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 44b7cf71fa..de6d93342a 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 @@ -48,13 +48,6 @@ public class TextImpl extends AbstractFormComponentImpl implements Text { @SlingObject private Resource resource; - @Override - protected void initBaseModel() { - // Always make dataRef of Text component as null, for this we need to make unboundFormElement as true - unboundFormElement = Boolean.TRUE; - super.initBaseModel(); - } - @Override public String getValue() { return translate("value", value); 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 b2cc0b4a96..85f0b2c975 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 @@ -93,7 +93,7 @@ void testIsRichText() { @Test void testGetDataRef() { Text text = Utils.getComponentUnderTest(PATH_TEXT_CUSTOMIZED, Text.class, context); - assertEquals("null", text.getDataRef()); + assertEquals("a.b", text.getDataRef()); Text textMock = Mockito.mock(Text.class); Mockito.when(textMock.getDataRef()).thenCallRealMethod(); assertEquals(null, textMock.getDataRef()); 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 895f1838db..0a4f38eebb 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 @@ -32,7 +32,6 @@ "name": "consenttext", "value": "Text related to the terms and conditions come here", "richText": false, - "dataRef": null, "events": { "custom:setProperty": [ "$event.payload" diff --git a/bundles/af-core/src/test/resources/form/text/exporter-text-customized.json b/bundles/af-core/src/test/resources/form/text/exporter-text-customized.json index fae110c7c3..6ef41425a1 100644 --- a/bundles/af-core/src/test/resources/form/text/exporter-text-customized.json +++ b/bundles/af-core/src/test/resources/form/text/exporter-text-customized.json @@ -1,6 +1,6 @@ { "id": "text-bb9fec86e7", - "dataRef": null, + "dataRef": "a.b", "fieldType": "plain-text", "name": "abc", "value": "

xyz

", 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 4f19844a24..143d36f683 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 @@ -1,7 +1,6 @@ { "id": "text-cfbea91bba", "fieldType": "plain-text", - "dataRef": null, "name": "text1680491190398", "value": "This is an AF", "richText": false, 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 d4eb57bb89..c1c6fc941b 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", - "dataRef": null, "richText": false, "name": "abc", ":type": "core/fd/components/form/text/v1/text", diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/clientlib-it-custom-function/js/functions.js b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/clientlib-it-custom-function/js/functions.js index 7deb535b47..4b85bed41a 100644 --- a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/clientlib-it-custom-function/js/functions.js +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/clientlib-it-custom-function/js/functions.js @@ -165,6 +165,16 @@ function testImportData(globals) globals.functions.importData(Object.fromEntries([['textinput_12605243111716188337417','abc']])); } +/** + * Tests static text import data + * @name testTextImportData + * @param {scope} globals + */ +function testTextImportData(globals) +{ + globals.functions.importData({'a' : {'b' : 'prefilled'}}); +} + /** * Tests set focus * @name testSetFocus diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/text/basic/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/text/basic/.content.xml index 976113d102..623531a3bc 100644 --- a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/text/basic/.content.xml +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/text/basic/.content.xml @@ -14,6 +14,9 @@ fd:version="2.1" jcr:primaryType="nt:unstructured" sling:resourceType="forms-components-examples/components/form/container" + clientLibRef="corecomponent.it.customfunction" + schemaType="none" + specVersion="0.14.2" fieldType="form"> + + + + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/text/v1/text/_cq_dialog/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/text/v1/text/_cq_dialog/.content.xml index 60f9260985..682a2de16b 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/text/v1/text/_cq_dialog/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/text/v1/text/_cq_dialog/.content.xml @@ -59,9 +59,6 @@ - @@ -71,9 +68,6 @@ - diff --git a/ui.tests/test-module/specs/text/text.authoring.cy.js b/ui.tests/test-module/specs/text/text.authoring.cy.js index fe48d744f0..67b0063ddb 100644 --- a/ui.tests/test-module/specs/text/text.authoring.cy.js +++ b/ui.tests/test-module/specs/text/text.authoring.cy.js @@ -54,13 +54,11 @@ describe('Page - Authoring', function () { cy.get("[name='./name']") .should("exist"); cy.get("[name='./dataRef']") - .should("not.exist"); + .should("exist"); cy.get("[name='./readOnly']") .should("not.exist"); cy.get("[name='./unboundFormElement']") - .should("not.exist"); - cy.get("[name='./dorBindRef']") - .should("not.exist"); + .should("exist"); cy.get('.cmp-adaptiveform-base__istitlerichtext').should('not.exist'); cy.get("[name='./visible'][type=\"checkbox\"]").should("exist").check(); diff --git a/ui.tests/test-module/specs/text/text.runtime.cy.js b/ui.tests/test-module/specs/text/text.runtime.cy.js index 5beff8d0ee..9d130618e0 100644 --- a/ui.tests/test-module/specs/text/text.runtime.cy.js +++ b/ui.tests/test-module/specs/text/text.runtime.cy.js @@ -56,7 +56,7 @@ }) - it(" should get model and view initialized properly ", () => { + it(" should get model and view initialized properly ", () => { expect(formContainer, "formcontainer is initialized").to.not.be.null; expect(formContainer._model.items.length, "model and view elements match").to.equal(Object.keys(formContainer._fields).length); Object.entries(formContainer._fields).forEach(([id, field]) => { @@ -65,7 +65,7 @@ }); }) - it(" html changes are reflected in model ", () => { + it(" html changes are reflected in model ", () => { const [id, fieldView] = Object.entries(formContainer._fields)[0] const model = formContainer._model.getElement(id) const input = "value" @@ -74,7 +74,7 @@ }) }); - it('test the rules editor', () => { + it('test the rules editor', () => { const [id, fieldView] = Object.entries(formContainer._fields)[1]; cy.get('.cmp-adaptiveform-textinput__widget') .type('Hide me'); @@ -105,4 +105,14 @@ }); }); + it(" prefill of static text using explicit dataRef, name bindings is not supported", () => { + const [id, fieldView] = Object.entries(formContainer._fields)[3]; + const [buttonId, buttonFieldView] = Object.entries(formContainer._fields)[5]; + const model = formContainer._model.getElement(id); + cy.get(`#${buttonId} button`).should("be.visible").click().then(() => { + expect(model.value, " Text model should import data").contains("prefilled"); + cy.get(`#${id}`).contains("prefilled"); + }); + }); + }) \ No newline at end of file