Skip to content

Commit 7b7ac82

Browse files
authored
FORMS-19439 adding support for display format in text input (#1714)
* FORMS-19439 adding support for display format in text input * Fixing package lock * Fixing test case * Fixing design dialog inheritance * Fixing test * Fixing test * Fixing test cases * updating QS version * Using 22450 image * update wcm version * Fixing test * Fixing test * Skipping test for now * Commenting test
1 parent e6e2e77 commit 7b7ac82

File tree

27 files changed

+382
-71
lines changed

27 files changed

+382
-71
lines changed

.circleci/ci/it-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ try {
3939

4040
//todo: remove this later, once aem image is released, since sites rotary aem base image has "2.25.4"
4141
//let wcmVersion = ci.sh('mvn help:evaluate -Dexpression=core.wcm.components.version -q -DforceStdout', true);
42-
let wcmVersion = "2.27.0";
42+
let wcmVersion = "2.30.0";
4343
ci.stage("Integration Tests");
4444
ci.dir(qpPath, () => {
4545
// Connect to QP

.circleci/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
entrypoint: tail -f /dev/null # Keeps the container running
77

88
circleci-aem-cloudready:
9-
image: docker-adobe-cif-release.dr-uw2.adobeitc.com/circleci-aem-cloudready:19823-final-openjdk11
9+
image: docker-adobe-cif-release.dr-uw2.adobeitc.com/circleci-aem-cloudready:22450-openjdk11
1010
depends_on:
1111
- circleci-qp
1212
# Add any additional configurations or environment variables if needed

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/servlets/FormMetaDataDataSourceServlet.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import javax.servlet.Servlet;
3232
import javax.servlet.ServletException;
33-
import javax.servlet.http.HttpServletRequest;
3433

3534
import org.apache.commons.lang3.StringUtils;
3635
import org.apache.jackrabbit.JcrConstants;
@@ -143,7 +142,7 @@ protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHtt
143142
FormMetaDataType type = FormMetaDataType.fromString(getParameter(config, TYPE, request, null));
144143
String dataModel = getParameter(config, DATA_MODEL, request, "");
145144
actionTypeDataSource = new SimpleDataSource(getDataSourceResources(
146-
request, request.getResourceResolver(), type, dataModel).iterator());
145+
request, request.getResourceResolver(), type, dataModel, config).iterator());
147146
}
148147
request.setAttribute(DataSource.class.getName(), actionTypeDataSource);
149148
}
@@ -171,8 +170,8 @@ private Boolean isLangPolicy(FormMetaDataType type, Map.Entry<String, Object> en
171170
return type.equals(FormMetaDataType.LANG) && entry.getKey().startsWith(FormMetaDataType.LANG.getValue());
172171
}
173172

174-
private List<Resource> getDataSourceResources(HttpServletRequest request, ResourceResolver resourceResolver, FormMetaDataType type,
175-
String dataModel) {
173+
private List<Resource> getDataSourceResources(SlingHttpServletRequest request, ResourceResolver resourceResolver, FormMetaDataType type,
174+
String dataModel, Config config) {
176175
List<Resource> resources = new ArrayList<>();
177176
FormMetaData formMetaData = resourceResolver.adaptTo(FormMetaData.class);
178177
if (formMetaData != null) {
@@ -200,7 +199,15 @@ private List<Resource> getDataSourceResources(HttpServletRequest request, Resour
200199
}
201200
}
202201
}
203-
resources.add(getResourceForDropdownDisplay(resourceResolver, "Custom", "custom"));
202+
// Only add "Custom" option for non-text-input components
203+
String fieldType = "";
204+
if (config != null) {
205+
String retrievedFieldType = getParameter(config, FIELD_TYPE, request, "");
206+
fieldType = retrievedFieldType != null ? retrievedFieldType : "";
207+
}
208+
if (fieldType.isEmpty() || !"text-input".equals(fieldType)) {
209+
resources.add(getResourceForDropdownDisplay(resourceResolver, "Custom", "custom"));
210+
}
204211
break;
205212
case SUBMIT_ACTION:
206213
// filter the submit actions by uniqueness and data model

examples/ui.content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/policies/.content.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@
220220
jcr:primaryType="nt:unstructured"/>
221221
</default>
222222
</telephoneinput>
223+
<textinput jcr:primaryType="nt:unstructured">
224+
<default
225+
jcr:lastModified="{Date}2022-07-12T11:41:57.902+05:30"
226+
jcr:primaryType="nt:unstructured"
227+
jcr:title="textinput-default-policy"
228+
sling:resourceType="wcm/core/components/policy/policy"
229+
allowedFormat1="Phone Number=phonenumber"
230+
allowedFormat2="Social Security Number=socialsecuritynumber"
231+
allowedFormat3="Email Alphanumeric=email-alphanumeric"
232+
allowedFormat4="Zip Code=zipcode">
233+
<jcr:content
234+
jcr:primaryType="nt:unstructured"/>
235+
</default>
236+
</textinput>
223237
<panelcontainer jcr:primaryType="nt:unstructured">
224238
<default
225239
jcr:lastModified="{Date}2023-03-07T11:41:57.902+05:30"

examples/ui.content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-blank-v2/policies/.content.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
jcr:primaryType="nt:unstructured"
2929
sling:resourceType="wcm/core/components/policies/mapping">
3030
</numberinput>
31+
<textinput
32+
cq:policy="forms-components-examples/components/form/textinput/default"
33+
jcr:primaryType="nt:unstructured"
34+
sling:resourceType="wcm/core/components/policies/mapping">
35+
</textinput>
3136
<datepicker
3237
cq:policy="forms-components-examples/components/form/datepicker/default"
3338
jcr:primaryType="nt:unstructured"

examples/ui.content/src/main/content/jcr_root/conf/core-components-examples/settings/wcm/templates/af-xfa-blank-v2/policies/.content.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
jcr:primaryType="nt:unstructured"
2929
sling:resourceType="wcm/core/components/policies/mapping">
3030
</numberinput>
31+
<textinput
32+
cq:policy="forms-components-examples/components/form/textinput/default"
33+
jcr:primaryType="nt:unstructured"
34+
sling:resourceType="wcm/core/components/policies/mapping">
35+
</textinput>
3136
<datepicker
3237
cq:policy="forms-components-examples/components/form/datepicker/default"
3338
jcr:primaryType="nt:unstructured"

it/config/src/main/content/jcr_root/apps/system/config/com.adobe.granite.toggle.impl.dev.DynamicToggleProviderImpl.cfg.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"FT_FORMS-16351",
2525
"FT_FORMS-14518",
2626
"FT_FORMS-13519"
27+
],
28+
"disabledToggles": [
29+
"FT_FORMS-17107"
2730
]
2831
}

it/content/src/main/content/jcr_root/conf/core-components-it/settings/wcm/policies/.content.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,20 @@
531531
<jcr:content jcr:primaryType="nt:unstructured"/>
532532
</default>
533533
</datepicker>
534+
<textinput jcr:primaryType="nt:unstructured">
535+
<default
536+
jcr:lastModified="{Date}2022-07-12T11:41:57.902+05:30"
537+
jcr:primaryType="nt:unstructured"
538+
jcr:title="textinput-default-policy"
539+
sling:resourceType="wcm/core/components/policy/policy"
540+
allowedFormat1="Phone Number=phonenumber"
541+
allowedFormat2="Social Security Number=socialsecuritynumber"
542+
allowedFormat3="Email Alphanumeric=email-alphanumeric"
543+
allowedFormat4="Zip Code=zipcode">
544+
<jcr:content
545+
jcr:primaryType="nt:unstructured"/>
546+
</default>
547+
</textinput>
534548
<panelcontainer jcr:primaryType="nt:unstructured">
535549
<default
536550
jcr:lastModified="{Date}2023-03-07T11:41:57.902+05:30"

it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/textinput/basic/.content.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,25 @@
213213
textIsRich="[true,true,true]"
214214
unboundFormElement="{Boolean}false"
215215
visible="{Boolean}true"/>
216+
<textinput_displayformat
217+
jcr:created="{Date}2025-01-15T10:00:00.000+05:30"
218+
jcr:createdBy="admin"
219+
jcr:lastModified="{Date}2025-01-15T10:00:00.000+05:30"
220+
jcr:lastModifiedBy="admin"
221+
jcr:primaryType="nt:unstructured"
222+
jcr:title="Text Input with Display Format"
223+
sling:resourceType="forms-components-examples/components/form/textinput"
224+
displayValueExpression="formatInput($field.$value, 'phonenumber')"
225+
displayFormat="phonenumber"
226+
displayPatternType="phonenumber"
227+
enabled="{Boolean}true"
228+
fieldType="text-input"
229+
hideTitle="false"
230+
name="textinput_displayformat"
231+
readOnly="{Boolean}false"
232+
textIsRich="[true,true,true]"
233+
unboundFormElement="{Boolean}false"
234+
visible="{Boolean}true"/>
216235
<submit
217236
jcr:lastModified="{Date}2023-06-22T17:28:46.456+05:30"
218237
jcr:lastModifiedBy="admin"

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/af-commons/v1/clientlibs/editor/utils/utils.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,21 @@
177177
let patternComponentParentDiv=patternComponent.closest("div");
178178
patternComponentParentDiv.setAttribute("hidden", true);
179179
}else {
180-
let displayFormatParentDiv=formatComponent.closest("div");
181-
switch (displayPatternSelectedValue) {
182-
case "" :
183-
case "#####################.###############" :
184-
displayFormatParentDiv.setAttribute("hidden", true);
185-
break;
186-
default :
187-
displayFormatParentDiv.removeAttribute("hidden");
180+
// Only handle format component if it exists and is not hidden
181+
if (formatComponent && !formatComponent.closest("div").hasAttribute("hidden")) {
182+
let displayFormatParentDiv=formatComponent.closest("div");
183+
switch (displayPatternSelectedValue) {
184+
case "" :
185+
case "#####################.###############" :
186+
displayFormatParentDiv.setAttribute("hidden", true);
187+
break;
188+
default :
189+
displayFormatParentDiv.removeAttribute("hidden");
190+
}
188191
}
189192
}
190-
if(displayPatternSelectedValue!="custom") {
193+
// Only update format component value if it exists and is not hidden
194+
if (formatComponent && !formatComponent.closest("div").hasAttribute("hidden") && displayPatternSelectedValue!="custom") {
191195
formatComponent.value = patternComponent.value;
192196
}
193197
}

0 commit comments

Comments
 (0)