Skip to content

Commit 67c19ad

Browse files
im-shivShivam Agarwal
andauthored
FORMS-17091 initializing label in button view (#1471)
Co-authored-by: Shivam Agarwal <shivama@adobe.com>
1 parent 7c29f5d commit 67c19ad

File tree

3 files changed

+27
-1
lines changed
  • it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/button/buttonv1/basic
  • ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/button/v1/button/clientlibs/site/js
  • ui.tests/test-module/specs/button

3 files changed

+27
-1
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@
7676
jcr:primaryType="nt:unstructured"
7777
click="[navigateTo('https://www.google.com'\, '_newwindow')]"/>
7878
</button-5>
79+
<button-6
80+
jcr:lastModified="{Date}2024-11-05T11:18:53.340+05:30"
81+
jcr:lastModifiedBy="admin"
82+
jcr:primaryType="nt:unstructured"
83+
jcr:title="change me"
84+
sling:resourceType="core/fd/components/form/button/v1/button"
85+
dorExclusion="true"
86+
enabled="{Boolean}true"
87+
fieldType="button"
88+
name="button1730785718091"
89+
visible="{Boolean}true">
90+
<fd:rules
91+
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.button1730785718091&quot;\,&quot;type&quot;:&quot;AFCOMPONENT|FIELD|BUTTON&quot;\,&quot;name&quot;:&quot;button1730785718091&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;SET_PROPERTY&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;MEMBER_EXPRESSION&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;PROPERTY_LIST&quot;\,&quot;value&quot;:&quot;label.value&quot;}\,{&quot;nodeName&quot;:&quot;of&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;COMPONENT&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.button1730785718091&quot;\,&quot;displayName&quot;:&quot;change me&quot;\,&quot;type&quot;:&quot;AFCOMPONENT|FIELD|BUTTON&quot;\,&quot;displayPath&quot;:&quot;FORM/change me/&quot;\,&quot;name&quot;:&quot;button1730785718091&quot;\,&quot;parent&quot;:&quot;$form&quot;\,&quot;metadata&quot;:{&quot;isAncestorRepeatable&quot;:false}}}]}\,{&quot;nodeName&quot;:&quot;to&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;EXTENDED_EXPRESSION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;STRING_LITERAL&quot;\,&quot;value&quot;:&quot;changed&quot;}}]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;{label : {value : 'changed'}}&quot;]\,&quot;eventName&quot;:&quot;Click&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
92+
jcr:primaryType="nt:unstructured"
93+
validationStatus="valid"/>
94+
<fd:events
95+
jcr:primaryType="nt:unstructured"
96+
click="[{label : {value : 'changed'}}]"/>
97+
</button-6>
7998
</guideContainer>
8099
</jcr:content>
81100
</jcr:root>

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/button/v1/button/clientlibs/site/js/buttonview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
static selectors = {
3131
self: "[data-" + this.NS + '-is="' + this.IS + '"]',
3232
widget: `.${Button.bemBlock}__widget`,
33+
label: `.${Button.bemBlock}__text`,
3334
description: `.${Button.bemBlock}__longdescription`,
3435
qm: `.${Button.bemBlock}__questionmark`,
3536
tooltipDiv: `.${Button.bemBlock}__shortdescription`
@@ -40,7 +41,7 @@
4041
}
4142

4243
getLabel() {
43-
return null;
44+
return this.element.querySelector(Button.selectors.label);
4445
}
4546

4647
getWidget() {

ui.tests/test-module/specs/button/button.runtime.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,10 @@ describe("Form Runtime with Button Input", () => {
108108
cy.get('.cmp-adaptiveform-button__widget').eq(0).should('have.attr', 'type', 'button');
109109
});
110110

111+
it(`label changes should reflect via rules`, () => {
112+
const [id] = Object.entries(formContainer._fields)[5];
113+
cy.get(`#${id}`).find('.cmp-adaptiveform-button__text').contains('change me');
114+
cy.get(`#${id}`).find('.cmp-adaptiveform-button__widget').click();
115+
cy.get(`#${id}`).find('.cmp-adaptiveform-button__text').contains('changed');
116+
});
111117
})

0 commit comments

Comments
 (0)