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
Expand Up @@ -329,3 +329,12 @@ function removePanelInstance(panel,globals)
globals.functions.dispatchEvent(p, 'initialize');
})
}

/**
* Hides a field's parent section using legacy private model access.
* @name hideParentSectionUsingPrivateModel
* @param {object} hideSom field in the section to hide
*/
function hideParentSectionUsingPrivateModel(hideSom) {
hideSom._options.parent._setProperty('visible', false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
jcr:language="en"
jcr:primaryType="cq:PageContent"
jcr:title="Adaptive Form V2 (IT)"
sling:resourceType="forms-components-examples/components/page">
sling:resourceType="forms-core-components-it/components/page">
<guideContainer
fd:version="2.1"
jcr:primaryType="nt:unstructured"
Expand Down Expand Up @@ -266,6 +266,30 @@
jcr:primaryType="nt:unstructured"
click="[testRemoveInstance()]"/>
</button_476277589>
<legacyAddressSection
jcr:primaryType="nt:unstructured"
jcr:title="Legacy Address Section"
sling:resourceType="forms-components-examples/components/form/panelcontainer"
fieldType="panel"
name="legacyAddressSection"
visible="{Boolean}true">
<streetNumber
jcr:primaryType="nt:unstructured"
jcr:title="Street Number"
sling:resourceType="forms-components-examples/components/form/textinput"
fieldType="text-input"
name="streetNumber"/>
</legacyAddressSection>
<hideLegacyAddressSection
jcr:primaryType="nt:unstructured"
jcr:title="Hide Legacy Address Section"
sling:resourceType="forms-components-examples/components/form/button"
fieldType="button"
name="hideLegacyAddressSection">
<fd:events
jcr:primaryType="nt:unstructured"
click="[hideParentSectionUsingPrivateModel(legacyAddressSection.streetNumber)]"/>
</hideLegacyAddressSection>
</guideContainer>
</jcr:content>
</jcr:root>
30 changes: 15 additions & 15 deletions ui.frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion ui.frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@aemforms/af-core": "^1.0.7",
"@aemforms/af-core": "^1.0.10",
"@aemforms/af-core-xfa": "^0.1.6",
"@aemforms/af-formatters": "^1.0.7",
"@aemforms/af-custom-functions": "1.0.18",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,24 @@ describe('Form with custom functions configured in client lib', () => {
it("should have set textinput value based on custom function rule", () => {
// Rule on textBox1: set value of textBox1 to "test", which is output of custom function testFunction1()
expect(formContainer, "formcontainer is initialized").to.not.be.null;
const [textbox1, textBox1FieldView] = Object.entries(formContainer._fields)[0];
cy.get(`#${textbox1}`).find("input").should('have.value', "test")
cy.get('input[name="textinput1"]').should('have.value', "test")
})

it('should hide the parent section using private field model access in a custom function', () => {
expect(formContainer, 'formcontainer is initialized').to.not.be.null;
const section = Object.values(formContainer._fields)
.find(field => field.getModel().name === 'legacyAddressSection');
expect(section, 'legacy address section is initialized').to.not.be.undefined;
const sectionModel = section.getModel();

cy.get(`#${sectionModel.id}`).should('be.visible');
cy.get('input[name="streetNumber"]').should('be.visible');
cy.contains('button', 'Hide Legacy Address Section').click();

cy.wrap(sectionModel).its('visible').should('equal', false);
cy.get(`#${sectionModel.id}`).should('not.be.visible');
});


it("should submit custom formData on button click", () => {
if (cy.af.isLatestAddon() && toggle_array.includes("FT_FORMS-11541")) {
Expand Down
Loading