Skip to content

Commit 465ed81

Browse files
s1mahantyci-build
authored andcommitted
FORMS-13810: Add the field to allow custom message for format in date… (#1158)
* FORMS-13810: Add the field to allow custom message for format in date picker * FORMS-13810: Test case added * FORMS-13810: Review comments incorporated.
1 parent 404540d commit 465ed81

File tree

4 files changed

+28
-6
lines changed
  • it/content/src/main/content/jcr_root/content
    • dam/formsanddocuments/core-components-it/samples/datepicker/basic
    • forms/af/core-components-it/samples/datepicker/basic
  • ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/_cq_dialog
  • ui.tests/test-module/specs/datepicker

4 files changed

+28
-6
lines changed

it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/datepicker/basic/.content.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
33
jcr:primaryType="dam:Asset">
44
<jcr:content
5-
jcr:lastModified="{Date}2023-01-20T15:28:03.292+05:30"
5+
jcr:lastModified="{Date}2024-04-03T17:09:20.123+05:30"
66
jcr:primaryType="dam:AssetContent"
77
sling:resourceType="fd/fm/af/render"
88
guide="1"
99
type="guide">
1010
<metadata
1111
fd:version="2.1"
12-
themeRef="/libs/fd/af/themes/canvas"
1312
jcr:primaryType="nt:unstructured"
1413
allowedRenderFormat="HTML"
1514
author="admin"
1615
availableInMobileApp="{Boolean}false"
16+
dorTemplateChanged="Boolean"
1717
dorType="none"
1818
formmodel="none"
1919
hasCustomThumbnail="{Boolean}false"
20+
themeRef="/libs/fd/af/themes/canvas"
2021
title="Adaptive Form V2 (IT)"/>
2122
</jcr:content>
2223
</jcr:root>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
jcr:primaryType="cq:Page">
44
<jcr:content
55
cq:deviceGroups="[mobile/groups/responsive]"
6-
cq:lastModified="{Date}2024-03-18T15:08:02.397+05:30"
6+
cq:lastModified="{Date}2024-04-03T17:09:19.976+05:30"
77
cq:lastModifiedBy="admin"
88
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
99
jcr:language="en"
@@ -17,13 +17,14 @@
1717
jcr:lastModifiedBy="admin"
1818
jcr:primaryType="nt:unstructured"
1919
sling:resourceType="forms-components-examples/components/form/container"
20-
themeRef="/libs/fd/af/themes/canvas"
2120
clientLibRef="corecomponent.it.customfunction"
21+
dorType="none"
2222
fieldType="form"
2323
schemaType="none"
2424
textIsRich="true"
2525
thankYouMessage="Thank you for submitting the form."
26-
thankYouOption="page">
26+
thankYouOption="page"
27+
themeRef="/libs/fd/af/themes/canvas">
2728
<dateinput1
2829
jcr:primaryType="nt:unstructured"
2930
jcr:title="Date Input 1"
@@ -103,7 +104,7 @@
103104
<datepicker
104105
jcr:created="{Date}2023-08-10T15:45:30.311+05:30"
105106
jcr:createdBy="admin"
106-
jcr:lastModified="{Date}2023-08-10T15:47:00.344+05:30"
107+
jcr:lastModified="{Date}2024-04-03T17:07:16.009+05:30"
107108
jcr:lastModifiedBy="admin"
108109
jcr:primaryType="nt:unstructured"
109110
jcr:title="Date Picker with edit and display formats"
@@ -114,6 +115,7 @@
114115
editPatternType="d/M/y"
115116
enabled="{Boolean}true"
116117
fieldType="date-input"
118+
formatMessage="Date format expected is d/M/y"
117119
hideTitle="false"
118120
name="datepicker7"
119121
readOnly="{Boolean}false"

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@
215215
fieldLabel="Edit Format"
216216
name="./editFormat">
217217
</editFormat>
218+
<formatMessage
219+
jcr:primaryType="nt:unstructured"
220+
sling:resourceType="granite/ui/components/coral/foundation/form/textarea"
221+
fieldDescription="Error message shown when the date format is incorrect."
222+
granite:class="cmp-adaptiveform-datepicker__formatmessage"
223+
fieldLabel="Format error message"
224+
name="./formatMessage"/>
218225
</items>
219226
</editPatternGroup>
220227
</items>

ui.tests/test-module/specs/datepicker/datepicker.runtime.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,16 @@ describe("Form Runtime with Date Picker", () => {
256256
}
257257
});
258258

259+
it.only("Test custom error message when incorrect date format is entered", () => {
260+
const [datePicker7, datePicker7FieldView] = Object.entries(formContainer._fields)[6];
261+
const incorrectInputs = ["adfasdfa", "29/2/2023", "32/1/2023", "1/32/23", "1-1-2023"];
262+
incorrectInputs.forEach(incorrectInput => {
263+
cy.get(`#${datePicker7}`).find("input").should('have.attr',"type", "text");
264+
cy.get(`#${datePicker7}`).find("input").clear().wait(1000).type(incorrectInput).trigger('input').blur()
265+
.then(x => {
266+
cy.get(`#${datePicker7}`).find("input").should('have.value', incorrectInput); // Check if the input is the same
267+
cy.get(`#${datePicker7}`).find(".cmp-adaptiveform-datepicker__errormessage").should('have.text',"Date format expected is d/M/y")
268+
});
269+
});
270+
});
259271
})

0 commit comments

Comments
 (0)