From b033ae853ced5a490f4d276bbb3cbb154077b782 Mon Sep 17 00:00:00 2001 From: Rishi Mehta <69448117+rismehta@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:53:21 +0530 Subject: [PATCH 01/16] Fixing versions.md script (#906) --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 87cccfd1ea..1d55892863 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -335,6 +335,12 @@ jobs: # update readme.md sed -i -E "s/(\| $LAST_VERSION\s*\|) [0-9]+\.[0-9]+\.[0-9]+ \s*\| /| $NEW_VERSION | $WCM_CORE_COMPONENTS_VERSION | /g" README.md + # Check if package-lock.json is modified + if [[ $(git status --porcelain | grep "package-lock.json") ]]; then + # Discard the changes to package-lock.json (if needed) + git checkout -- '**/package-lock.json' + fi + git add VERSIONS.md README.md git commit -m "Update VERSIONS.md and README.md to include version ${NEW_VERSION}" git push origin $RELEASE_BRANCH From f36a80e3d52346e01bce4ed305b9f3d9762cd98f Mon Sep 17 00:00:00 2001 From: Pankaj Parashar Date: Thu, 5 Oct 2023 17:24:39 +0530 Subject: [PATCH 02/16] FORMS-11162 - Accessibility Issue - Forms iframe head tag issue (#907) --- .../core/fd/components/aemform/v1/aemform/iframe.html | 8 ++++---- .../core/fd/components/aemform/v2/aemform/iframe.html | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v1/aemform/iframe.html b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v1/aemform/iframe.html index 1f5e531965..d0346766c5 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v1/aemform/iframe.html +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v1/aemform/iframe.html @@ -14,10 +14,10 @@ ~ limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/--> - - - + + + + <sly data-sly-use.af="com.adobe.aemds.guide.common.AdaptiveForm" />${af.formTitle @ context='html'} diff --git a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html index fd4a044aea..69a4e8d12e 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html +++ b/ui.apps/src/main/content/jcr_root/apps/core/fd/components/aemform/v2/aemform/iframe.html @@ -14,10 +14,10 @@ ~ limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/--> - - - + + + + <sly data-sly-use.af="com.adobe.aemds.guide.common.AdaptiveForm" />${af.formTitle @ context='html'} From bb75aa9df712026c8f8d66b34eee3717ea2f62f9 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal <47965724+im-shiv@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:28:40 +0530 Subject: [PATCH 03/16] FORMS-3696 adding rich text support for labels (#904) * FORMS-3696 adding rich text support for labels FORMS-3696 adding rich text support for labels Co-authored-by: Shivam Agarwal * FORMS-3696 adding test for deprecated method * FORMS-3696 adding inline editor logic * FORMS-3696 addressed review comments * FORMS-3696 sorting options constraint * FORMS-3696 adding some more test cases --------- Co-authored-by: Shivam Agarwal --- .../core/components/models/form/Label.java | 26 +- .../models/form/OptionsConstraint.java | 13 + .../components/models/form/TextContent.java | 51 ++++ .../components/models/form/package-info.java | 2 +- .../util/AbstractOptionsFieldImpl.java | 32 +++ .../models/v1/form/CheckBoxGroupImplTest.java | 45 ++++ .../models/v1/form/CheckBoxImplTest.java | 16 +- .../models/v1/form/DropDownImplTest.java | 47 ++++ .../models/v1/form/RadioButtonImplTest.java | 43 ++- .../exporter-checkboxgroup-datalayer.json | 8 +- .../checkboxgroup/exporter-checkboxgroup.json | 12 +- .../form/dropdown/exporter-dropdown-1.json | 12 +- .../dropdown/exporter-dropdown-datalayer.json | 8 +- .../form/dropdown/exporter-dropdown.json | 12 +- .../exporter-multiselect-dropdown.json | 12 +- .../exporter-radiobutton-customized.json | 10 +- .../exporter-radiobutton-datalayer.json | 8 +- .../radiobutton/exporter-radiobutton.json | 10 +- .../form/radiobutton/test-content.json | 10 +- .../samples/checkboxgroup/basic/.content.xml | 22 ++ .../af-commons/v1/fieldTemplates/label.html | 4 +- .../accordion/v1/accordion/accordion.html | 2 +- .../form/base/v1/base/_cq_dialog/.content.xml | 253 +++++++++++++++++- .../form/base/v1/base/_cq_editConfig.xml | 122 ++++++++- .../base/clientlibs/editor/js/editDialog.js | 155 ++++++++++- .../button/v1/button/_cq_dialog/.content.xml | 7 +- .../form/button/v1/button/_cq_editConfig.xml | 122 ++++++++- .../form/button/v1/button/button.html | 2 +- .../form/checkbox/v1/checkbox/checkbox.html | 2 +- .../v1/checkboxgroup/checkboxgroup.html | 4 +- .../v2/container/clientlibs/editorhook/js.txt | 1 + .../editorhook/js/toolbaractionhook.js | 52 ++++ .../datepicker/v1/datepicker/datepicker.html | 2 +- .../v1/dropdown/_cq_dialog/.content.xml | 51 +++- .../form/dropdown/v1/dropdown/dropdown.html | 8 +- .../emailinput/v1/emailinput/emailinput.html | 2 +- .../fileinput/v1/fileinput/fileinput.html | 2 +- .../image/v1/image/_cq_dialog/.content.xml | 6 + .../v1/numberinput/numberinput.html | 2 +- .../v1/panelcontainer/_cq_dialog/.content.xml | 8 + .../v1/panelcontainer/responsiveGrid.html | 2 +- .../v1/panelcontainer/simple.html | 2 +- .../v1/radiobutton/radiobutton.html | 4 +- .../tabsontop/v1/tabsontop/tabsontop.html | 2 +- .../v1/telephoneinput/telephoneinput.html | 2 +- .../fd/components/form/text/v1/text/text.html | 3 +- .../textinput/v1/textinput/textinput.html | 2 +- .../form/wizard/v1/wizard/wizard.html | 2 +- .../specs/button/button.authoring.spec.js | 26 +- .../checkboxgroup.authoring.spec.js | 28 +- .../checkboxgroup.runtime.spec.js | 8 + .../specs/image/image.authoring.spec.js | 15 +- .../panelcontainer.authoring.spec.js | 15 +- .../radiobutton/radiobutton.authoring.spec.js | 20 ++ .../textinput/textinput.authoring.spec.js | 35 ++- 55 files changed, 1256 insertions(+), 116 deletions(-) create mode 100644 bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/editorhook/js/toolbaractionhook.js diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java index a7106b9f97..05f75471e6 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java @@ -21,21 +21,10 @@ /** * Interface for a label * - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + * @since com.adobe.cq.forms.core.components.models.form 4.6.0 */ @ConsumerType -public interface Label { - - /** - * Returns {@code true} if label is rich text, otherwise {@code false}. - * - * @return {@code true} if label is rich text, otherwise {@code false} - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Nullable - default Boolean isRichText() { - return null; - } +public interface Label extends TextContent { /** * Returns {@code true} if label should be visible, otherwise {@code false}. @@ -48,15 +37,4 @@ default Boolean isVisible() { return null; } - /** - * Returns the value of this label. - * - * @return the value of this label - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Nullable - default String getValue() { - return null; - } - } diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java index 2b949352d7..93770a63bd 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java @@ -17,6 +17,7 @@ import org.osgi.annotation.versioning.ProviderType; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -57,5 +58,17 @@ default boolean isEnforceEnum() { * @return the list of enum names * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ + @Deprecated + @JsonIgnore String[] getEnumNames(); + + /** + * Returns a list of RichText to be displayed to the end user. + * The length of enum and enumNames array must match + * + * @return the list of enum names + * @since com.adobe.cq.forms.core.components.models.form 4.6.0 + */ + @JsonProperty("enumNames") + TextContent[] getEnumNamesAsTextContent(); } diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java new file mode 100644 index 0000000000..30b7006263 --- /dev/null +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java @@ -0,0 +1,51 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ Copyright 2023 Adobe + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.jetbrains.annotations.Nullable; +import org.osgi.annotation.versioning.ProviderType; + +/** + * Interface to represent text as rich content + * + * @since com.adobe.cq.forms.core.components.models.form 4.6.0 + */ +@ProviderType +public interface TextContent { + + /** + * Returns {@code true} if text is rich, otherwise {@code false}. + * + * @return {@code true} if text is rich, otherwise {@code false} + * @since com.adobe.cq.forms.core.components.models.form 4.6.0 + */ + @Nullable + default Boolean isRichText() { + return null; + } + + /** + * Returns a user friendly text to display for the possible options to be shown to the end user. + * + * @return the content of this text + * @since com.adobe.cq.forms.core.components.models.form 4.6.0 + */ + @Nullable + default String getValue() { + return null; + } + +} \ No newline at end of file diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java index 569a0f2118..ff809fcbdc 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java @@ -34,7 +34,7 @@ * version, is bound to this proxy component resource type. *

*/ -@Version("4.5.0") +@Version("4.6.0") package com.adobe.cq.forms.core.components.models.form; import org.osgi.annotation.versioning.Version; diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java index 31fd23f66a..96af116db8 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java @@ -29,6 +29,9 @@ import com.adobe.cq.forms.core.components.models.form.Field; import com.adobe.cq.forms.core.components.models.form.OptionsConstraint; +import com.adobe.cq.forms.core.components.models.form.TextContent; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; /** * Abstract class which can be used as base class for options {@link Field} implementations. @@ -49,6 +52,10 @@ public abstract class AbstractOptionsFieldImpl extends AbstractFieldImpl impleme @Nullable private String[] enumNames; + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "areOptionsRichText") + @Nullable + private Boolean areOptionsRichText; + @Override public boolean isEnforceEnum() { return enforceEnum; @@ -95,6 +102,8 @@ public Object[] getEnums() { } @Override + @Deprecated + @JsonIgnore public String[] getEnumNames() { if (enumNames != null) { Map map = removeDuplicates(); @@ -108,6 +117,29 @@ public String[] getEnumNames() { return null; } + @Override + public TextContent[] getEnumNamesAsTextContent() { + if (enumNames != null) { + Map map = removeDuplicates(); + String[] enumName = map.values().toArray(new String[0]); + return Arrays.stream(enumName) + .map(p -> new TextContent() { + @Override + @JsonInclude(JsonInclude.Include.NON_NULL) + public @Nullable Boolean isRichText() { + return areOptionsRichText; + } + + @Override + public @Nullable String getValue() { + return translate("enumNames", p); + } + }) + .toArray(TextContent[]::new); + } + return null; + } + @Override public Object[] getDefault() { Object[] typedDefaultValue = null; diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java index 8f887346e4..2a47560728 100644 --- a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -294,6 +295,44 @@ void testGetType() { void testGetEnumNames() { CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP); assertArrayEquals(new String[] { "m", "f", "o" }, checkboxGroup.getEnumNames()); + TextContent textContent1 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return null; + } + + @Override + public @Nullable String getValue() { + return "m"; + } + }; + TextContent textContent2 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return null; + } + + @Override + public @Nullable String getValue() { + return "f"; + } + }; + TextContent textContent3 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return null; + } + + @Override + public @Nullable String getValue() { + return "o"; + } + }; + TextContent[] textContent = new TextContent[] { textContent1, textContent2, textContent3 }; + for (int i = 0; i < checkboxGroup.getEnumNamesAsTextContent().length; i++) { + assertEquals(textContent[i].getValue(), checkboxGroup.getEnumNamesAsTextContent()[i].getValue()); + assertEquals(textContent[i].isRichText(), checkboxGroup.getEnumNamesAsTextContent()[i].isRichText()); + } } @Test @@ -304,6 +343,9 @@ void testGetEnumNamesWithDuplicateEnumValues() { map.put("1", "Item 2"); map.put("0", "Item 3"); assertArrayEquals(map.values().toArray(new String[0]), checkboxGroup.getEnumNames()); + String[] checkboxGroupValues = Arrays.stream(checkboxGroup.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray( + size -> new String[checkboxGroup.getEnumNamesAsTextContent().length]); + assertArrayEquals(map.values().toArray(new String[0]), checkboxGroupValues); } @Test @@ -377,5 +419,8 @@ void testInsertionOrderForEnumNames() { Set set = new LinkedHashSet<>(Arrays.asList("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty")); assertArrayEquals(set.toArray(new String[0]), checkboxGroup.getEnumNames()); + String[] checkboxGroupValues = Arrays.stream(checkboxGroup.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray( + size -> new String[checkboxGroup.getEnumNamesAsTextContent().length]); + assertArrayEquals(set.toArray(new String[0]), checkboxGroupValues); } } diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java index 071ce8d418..b3d8c6efbb 100644 --- a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxImplTest.java @@ -27,12 +27,8 @@ import com.adobe.cq.forms.core.Utils; import com.adobe.cq.forms.core.components.internal.form.FormConstants; -import com.adobe.cq.forms.core.components.models.form.Base; -import com.adobe.cq.forms.core.components.models.form.CheckBox; +import com.adobe.cq.forms.core.components.models.form.*; import com.adobe.cq.forms.core.components.models.form.CheckBox.Orientation; -import com.adobe.cq.forms.core.components.models.form.ConstraintType; -import com.adobe.cq.forms.core.components.models.form.FieldType; -import com.adobe.cq.forms.core.components.models.form.Label; import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext; import com.adobe.cq.wcm.style.ComponentStyleInfo; import io.wcm.testing.mock.aem.junit5.AemContext; @@ -309,6 +305,16 @@ void testGetEnum() { } + @Test + void testGetNullEnumNames() { + CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX); + assertNull(checkbox.getEnumNamesAsTextContent()); + assertNull(checkbox.getEnumNames()); + CheckBox noEnumCheckbox = getCheckBoxUnderTest(PATH_CHECKBOX_NOENUM); + assertNull(noEnumCheckbox.getEnumNamesAsTextContent()); + assertNull(noEnumCheckbox.getEnumNames()); + } + @Test void testGetNullEnum() { CheckBox noEnumCheckbox = getCheckBoxUnderTest(PATH_CHECKBOX_NOENUM); diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java index 824078c932..ed9b4da4b1 100644 --- a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/DropDownImplTest.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.sling.api.resource.Resource; import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -379,6 +380,44 @@ void testGetMultiSelectMaxItems() { void testGetEnumNames() { DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN_1, DropDown.class, context); assertArrayEquals(new String[] { "m", "f", "o" }, dropdown.getEnumNames()); + TextContent textContent1 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return null; + } + + @Override + public @Nullable String getValue() { + return "m"; + } + }; + TextContent textContent2 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return null; + } + + @Override + public @Nullable String getValue() { + return "f"; + } + }; + TextContent textContent3 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return null; + } + + @Override + public @Nullable String getValue() { + return "o"; + } + }; + TextContent[] textContent = new TextContent[] { textContent1, textContent2, textContent3 }; + for (int i = 0; i < dropdown.getEnumNamesAsTextContent().length; i++) { + assertEquals(textContent[i].getValue(), dropdown.getEnumNamesAsTextContent()[i].getValue()); + assertEquals(textContent[i].isRichText(), dropdown.getEnumNamesAsTextContent()[i].isRichText()); + } } @Test @@ -389,6 +428,10 @@ void testGetEnumNamesWithDuplicateEnumValues() { map.put("1", "Item 2"); map.put("0", "Item 3"); assertArrayEquals(map.values().toArray(new String[0]), dropdown.getEnumNames()); + String[] dropdownValues = Arrays.stream(dropdown.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray( + size -> new String[dropdown + .getEnumNamesAsTextContent().length]); + assertArrayEquals(map.values().toArray(new String[0]), dropdownValues); } @Test @@ -438,5 +481,9 @@ void testInsertionOrderForEnumNames() { Set set = new LinkedHashSet<>(Arrays.asList("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty")); assertArrayEquals(set.toArray(new String[0]), dropdown.getEnumNames()); + String[] dropdownValues = Arrays.stream(dropdown.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray( + size -> new String[dropdown + .getEnumNamesAsTextContent().length]); + assertArrayEquals(set.toArray(new String[0]), dropdownValues); } } diff --git a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/RadioButtonImplTest.java b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/RadioButtonImplTest.java index 22dcf6f74a..3df63727d1 100644 --- a/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/RadioButtonImplTest.java +++ b/bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/RadioButtonImplTest.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; +import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -307,10 +308,42 @@ void testGetType() { assertEquals(BaseConstraint.Type.STRING, radioButtonMock.getType()); } + @Test + void testDeprecatedGetEnumNames() { + RadioButton radioButton = getRadioButtonUnderTest(PATH_RADIOBUTTON_CUSTOMIZED); + assertArrayEquals(new String[] { "

Item 1

", "

Item 2

" }, radioButton.getEnumNames()); + } + @Test void testGetEnumNames() { RadioButton radioButton = getRadioButtonUnderTest(PATH_RADIOBUTTON_CUSTOMIZED); - assertArrayEquals(new String[] { "Item 1", "Item 2" }, radioButton.getEnumNames()); + TextContent textContent1 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return true; + } + + @Override + public @Nullable String getValue() { + return "

Item 1

"; + } + }; + TextContent textContent2 = new TextContent() { + @Override + public @Nullable Boolean isRichText() { + return true; + } + + @Override + public @Nullable String getValue() { + return "

Item 2

"; + } + }; + TextContent[] textContent = new TextContent[] { textContent1, textContent2 }; + for (int i = 0; i < radioButton.getEnumNamesAsTextContent().length; i++) { + assertEquals(textContent[i].getValue(), radioButton.getEnumNamesAsTextContent()[i].getValue()); + assertEquals(textContent[i].isRichText(), radioButton.getEnumNamesAsTextContent()[i].isRichText()); + } } @Test @@ -321,6 +354,10 @@ void testGetEnumNamesWithDuplicateEnumValues() { map.put("1", "Item 2"); map.put("0", "Item 3"); assertArrayEquals(map.values().toArray(new String[0]), radioButton.getEnumNames()); + String[] radioButtonValues = Arrays.stream(radioButton.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray( + size -> new String[radioButton + .getEnumNamesAsTextContent().length]); + assertArrayEquals(map.values().toArray(new String[0]), radioButtonValues); } @Test @@ -389,5 +426,9 @@ void testInsertionOrderForEnumNames() { Set set = new LinkedHashSet<>(Arrays.asList("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty")); assertArrayEquals(set.toArray(new String[0]), radioButton.getEnumNames()); + String[] radioButtonValues = Arrays.stream(radioButton.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray( + size -> new String[radioButton + .getEnumNamesAsTextContent().length]); + assertArrayEquals(set.toArray(new String[0]), radioButtonValues); } } diff --git a/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup-datalayer.json b/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup-datalayer.json index 986b3f2b6a..de77a5d84f 100644 --- a/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup-datalayer.json +++ b/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup-datalayer.json @@ -9,8 +9,12 @@ "readOnly": false, "enforceEnum": true, "enumNames": [ - "Cat Person", - "Dog Person" + { + "value": "Cat Person" + }, + { + "value": "Dog Person" + } ], "label": { "value": "Personality" diff --git a/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json b/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json index b71aa10538..f82ba6229a 100644 --- a/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json +++ b/bundles/af-core/src/test/resources/form/checkboxgroup/exporter-checkboxgroup.json @@ -16,9 +16,15 @@ "readOnly": true, "enforceEnum": true, "enumNames": [ - "m", - "f", - "o" + { + "value": "m" + }, + { + "value": "f" + }, + { + "value": "o" + } ], "default": [ 0, diff --git a/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-1.json b/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-1.json index 60987e7d27..b20398a150 100644 --- a/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-1.json +++ b/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-1.json @@ -15,9 +15,15 @@ "readOnly": false, "enforceEnum": true, "enumNames": [ - "m", - "f", - "o" + { + "value": "m" + }, + { + "value": "f" + }, + { + "value": "o" + } ], "label": { "visible": true, diff --git a/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-datalayer.json b/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-datalayer.json index 4b7d3b72e6..f02d9514a7 100644 --- a/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-datalayer.json +++ b/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown-datalayer.json @@ -9,8 +9,12 @@ "readOnly": false, "enforceEnum": true, "enumNames": [ - "Owl", - "Wolf" + { + "value": "Owl" + }, + { + "value": "Wolf" + } ], "label": { "value": "Favorite Animal" diff --git a/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown.json b/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown.json index 7ecce9aa4e..64e232f04e 100644 --- a/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown.json +++ b/bundles/af-core/src/test/resources/form/dropdown/exporter-dropdown.json @@ -4,7 +4,17 @@ "name": "abc", "type": "string", "enforceEnum": true, - "enumNames": ["m", "f", "o"], + "enumNames": [ + { + "value": "m" + }, + { + "value": "f" + }, + { + "value": "o" + } + ], "enum": ["0", "1", "2"], "label": { "value": "def" diff --git a/bundles/af-core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json b/bundles/af-core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json index 43860b3db0..9547715155 100644 --- a/bundles/af-core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json +++ b/bundles/af-core/src/test/resources/form/dropdown/exporter-multiselect-dropdown.json @@ -15,9 +15,15 @@ }, "enforceEnum": true, "enumNames": [ - "m", - "f", - "o" + { + "value": "m" + }, + { + "value": "f" + }, + { + "value": "o" + } ], "default": [ 0, diff --git a/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-customized.json b/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-customized.json index 988424436a..7225f64b53 100644 --- a/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-customized.json +++ b/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-customized.json @@ -16,8 +16,14 @@ }, "enforceEnum": true, "enumNames": [ - "Item 1", - "Item 2" + { + "richText": true, + "value": "

Item 1

" + }, + { + "richText": true, + "value": "

Item 2

" + } ], "default": "0", "screenReaderText": "'custom text'", diff --git a/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-datalayer.json b/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-datalayer.json index 6662d77b6d..870734a41e 100644 --- a/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-datalayer.json +++ b/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton-datalayer.json @@ -9,8 +9,12 @@ "readOnly": false, "enforceEnum": true, "enumNames": [ - "Male", - "Female" + { + "value": "Male" + }, + { + "value": "Female" + } ], "label": { "value": "Gender" diff --git a/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton.json b/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton.json index 078687521f..9fd2561296 100644 --- a/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton.json +++ b/bundles/af-core/src/test/resources/form/radiobutton/exporter-radiobutton.json @@ -5,8 +5,14 @@ "type": "string", "enforceEnum": true, "enumNames": [ - "Item 1", - "Item 2" + { + "richText": true, + "value": "

Item 1

" + }, + { + "richText": true, + "value": "

Item 2

" + } ], "label": { "value": "Radio Button" diff --git a/bundles/af-core/src/test/resources/form/radiobutton/test-content.json b/bundles/af-core/src/test/resources/form/radiobutton/test-content.json index d68b10d0c8..076198ea4c 100644 --- a/bundles/af-core/src/test/resources/form/radiobutton/test-content.json +++ b/bundles/af-core/src/test/resources/form/radiobutton/test-content.json @@ -8,13 +8,14 @@ "orientation": "vertical", "jcr:lastModifiedBy": "admin", "jcr:created": "Tue Sep 13 2022 15:17:35 GMT+0530", + "areOptionsRichText": true, "enum": [ "0", "1" ], "enumNames": [ - "Item 1", - "Item 2" + "

Item 1

", + "

Item 2

" ], "jcr:lastModified": "Tue Sep 13 2022 15:18:50 GMT+0530", "fieldType": "radio-group" @@ -37,14 +38,15 @@ "dorColspan": "4", "assistPriority": "custom", "jcr:created": "Tue Sep 13 2022 15:17:35 GMT+0530", + "areOptionsRichText": true, "enum": [ "0", "1" ], "type": "string", "enumNames": [ - "Item 1", - "Item 2" + "

Item 1

", + "

Item 2

" ], "visible": false, "readOnly": true, diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/checkboxgroup/basic/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/checkboxgroup/basic/.content.xml index 30e1d78040..9dc2b02920 100755 --- a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/checkboxgroup/basic/.content.xml +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/checkboxgroup/basic/.content.xml @@ -153,6 +153,28 @@ textIsRich="[true,true]" type="number[]" visible="{Boolean}true"/> + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/af-commons/v1/fieldTemplates/label.html b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/af-commons/v1/fieldTemplates/label.html index 07f79c829e..823bd9bd9b 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/af-commons/v1/fieldTemplates/label.html +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/af-commons/v1/fieldTemplates/label.html @@ -1,4 +1,4 @@ -