Skip to content

Commit 4f485ea

Browse files
authored
FORMS-16911 Prefill of static text with explicit data bindings (#1443)
@review @vdua DOD(Yes)
1 parent 3ac02d4 commit 4f485ea

File tree

11 files changed

+71
-25
lines changed

11 files changed

+71
-25
lines changed

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImpl.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ public class TextImpl extends AbstractFormComponentImpl implements Text {
4848
@SlingObject
4949
private Resource resource;
5050

51-
@Override
52-
protected void initBaseModel() {
53-
// Always make dataRef of Text component as null, for this we need to make unboundFormElement as true
54-
unboundFormElement = Boolean.TRUE;
55-
super.initBaseModel();
56-
}
57-
5851
@Override
5952
public String getValue() {
6053
return translate("value", value);

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/TextImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void testIsRichText() {
9393
@Test
9494
void testGetDataRef() {
9595
Text text = Utils.getComponentUnderTest(PATH_TEXT_CUSTOMIZED, Text.class, context);
96-
assertEquals("null", text.getDataRef());
96+
assertEquals("a.b", text.getDataRef());
9797
Text textMock = Mockito.mock(Text.class);
9898
Mockito.when(textMock.getDataRef()).thenCallRealMethod();
9999
assertEquals(null, textMock.getDataRef());

bundles/af-core/src/test/resources/form/termsandconditions/exporter-termsandconditions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"name": "consenttext",
3333
"value": "Text related to the terms and conditions come here",
3434
"richText": false,
35-
"dataRef": null,
3635
"events": {
3736
"custom:setProperty": [
3837
"$event.payload"

bundles/af-core/src/test/resources/form/text/exporter-text-customized.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "text-bb9fec86e7",
3-
"dataRef": null,
3+
"dataRef": "a.b",
44
"fieldType": "plain-text",
55
"name": "abc",
66
"value": "<p>xyz</p>",

bundles/af-core/src/test/resources/form/text/exporter-text-datalayer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"id": "text-cfbea91bba",
33
"fieldType": "plain-text",
4-
"dataRef": null,
54
"name": "text1680491190398",
65
"value": "This is an AF",
76
"richText": false,

bundles/af-core/src/test/resources/form/text/exporter-text.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"id": "text-ac0bcff4f3",
33
"fieldType": "plain-text",
4-
"dataRef": null,
54
"richText": false,
65
"name": "abc",
76
":type": "core/fd/components/form/text/v1/text",

it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/clientlib-it-custom-function/js/functions.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ function testImportData(globals)
165165
globals.functions.importData(Object.fromEntries([['textinput_12605243111716188337417','abc']]));
166166
}
167167

168+
/**
169+
* Tests static text import data
170+
* @name testTextImportData
171+
* @param {scope} globals
172+
*/
173+
function testTextImportData(globals)
174+
{
175+
globals.functions.importData({'a' : {'b' : 'prefilled'}});
176+
}
177+
168178
/**
169179
* Tests set focus
170180
* @name testSetFocus

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
fd:version="2.1"
1515
jcr:primaryType="nt:unstructured"
1616
sling:resourceType="forms-components-examples/components/form/container"
17+
clientLibRef="corecomponent.it.customfunction"
18+
schemaType="none"
19+
specVersion="0.14.2"
1720
fieldType="form">
1821
<textinput
1922
jcr:primaryType="nt:unstructured"
@@ -71,6 +74,47 @@
7174
jcr:primaryType="nt:unstructured"
7275
click="[dispatchEvent('reset')]"/>
7376
</reset>
77+
<text_327821969
78+
jcr:created="{Date}2024-10-16T11:14:16.467+05:30"
79+
jcr:createdBy="admin"
80+
jcr:lastModified="{Date}2024-10-16T11:34:33.938+05:30"
81+
jcr:lastModifiedBy="admin"
82+
jcr:primaryType="nt:unstructured"
83+
jcr:title="Text"
84+
sling:resourceType="forms-components-examples/components/form/text"
85+
dataRef="$.a.b"
86+
fieldType="plain-text"
87+
name="prefilltext"
88+
textIsRich="true"
89+
unboundFormElement="{Boolean}false"
90+
value="&lt;p>prefill test&lt;/p>&#xd;&#xa;"
91+
visible="{Boolean}true">
92+
<fd:rules jcr:primaryType="nt:unstructured"/>
93+
<fd:events jcr:primaryType="nt:unstructured"/>
94+
</text_327821969>
95+
<button
96+
jcr:created="{Date}2024-10-16T11:15:30.148+05:30"
97+
jcr:createdBy="admin"
98+
jcr:lastModified="{Date}2024-10-16T11:15:43.398+05:30"
99+
jcr:lastModifiedBy="admin"
100+
jcr:primaryType="nt:unstructured"
101+
jcr:title="click to prefill static text"
102+
sling:resourceType="forms-components-examples/components/form/button"
103+
dorExclusion="true"
104+
enabled="{Boolean}true"
105+
fieldType="button"
106+
name="button1729057530205"
107+
textIsRich="[true,true,true]"
108+
unboundFormElement="{Boolean}false"
109+
visible="{Boolean}true">
110+
<fd:rules
111+
fd:click="[{&quot;nodeName&quot;:&quot;ROOT&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_SCRIPTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;EVENT_CONDITION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;COMPONENT&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.button1729057530205&quot;\,&quot;type&quot;:&quot;BUTTON&quot;\,&quot;name&quot;:&quot;button1729057530205&quot;}}\,{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON_OPERATOR&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;is clicked&quot;\,&quot;value&quot;:null}}\,{&quot;nodeName&quot;:&quot;PRIMITIVE_EXPRESSION&quot;\,&quot;choice&quot;:null}]}\,&quot;nested&quot;:false}\,{&quot;nodeName&quot;:&quot;Then&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;BLOCK_STATEMENTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;BLOCK_STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;FUNCTION_CALL&quot;\,&quot;parentNodeName&quot;:&quot;BLOCK_STATEMENT&quot;\,&quot;functionName&quot;:{&quot;id&quot;:&quot;testTextImportData&quot;\,&quot;displayName&quot;:&quot;testTextImportData&quot;\,&quot;type&quot;:&quot;STRING|NUMBER|BOOLEAN|DATE|ARRAY|OBJECT&quot;\,&quot;isDuplicate&quot;:false\,&quot;displayPath&quot;:&quot;&quot;\,&quot;args&quot;:[]\,&quot;impl&quot;:&quot;$0()&quot;}\,&quot;params&quot;:[]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;testTextImportData()&quot;]\,&quot;eventName&quot;:&quot;Click&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
112+
jcr:primaryType="nt:unstructured"
113+
validationStatus="valid"/>
114+
<fd:events
115+
jcr:primaryType="nt:unstructured"
116+
click="[testTextImportData()]"/>
117+
</button>
74118
</guideContainer>
75119
</jcr:content>
76120
</jcr:root>

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/text/v1/text/_cq_dialog/.content.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
<hideTitle
6060
jcr:primaryType="nt:unstructured"
6161
sling:hideResource="{Boolean}true"/>
62-
<bindref
63-
jcr:primaryType="nt:unstructured"
64-
sling:hideResource="{Boolean}true"/>
6562
<enabled
6663
jcr:primaryType="nt:unstructured"
6764
sling:hideResource="{Boolean}true"/>
@@ -71,9 +68,6 @@
7168
<dorBindref
7269
jcr:primaryType="nt:unstructured"
7370
sling:hideResource="{Boolean}true"/>
74-
<unboundFormElement
75-
jcr:primaryType="nt:unstructured"
76-
sling:hideResource="{Boolean}true" />
7771
<readonly
7872
jcr:primaryType="nt:unstructured"
7973
sling:hideResource="{Boolean}true" />

ui.tests/test-module/specs/text/text.authoring.cy.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ describe('Page - Authoring', function () {
5454
cy.get("[name='./name']")
5555
.should("exist");
5656
cy.get("[name='./dataRef']")
57-
.should("not.exist");
57+
.should("exist");
5858
cy.get("[name='./readOnly']")
5959
.should("not.exist");
6060
cy.get("[name='./unboundFormElement']")
61-
.should("not.exist");
62-
cy.get("[name='./dorBindRef']")
63-
.should("not.exist");
61+
.should("exist");
6462
cy.get('.cmp-adaptiveform-base__istitlerichtext').should('not.exist');
6563

6664
cy.get("[name='./visible'][type=\"checkbox\"]").should("exist").check();

0 commit comments

Comments
 (0)