diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImpl.java index de6d93342a..9381104053 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImpl.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImpl.java @@ -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; @@ -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 }, @@ -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; @@ -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; } diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImplTest.java index 4eaf4c07cc..8d32998ea7 100644 --- a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImplTest.java +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImplTest.java @@ -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; @@ -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); diff --git a/bundles/af-core/src/test/resources/form/termsandconditions/exporter-termsandconditions.json b/bundles/af-core/src/test/resources/form/termsandconditions/exporter-termsandconditions.json index a8017f9c3d..135c166a6d 100644 --- a/bundles/af-core/src/test/resources/form/termsandconditions/exporter-termsandconditions.json +++ b/bundles/af-core/src/test/resources/form/termsandconditions/exporter-termsandconditions.json @@ -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" diff --git a/bundles/af-core/src/test/resources/form/text/exporter-text-datalayer.json b/bundles/af-core/src/test/resources/form/text/exporter-text-datalayer.json index ced8c2ac52..01205ff719 100644 --- a/bundles/af-core/src/test/resources/form/text/exporter-text-datalayer.json +++ b/bundles/af-core/src/test/resources/form/text/exporter-text-datalayer.json @@ -3,7 +3,6 @@ "fieldType": "plain-text", "name": "text1680491190398", "value": "This is an AF", - "richText": false, "events": { "custom:setProperty": [ "$event.payload" diff --git a/bundles/af-core/src/test/resources/form/text/exporter-text-with-viewtype.json b/bundles/af-core/src/test/resources/form/text/exporter-text-with-viewtype.json index c9c338ee3b..30459b8d8b 100644 --- a/bundles/af-core/src/test/resources/form/text/exporter-text-with-viewtype.json +++ b/bundles/af-core/src/test/resources/form/text/exporter-text-with-viewtype.json @@ -2,7 +2,6 @@ "id": "text-2c82909883", "fieldType": "plain-text", "name": "abc", - "richText": false, "properties": { "fd:path": "/content/text-with-viewtype" }, diff --git a/bundles/af-core/src/test/resources/form/text/exporter-text.json b/bundles/af-core/src/test/resources/form/text/exporter-text.json index 4243f7d3dd..cfbcb08eb2 100644 --- a/bundles/af-core/src/test/resources/form/text/exporter-text.json +++ b/bundles/af-core/src/test/resources/form/text/exporter-text.json @@ -1,7 +1,6 @@ { "id": "text-ac0bcff4f3", "fieldType": "plain-text", - "richText": false, "name": "abc", ":type": "core/fd/components/form/text/v1/text", "properties": { @@ -13,4 +12,4 @@ "$event.payload" ] } -} \ No newline at end of file +} diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/checkbox/v1/checkbox/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/checkbox/v1/checkbox/_cq_dialog/.content.xml index babd5a5f03..97c10253f7 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/checkbox/v1/checkbox/_cq_dialog/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/checkbox/v1/checkbox/_cq_dialog/.content.xml @@ -74,7 +74,7 @@ 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"/> @@ -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"/> diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/_cq_dialog/.content.xml index 367c397277..3a7a50e550 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/_cq_dialog/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/_cq_dialog/.content.xml @@ -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"/> + + + + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput/_cq_dialog/.content.xml index 961d61af41..e09d7c6665 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput/_cq_dialog/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/fileinput/v3/fileinput/_cq_dialog/.content.xml @@ -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="">