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 04d864596e..26002c8cf8 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 @@ -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); +} diff --git a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/ruleeditor/af2-custom-function/basic/.content.xml b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/ruleeditor/af2-custom-function/basic/.content.xml index b07276b417..fa6b38a888 100644 --- a/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/ruleeditor/af2-custom-function/basic/.content.xml +++ b/it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/ruleeditor/af2-custom-function/basic/.content.xml @@ -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"> + + + + + + diff --git a/ui.frontend/package-lock.json b/ui.frontend/package-lock.json index 964dbef627..2a1dbbe654 100644 --- a/ui.frontend/package-lock.json +++ b/ui.frontend/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "@aemforms/af-core": "^1.0.7", + "@aemforms/af-core": "^1.0.10", "@aemforms/af-core-xfa": "^0.1.6", "@aemforms/af-custom-functions": "1.0.18", "@aemforms/af-formatters": "^1.0.7", @@ -109,13 +109,13 @@ } }, "node_modules/@aemforms/af-core": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@aemforms/af-core/-/af-core-1.0.7.tgz", - "integrity": "sha512-hw6xDFlFwvRcySvmvqb5Xl9sHB6Q5Fz7POURfGFzSfxf+HFc2OkO7sk9mGwPKD22Og3lqC8jxnEr/uL47aa4pA==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@aemforms/af-core/-/af-core-1.0.10.tgz", + "integrity": "sha512-U9oPROwbzi3Uh5jKnHlISQApFT1tpQ/oLvfimOBsqrMtYmpvq2iHCh9JDqs6TO61WQhO2lHxOTkvhO8R2gsLHg==", "license": "Adobe Proprietary", "dependencies": { "@adobe/json-formula": "0.1.50", - "@aemforms/af-formatters": "^1.0.7" + "@aemforms/af-formatters": "^1.0.10" } }, "node_modules/@aemforms/af-core-xfa": { @@ -138,9 +138,9 @@ "integrity": "sha512-Hg7dkONjmR3aH/Iec+/HRY/lCzVvP3GI6H9wD5FNGsE9zSxPcCzMtnAA0P7n/RKMjcnqYBMt4pFQ6MVb+YvIGg==" }, "node_modules/@aemforms/af-formatters": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@aemforms/af-formatters/-/af-formatters-1.0.7.tgz", - "integrity": "sha512-2dEAOmYIH8FfYiiLzPSWqBDmdorrBFCzc+YsQ4JfDoZNH7qMPebnyujZsaFG3grhxUJcz8npMnKdPzDCqUjiqg==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@aemforms/af-formatters/-/af-formatters-1.0.10.tgz", + "integrity": "sha512-Q7IRSpGV8E6cR/hCBhWDyzXa2jYEl1yHWPep1rU24AqsbzWU0s+KtCoEkKln6l9t8G71czDg8+FJB21/yPhsvA==", "license": "Adobe Proprietary" }, "node_modules/@aemforms/af-webmcp": { @@ -11149,12 +11149,12 @@ "integrity": "sha512-dmlLYfbty8NPVIdxvI9cJ+ZdXsrRCFrCdmL1+aR2auEzXJ86rD0bm1qu+S4NOpFiZLKIyx0zvUTykms40vNjsA==" }, "@aemforms/af-core": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@aemforms/af-core/-/af-core-1.0.7.tgz", - "integrity": "sha512-hw6xDFlFwvRcySvmvqb5Xl9sHB6Q5Fz7POURfGFzSfxf+HFc2OkO7sk9mGwPKD22Og3lqC8jxnEr/uL47aa4pA==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@aemforms/af-core/-/af-core-1.0.10.tgz", + "integrity": "sha512-U9oPROwbzi3Uh5jKnHlISQApFT1tpQ/oLvfimOBsqrMtYmpvq2iHCh9JDqs6TO61WQhO2lHxOTkvhO8R2gsLHg==", "requires": { "@adobe/json-formula": "0.1.50", - "@aemforms/af-formatters": "^1.0.7" + "@aemforms/af-formatters": "^1.0.10" } }, "@aemforms/af-core-xfa": { @@ -11179,9 +11179,9 @@ "integrity": "sha512-Hg7dkONjmR3aH/Iec+/HRY/lCzVvP3GI6H9wD5FNGsE9zSxPcCzMtnAA0P7n/RKMjcnqYBMt4pFQ6MVb+YvIGg==" }, "@aemforms/af-formatters": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@aemforms/af-formatters/-/af-formatters-1.0.7.tgz", - "integrity": "sha512-2dEAOmYIH8FfYiiLzPSWqBDmdorrBFCzc+YsQ4JfDoZNH7qMPebnyujZsaFG3grhxUJcz8npMnKdPzDCqUjiqg==" + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@aemforms/af-formatters/-/af-formatters-1.0.10.tgz", + "integrity": "sha512-Q7IRSpGV8E6cR/hCBhWDyzXa2jYEl1yHWPep1rU24AqsbzWU0s+KtCoEkKln6l9t8G71czDg8+FJB21/yPhsvA==" }, "@aemforms/af-webmcp": { "version": "1.0.7", diff --git a/ui.frontend/package.json b/ui.frontend/package.json index dc896810c5..b1532b0786 100644 --- a/ui.frontend/package.json +++ b/ui.frontend/package.json @@ -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", diff --git a/ui.tests/test-module/specs/ruleeditor/runtime/customFunction.runtime.cy.js b/ui.tests/test-module/specs/ruleeditor/runtime/customFunction.runtime.cy.js index 0468fce5de..d919c9bc9a 100644 --- a/ui.tests/test-module/specs/ruleeditor/runtime/customFunction.runtime.cy.js +++ b/ui.tests/test-module/specs/ruleeditor/runtime/customFunction.runtime.cy.js @@ -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")) {