Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.Nullable;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
Expand All @@ -32,6 +32,8 @@
import com.adobe.cq.forms.core.components.models.form.Text;
import com.adobe.cq.forms.core.components.util.AbstractFormComponentImpl;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@Model(
adaptables = { SlingHttpServletRequest.class, Resource.class },
Expand All @@ -42,8 +44,8 @@
public class TextImpl extends AbstractFormComponentImpl implements Text {

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_TEXT_IS_RICH)
@Default(booleanValues = false)
private boolean textIsRich;
@Nullable
private Boolean textIsRich;

@SlingObject
private Resource resource;
Expand All @@ -54,7 +56,14 @@ public String getValue() {
}

@Override
@JsonIgnore
public boolean isRichText() {
return textIsRich != null && textIsRich;
}

@JsonProperty("richText")
@JsonInclude(JsonInclude.Include.NON_NULL)
public Boolean getRichText() {
return textIsRich;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.*;
import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;

Expand Down Expand Up @@ -91,6 +92,15 @@ void testIsRichText() {
assertEquals(false, textMock.isRichText());
}

@Test
void testRichTextAbsentFromJcr() throws Exception {
Text text = Utils.getComponentUnderTest(PATH_TEXT, Text.class, context);
assertEquals(false, text.isRichText());
String json = new ObjectMapper().writeValueAsString(text);
assertFalse("richText must not appear in JSON when textIsRich is absent from JCR",
json.contains("\"richText\""));
}

@Test
void testGetDataRef() {
Text text = Utils.getComponentUnderTest(PATH_TEXT_CUSTOMIZED, Text.class, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"fieldType": "plain-text",
"name": "consenttext",
"value": "Text related to the terms and conditions come here",
"richText": false,
"events": {
"custom:setProperty": [
"$event.payload"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"fieldType": "plain-text",
"name": "text1680491190398",
"value": "This is an AF",
"richText": false,
"events": {
"custom:setProperty": [
"$event.payload"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"id": "text-2c82909883",
"fieldType": "plain-text",
"name": "abc",
"richText": false,
"properties": {
"fd:path": "/content/text-with-viewtype"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"id": "text-ac0bcff4f3",
"fieldType": "plain-text",
"richText": false,
"name": "abc",
":type": "core/fd/components/form/text/v1/text",
"properties": {
Expand All @@ -13,4 +12,4 @@
"$event.payload"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="When Checked, return value"
fieldDescription="Specify the value to be returned when the checkbox is checked by the user."
fieldDescription="Value submitted when the checkbox is checked. Enter the value as text. For boolean fields, use true. For numeric intent, enter values such as 1 as text."
name="./checkedValue"/>
<enableUncheckedValue
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/switch"
wrapperClass="cmp-adaptiveform-checkbox__enable-unchecked-value"
name="./enableUncheckedValue"
fieldLabel="Preserve Uncheck state value."
fieldDescription="Specify the value to be returned when the checkbox is not checked by the user."
fieldDescription="When enabled, the unchecked value is submitted when the checkbox is not selected."
uncheckedValue="false"
value="true">
</enableUncheckedValue>
Expand All @@ -96,6 +96,7 @@
fieldLabel="When Unchecked, return value"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Value submitted when the checkbox is unchecked. Used only when 'Preserve Uncheck state value' is enabled. Enter the value as text. For boolean fields, use false."
name="./uncheckedValue"/>
</items>
</enumsCustom>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@
text="Enable the hamburger menu for mobile view"
fieldDescription="Select the option to display the hamburger menu for efficient navigation on mobile devices."
value="{Boolean}true"/>
<fieldType
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
name="./fieldType"
required="{Boolean}true"
granite:hidden="true">
<items jcr:primaryType="nt:unstructured">
<item jcr:primaryType="nt:unstructured"
text="Form"
value="form"
selected="{Boolean}true"/>
</items>
</fieldType>
</items>
</container>
</items>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@
fieldDescription="Specify allowed MIME types (for example, image/jpeg) to filter uploads. You can use this option or 'Allowed file extensions'. However, this setting is disabled if any 'Allowed file extensions' are specified."
defaultValue="">
<field
fieldLabel="Allowed file types"
fieldDescription="Allowed file MIME types. Add one MIME type per value, for example application/pdf or image/png. Do not use file extensions or comma-separated text. Leave empty to allow any file type."
name="./accept"
multiple="{Boolean}true"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"/>
</mimeType>
Expand Down