Skip to content

Commit 4ca6b4e

Browse files
im-shivShivam Agarwal
authored andcommitted
FORMS-18328 default date localization changes (#1722)
* FORMS-18328 default date localization changes * FORMS-18328 updating comment message --------- Co-authored-by: Shivam Agarwal <[email protected]>
1 parent d65b295 commit 4ca6b4e

File tree

2 files changed

+26
-4
lines changed
  • ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker

2 files changed

+26
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
<items jcr:primaryType="nt:unstructured">
5050
<default
5151
jcr:primaryType="nt:unstructured"
52+
wrapperClass="cmp-adaptiveform-datepicker__defaultdate"
5253
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
5354
fieldDescription="Please enter the date in the required format &quot;yyyy-mm-dd&quot;."
5455
fieldLabel="Default date"
55-
emptyText="YYYY-MM-DD"
5656
name="./default"/>
5757
</items>
5858
</column>
@@ -80,9 +80,9 @@
8080
<minimum
8181
jcr:primaryType="nt:unstructured"
8282
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
83+
wrapperClass="cmp-adaptiveform-datepicker__mindate"
8384
fieldDescription="Please enter the date in the required format &quot;yyyy-mm-dd&quot;."
8485
fieldLabel="Minimum date"
85-
emptyText="YYYY-MM-DD"
8686
name="./minimumDate"
8787
valueFormat="YYYY-MM-DD[T]HH:mm:ss.000-00:00"/> <!-- Enforce UTC timezone to be timezone agnostic -->
8888
<minimumMessage
@@ -108,9 +108,9 @@
108108
<maximum
109109
jcr:primaryType="nt:unstructured"
110110
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
111+
wrapperClass="cmp-adaptiveform-datepicker__maxdate"
111112
fieldDescription="Please enter the date in the required format &quot;yyyy-mm-dd&quot;."
112113
fieldLabel="Maximum date"
113-
emptyText="YYYY-MM-DD"
114114
name="./maximumDate"
115115
valueFormat="YYYY-MM-DD[T]HH:mm:ss.000-00:00"/> <!-- Enforce UTC timezone to be timezone agnostic -->
116116
<maximumMessage

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/editor/js/editDialog.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
DATEPICKER_EDITFORMAT = EDIT_DIALOG + " .cmp-adaptiveform-datepicker__editformat",
2424
DATEPICKER_LANG = EDIT_DIALOG + " .cmp-adaptiveform-datepicker__lang",
2525
DATEPICKER_LANGDISPLAYVALUE = EDIT_DIALOG + " .cmp-adaptiveform-datepicker__langdisplayvalue",
26+
DATEPICKER_DEFAULTDATE = EDIT_DIALOG + " .cmp-adaptiveform-datepicker__defaultdate",
27+
DATEPICKER_MINDATE = EDIT_DIALOG + " .cmp-adaptiveform-datepicker__mindate",
28+
DATEPICKER_MAXDATE = EDIT_DIALOG + " .cmp-adaptiveform-datepicker__maxdate",
2629
Utils = window.CQ.FormsCoreComponents.Utils.v1;
2730

2831

@@ -47,5 +50,24 @@
4750
Utils.handlePatternFormat(dialog,DATEPICKER_LANGDISPLAYVALUE,DATEPICKER_LANG);
4851
}
4952

50-
Utils.initializeEditDialog(EDIT_DIALOG)(handleDisplayPatternDropDown,handleDisplayFormat,handleEditPatternDropDown,handleEditFormat,handleLang);
53+
function handleDatePlaceholders(dialog){
54+
var defaultDateInput = dialog.find(DATEPICKER_DEFAULTDATE + " input")[0],
55+
minDateInput = dialog.find(DATEPICKER_MINDATE + " coral-datepicker")[0],
56+
maxDateInput = dialog.find(DATEPICKER_MAXDATE + " coral-datepicker")[0],
57+
defaultDateTooltip = dialog.find(DATEPICKER_DEFAULTDATE + " coral-tooltip")[0],
58+
minDateTooltip = dialog.find(DATEPICKER_MINDATE + " coral-tooltip")[0],
59+
maxDateTooltip = dialog.find(DATEPICKER_MAXDATE + " coral-tooltip")[0],
60+
emptyText = Granite.I18n.get('YYYY-MM-DD', null, 'placeholder text to retain format across locale'),
61+
fieldDescription = Granite.I18n.get('Please enter the date in the required format "yyyy-mm-dd".', null, 'placeholder text to retain format across locale');
62+
63+
defaultDateInput.placeholder = emptyText;
64+
defaultDateInput.setAttribute('aria-label', emptyText);
65+
minDateInput.placeholder = emptyText;
66+
maxDateInput.placeholder = emptyText;
67+
defaultDateTooltip.innerHTML = fieldDescription;
68+
minDateTooltip.innerHTML = fieldDescription;
69+
maxDateTooltip.innerHTML = fieldDescription;
70+
}
71+
72+
Utils.initializeEditDialog(EDIT_DIALOG)(handleDisplayPatternDropDown,handleDisplayFormat,handleEditPatternDropDown,handleEditFormat,handleLang,handleDatePlaceholders);
5173
})(jQuery);

0 commit comments

Comments
 (0)