Skip to content

Commit 9b29d2f

Browse files
authored
Merge pull request #1514 from adobe/devMaster27Jan
Dev master27 jan
2 parents b3dc75e + 51fe1cb commit 9b29d2f

File tree

10 files changed

+115
-53
lines changed

10 files changed

+115
-53
lines changed

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/StaticImageImpl.java

-5
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ public String getAltText() {
110110
return translate("altText", altText);
111111
}
112112

113-
@Override
114-
public String getDataRef() {
115-
return null;
116-
}
117-
118113
@Override
119114
@JsonIgnore
120115
public String getDescription() {

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/StaticImageImplTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void testGetName() {
9595
@Test
9696
void testGetDataRef() {
9797
StaticImage staticImage = Utils.getComponentUnderTest(PATH_IMAGE_CUSTOMIZED, StaticImage.class, context);
98-
assertEquals(null, staticImage.getDataRef());
98+
assertEquals("a.b", staticImage.getDataRef());
9999
StaticImage staticImageMock = Mockito.mock(StaticImage.class);
100100
Mockito.when(staticImageMock.getDataRef()).thenCallRealMethod();
101101
assertEquals(null, staticImageMock.getDataRef());

bundles/af-core/src/test/resources/form/image/exporter-image-customized.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"id": "image-ad1e095fba",
3+
"dataRef" : "a.b",
34
"fieldType": "image",
45
"name": "abc",
56
"value": "/content/image-customized.img.png",

bundles/af-core/src/test/resources/form/image/test-content.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"jcr:title" : "def",
1919
"hideTitle" : false,
2020
"visible" : false,
21+
"dataRef" : "a.b",
2122
"altText": "abc",
2223
"file": {
2324
"jcr:content": {

it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/clientlib-it-custom-function/js/functions.js

+10
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ function testTextImportData(globals)
175175
globals.functions.importData({'a' : {'b' : 'prefilled'}});
176176
}
177177

178+
/**
179+
* Tests static image import data
180+
* @name testImageImportData
181+
* @param {scope} globals
182+
*/
183+
function testImageImportData(globals)
184+
{
185+
globals.functions.importData({'a' : {'b' : '/content/dam/reference-fragments/visa%402x.png'}})
186+
}
187+
178188
/**
179189
* Tests set focus
180190
* @name testSetFocus
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,82 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
3-
xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
4-
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
5-
jcr:primaryType="cq:Page">
6-
<jcr:content
7-
cq:deviceGroups="[mobile/groups/responsive]"
8-
cq:lastModified="{Date}2021-12-02T15:12:59.900+05:30"
9-
cq:lastModifiedBy="admin"
10-
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
11-
jcr:language="en"
12-
jcr:primaryType="cq:PageContent"
13-
jcr:title="Adaptive Form V2 (IT)"
14-
sling:resourceType="forms-components-examples/components/page">
15-
<guideContainer
16-
fd:version="2.1"
17-
fieldType="form"
18-
jcr:primaryType="nt:unstructured"
19-
sling:resourceType="forms-components-examples/components/form/container">
20-
<textinput
21-
fieldType="text-input"
22-
jcr:primaryType="nt:unstructured"
23-
name="textinput1"
24-
jcr:title="Text Input 1"
25-
sling:resourceType="forms-components-examples/components/form/textinput"/>
26-
<image
27-
jcr:created="{Date}2022-10-13T14:31:23.772+05:30"
28-
jcr:createdBy="admin"
29-
jcr:lastModified="{Date}2022-10-13T14:31:23.772+05:30"
30-
jcr:lastModifiedBy="admin"
31-
jcr:primaryType="nt:unstructured"
32-
jcr:title="Image"
33-
sling:resourceType="forms-components-examples/components/form/image"
34-
fieldType="image"
35-
name="image1665651689720">
36-
<fd:rules
37-
jcr:primaryType="nt:unstructured"
38-
visible="!(textinput1 == 'Hide me') || textinput1 == 'Show me'"/>
39-
<fd:events jcr:primaryType="nt:unstructured"/>
40-
</image>
41-
42-
</guideContainer>
43-
</jcr:content>
44-
</jcr:root>
2+
<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:fd="http://www.adobe.com/aemfd/fd/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
3+
jcr:primaryType="cq:Page">
4+
<jcr:content
5+
cq:deviceGroups="[mobile/groups/responsive]"
6+
cq:lastModified="{Date}2025-01-23T19:42:45.919+05:30"
7+
cq:lastModifiedBy="admin"
8+
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
9+
fd:ignoreTranslationInvalidation="{Boolean}true"
10+
jcr:language="en"
11+
jcr:primaryType="cq:PageContent"
12+
jcr:title="Adaptive Form V2 (IT)"
13+
sling:resourceType="forms-components-examples/components/page">
14+
<guideContainer
15+
fd:version="2.1"
16+
jcr:lastModified="{Date}2025-01-23T19:40:52.901+05:30"
17+
jcr:lastModifiedBy="admin"
18+
jcr:primaryType="nt:unstructured"
19+
sling:resourceType="forms-components-examples/components/form/container"
20+
clientLibRef="corecomponent.it.customfunction"
21+
fieldType="form"
22+
schemaType="none"
23+
specVersion="0.14.2"
24+
textIsRich="true"
25+
thankYouMessage="&lt;p>Thank you for submitting the form.&lt;/p>&#xd;&#xa;"
26+
thankYouOption="page">
27+
<textinput
28+
jcr:primaryType="nt:unstructured"
29+
jcr:title="Text Input 1"
30+
sling:resourceType="forms-components-examples/components/form/textinput"
31+
fieldType="text-input"
32+
name="textinput1"/>
33+
<image
34+
jcr:created="{Date}2022-10-13T14:31:23.772+05:30"
35+
jcr:createdBy="admin"
36+
jcr:lastModified="{Date}2022-10-13T14:31:23.772+05:30"
37+
jcr:lastModifiedBy="admin"
38+
jcr:primaryType="nt:unstructured"
39+
jcr:title="Image"
40+
sling:resourceType="forms-components-examples/components/form/image"
41+
fieldType="image"
42+
name="image1665651689720">
43+
<fd:rules
44+
jcr:primaryType="nt:unstructured"
45+
visible="!(textinput1 == 'Hide me') || textinput1 == 'Show me'"/>
46+
<fd:events jcr:primaryType="nt:unstructured"/>
47+
</image>
48+
<image_1118656190
49+
jcr:created="{Date}2025-01-23T19:41:02.563+05:30"
50+
jcr:createdBy="admin"
51+
jcr:lastModified="{Date}2025-01-23T19:42:29.946+05:30"
52+
jcr:lastModifiedBy="admin"
53+
jcr:primaryType="nt:unstructured"
54+
jcr:title="Image"
55+
sling:resourceType="forms-components-examples/components/form/image"
56+
dataRef="$.a.b"
57+
fieldType="image"
58+
fileReference="/content/dam/reference-fragments/[email protected]"
59+
name="image_11186561901737641462594"
60+
visible="{Boolean}true"/>
61+
<button
62+
jcr:created="{Date}2025-01-23T19:41:38.650+05:30"
63+
jcr:createdBy="admin"
64+
jcr:lastModified="{Date}2025-01-23T19:41:38.650+05:30"
65+
jcr:lastModifiedBy="admin"
66+
jcr:primaryType="nt:unstructured"
67+
jcr:title="Button"
68+
sling:resourceType="forms-components-examples/components/form/button"
69+
dorExclusion="true"
70+
fieldType="button"
71+
name="button1737641498676">
72+
<fd:rules
73+
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.button1737641498676&quot;\,&quot;type&quot;:&quot;BUTTON&quot;\,&quot;name&quot;:&quot;button1737641498676&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;FUNCTION_CALL&quot;\,&quot;parentNodeName&quot;:&quot;BLOCK_STATEMENT&quot;\,&quot;functionName&quot;:{&quot;id&quot;:&quot;testImageImportData&quot;\,&quot;displayName&quot;:&quot;testImageImportData&quot;\,&quot;type&quot;:&quot;STRING|NUMBER|BOOLEAN|DATE|ARRAY|OBJECT&quot;\,&quot;isDuplicate&quot;:false\,&quot;displayPath&quot;:&quot;&quot;\,&quot;args&quot;:[]\,&quot;impl&quot;:&quot;$0()&quot;}\,&quot;params&quot;:[]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;testImageImportData()&quot;]\,&quot;eventName&quot;:&quot;Click&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
74+
jcr:primaryType="nt:unstructured"
75+
validationStatus="valid"/>
76+
<fd:events
77+
jcr:primaryType="nt:unstructured"
78+
click="[testImageImportData()]"/>
79+
</button>
80+
</guideContainer>
81+
</jcr:content>
82+
</jcr:root>

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/image/v1/image/_cq_dialog/.content.xml

-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
<placeholder
4545
jcr:primaryType="nt:unstructured"
4646
sling:hideResource="{Boolean}true"/>
47-
<bindref
48-
jcr:primaryType="nt:unstructured"
49-
sling:hideResource="{Boolean}true"/>
5047
<description
5148
jcr:primaryType="nt:unstructured"
5249
sling:orderBefore="visible"

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

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
setFocus() {
6262
this.setActive();
6363
}
64+
65+
updateValue(value) {
66+
if (this.element) {
67+
this.element.setAttribute('data-cmp-src', value);
68+
const imgElement = this.element.querySelector('img');
69+
if (imgElement) {
70+
imgElement.setAttribute('src', value);
71+
}
72+
}
73+
}
6474
}
6575

6676
FormView.Utils.setupField(({element, formContainer}) => {

ui.tests/test-module/specs/image/image.authoring.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('Page - Authoring', function () {
5858
cy.get("[name='./name']")
5959
.should("exist");
6060
cy.get("[name='./dataRef']")
61-
.should("not.exist");
61+
.should("exist");
6262
cy.get("[name='./readOnly']")
6363
.should("not.exist");
6464
cy.get("[name='./unboundFormElement']")

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

+10
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,14 @@
9191

9292
})
9393

94+
it("prefill test", () => {
95+
const [id, fieldView] = Object.entries(formContainer._fields)[3];
96+
const [buttonId, buttonFieldView] = Object.entries(formContainer._fields)[1];
97+
const model = formContainer._model.getElement(id);
98+
cy.get(`#${buttonId}-widget`).should("be.visible").click().then(() => {
99+
expect(model.value).contains("/content/dam/reference-fragments/visa%402x.png");
100+
cy.get(`#${id}`).find('img.cmp-image__image').should('have.attr', 'src', '/content/dam/reference-fragments/visa%402x.png');
101+
})
102+
})
103+
94104
})

0 commit comments

Comments
 (0)