Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
jcr:primaryType="cq:Page">
jcr:primaryType="cq:Page">
<jcr:content
cq:deviceGroups="[mobile/groups/responsive]"
cq:lastModified="{Date}2023-01-09T16:01:24.451+05:30"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
jcr:language="en"
jcr:primaryType="cq:PageContent"
jcr:title="Adaptive Form V2 (IT)"
sling:resourceType="forms-components-examples/components/page">
cq:deviceGroups="[mobile/groups/responsive]"
cq:lastModified="{Date}2024-09-10T14:57:01.796+05:30"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
jcr:language="en"
jcr:primaryType="cq:PageContent"
jcr:title="Adaptive Form V2 (IT)"
sling:resourceType="forms-components-examples/components/page">
<guideContainer
fd:version="2.1"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/container"
dorType="none"
themeRef="/libs/fd/af/themes/canvas"
fieldType="form">
fd:version="2.1"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/container"
dorType="none"
fieldType="form"
themeRef="/libs/fd/af/themes/canvas">
<fragment
jcr:lastModified="{Date}2023-06-02T12:34:24.990+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Fragment"
sling:resourceType="forms-components-examples/components/form/fragment"
fieldType="panel"
fragmentPath="/content/forms/af/core-components-it/samples/fragment/test-fragment"
maxOccur="4"
minOccur="0"
name="fragment1685689465369"
repeatable="{Boolean}true"
wrapData="{Boolean}true"/>
<fragment1
jcr:lastModified="{Date}2023-06-02T12:34:24.990+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Fragment"
jcr:title="Fragment 1"
sling:resourceType="forms-components-examples/components/form/fragment"
fieldType="panel"
fragmentPath="/content/forms/af/core-components-it/samples/fragment/test-fragment"
repeatable="{Boolean}true"
maxOccur="4"
minOccur="0"
name="fragment1685689465369"
name="fragment16856894653691"
repeatable="{Boolean}true"
wrapData="{Boolean}true"/>
</guideContainer>
</jcr:content>
</jcr:root>
</jcr:root>
56 changes: 43 additions & 13 deletions .../jcr_root/content/forms/af/core-components-it/samples/fragment/test-fragment/.content.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
jcr:primaryType="cq:Page">
<jcr:content
cq:deviceGroups="[/etc/mobile/groups/responsive]"
cq:lastModified="{Date}2023-06-02T12:27:19.297+05:30"
cq:lastModified="{Date}2024-09-10T15:11:58.094+05:30"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
jcr:language="en"
Expand All @@ -12,15 +12,15 @@
sling:configRef="/conf/forms/core-components-it/af-v2-test/"
sling:resourceType="forms-components-examples/components/page">
<guideContainer
fd:version="2.1"
fd:type="fragment"
fd:version="2.1"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/fragmentcontainer"
clientLibRef="x.y"
dorType="none"
fieldType="form"
thankYouOption="page"
themeRef="/libs/fd/af/themes/canvas"
clientLibRef="x.y"
title="AF Fragment (v2)">
<textinput
jcr:lastModified="{Date}2023-06-02T12:27:19.294+05:30"
Expand All @@ -31,20 +31,50 @@
fieldType="text-input"
name="fragmenttextinput"/>
<textinput1
jcr:created="{Date}2024-05-08T20:17:24.203+05:30"
jcr:lastModified="{Date}2024-05-08T20:17:24.203+05:30"
jcr:primaryType="nt:unstructured"
jcr:title="Responsive Text Input"
sling:resourceType="forms-components-examples/components/form/textinput"
fieldType="text-input"
name="textinput1715179644273">
jcr:created="{Date}2024-05-08T20:17:24.203+05:30"
jcr:lastModified="{Date}2024-05-08T20:17:24.203+05:30"
jcr:primaryType="nt:unstructured"
jcr:title="Responsive Text Input"
sling:resourceType="forms-components-examples/components/form/textinput"
fieldType="text-input"
name="textinput1715179644273">
<cq:responsive jcr:primaryType="nt:unstructured">
<default
jcr:primaryType="nt:unstructured"
offset="1"
width="9"/>
jcr:primaryType="nt:unstructured"
offset="1"
width="9"/>
</cq:responsive>
<fd:rules
fd:calc="[{&quot;nodeName&quot;:&quot;ROOT&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;CALC_EXPRESSION&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;VALUE_FIELD&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.textinput1715179644273&quot;\,&quot;type&quot;:&quot;STRING&quot;\,&quot;name&quot;:&quot;textinput1715179644273&quot;}}\,{&quot;nodeName&quot;:&quot;to&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;EXPRESSION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;COMPONENT&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.fragmenttextinput&quot;\,&quot;displayName&quot;:&quot;Text Input&quot;\,&quot;type&quot;:&quot;STRING&quot;\,&quot;displayPath&quot;:&quot;FORM/Text Input/&quot;\,&quot;name&quot;:&quot;fragmenttextinput&quot;\,&quot;parent&quot;:&quot;$form&quot;}}}\,{&quot;nodeName&quot;:&quot;When&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;CONDITIONORALWAYS&quot;\,&quot;choice&quot;:null}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:&quot;fragmenttextinput.$value&quot;\,&quot;eventName&quot;:&quot;Calculate&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
fd:valueCommit="[{&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.textinput1715179644273&quot;\,&quot;type&quot;:&quot;STRING&quot;\,&quot;name&quot;:&quot;textinput1715179644273&quot;}}\,{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON_OPERATOR&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;is changed&quot;\,&quot;value&quot;:null}}\,{&quot;nodeName&quot;:&quot;PRIMITIVE_EXPRESSION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;STRING_LITERAL&quot;\,&quot;value&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;SET_VALUE_STATEMENT&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;VALUE_FIELD&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.panelcontainer1725960550534.text1725960554387&quot;\,&quot;displayName&quot;:&quot;text1725960554387&quot;\,&quot;type&quot;:&quot;STRING&quot;\,&quot;displayPath&quot;:&quot;FORM/Panel/text1725960554387/&quot;\,&quot;name&quot;:&quot;text1725960554387&quot;\,&quot;parent&quot;:&quot;$form.panelcontainer1725960550534&quot;}}\,{&quot;nodeName&quot;:&quot;to&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;EXPRESSION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;STRING_LITERAL&quot;\,&quot;value&quot;:&quot;Thanks&quot;}}]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;dispatchEvent($form.panelcontainer1725960550534.text1725960554387\, 'custom:setProperty'\, {value : 'Thanks'})&quot;]\,&quot;eventName&quot;:&quot;Value Commit&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
jcr:primaryType="nt:unstructured"
validationStatus="valid"
value="fragmenttextinput.$value"/>
<fd:events
jcr:primaryType="nt:unstructured"
change="[if(contains($event.payload.changes[].propertyName\, 'value')\, dispatchEvent($form.panelcontainer1725960550534.text1725960554387\, 'custom:setProperty'\, {value : 'Thanks'})\, {})]"/>
</textinput1>
<panelcontainer
jcr:created="{Date}2024-09-10T14:59:10.484+05:30"
jcr:createdBy="admin"
jcr:lastModified="{Date}2024-09-10T14:59:10.484+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Panel"
sling:resourceType="forms-components-examples/components/form/panelcontainer"
fieldType="panel"
name="panelcontainer1725960550534">
<text
jcr:created="{Date}2024-09-10T14:59:14.338+05:30"
jcr:createdBy="admin"
jcr:lastModified="{Date}2024-09-10T14:59:14.338+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Text"
sling:resourceType="forms-components-examples/components/form/text"
fieldType="plain-text"
name="text1725960554387"/>
</panelcontainer>
</guideContainer>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@
updateValue(value) {
// html sets undefined value as undefined string in input value, hence this check is added
let actualValue = typeof value === "undefined" ? "" : value;

const sanitizedValue = window.DOMPurify ? window.DOMPurify.sanitize(actualValue) : actualValue;
// since there is no widget for textview, the innerHTML is being changed
this.element.children[0].innerHTML = actualValue;
if (this.element.children[0]) {
this.element.children[0].innerHTML = sanitizedValue;
} else {
this.element.innerHTML = sanitizedValue;
}
}
}

Expand Down
32 changes: 16 additions & 16 deletions ui.frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ui.frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@aemforms/af-core": "^0.22.102",
"@aemforms/af-formatters": "^0.22.102",
"@aemforms/af-core": "^0.22.103",
"@aemforms/af-formatters": "^0.22.103",
"@aemforms/af-custom-functions": "1.0.10"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("Sites with Aem Embed Container", () => {
it("model initialized properly", () => {
expect(formContainer, "formcontainer is initialized").to.not.be.null;
// fragment component, text field and IntanceManager
expect(Object.keys(formContainer._fields).length).to.equal(4);
expect(Object.keys(formContainer._fields).length).to.be.gt(4);
})

it("model's changes are reflected in the html ", () => {
Expand Down
31 changes: 31 additions & 0 deletions ui.tests/test-module/specs/fragment/fragment.runtime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,35 @@ describe("Form Runtime with Fragment", () => {
});
});
});


it("rules inside fragment should work when included in form", () => {
const [idTextBox, fieldView] = Object.entries(formContainer._fields)[0];
const [idTextBox1, fieldView1] = Object.entries(formContainer._fields)[1];
const [idPanel, panelView] = Object.entries(formContainer._fields)[4];
const input = "abc";
const model = formContainer._model.getElement(idPanel);
cy.get(`#${idTextBox}`).find("input").clear().type(input).blur().then(x => {
cy.get(`#${idTextBox1} input`).invoke('val').then(val => {
expect(val, "rules inside fragment (when included in form) did not work").to.equal(input);
})
})

cy.get(`#${model.items[0].id}`).should('have.text', 'Thanks');
});

it("same fragment referred twice should have unique ids", () => {
const [idTextBox, fieldView] = Object.entries(formContainer._fields)[2];
const [idTextBox1, fieldView1] = Object.entries(formContainer._fields)[3];
const [idPanel, panelView] = Object.entries(formContainer._fields)[5];
const input = "abc";
const model = formContainer._model.getElement(idPanel);
cy.get(`#${idTextBox}`).find("input").clear().type(input).blur().then(x => {
cy.get(`#${idTextBox1} input`).invoke('val').then(val => {
expect(val, "rules inside fragment (when included in form) did not work").to.equal(input);
})
})

cy.get(`#${model.items[0].id}`).should('have.text', 'Thanks');
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add a test case where the same fragment is added multiple times (need to check if core components provide new id to the fields)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Added the same

})