Skip to content

Commit c620390

Browse files
devgurjardgurjar
andauthored
date picker layout issue (#1145)
Co-authored-by: dgurjar <dgurjar@adobe.com>
1 parent 61b45f1 commit c620390

File tree

4 files changed

+455
-20
lines changed
  • it/content/src/main/content/jcr_root/content
    • dam/formsanddocuments/core-components-it/samples/datepicker/datepickerlayoutissue
    • forms/af/core-components-it/samples/datepicker/datepickerlayoutissue
  • ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/datepicker/v1/datepicker/clientlibs/site/js
  • ui.tests/test-module/specs/datepicker

4 files changed

+455
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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:xmp="http://ns.adobe.com/xap/1.0/" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
3+
jcr:primaryType="dam:Asset">
4+
<jcr:content
5+
cq:conf="\0"
6+
jcr:lastModified="{Date}2024-03-26T17:00:31.679+05:30"
7+
jcr:primaryType="dam:AssetContent"
8+
sling:resourceType="fd/fm/af/render"
9+
guide="1"
10+
type="guide">
11+
<metadata
12+
fd:version="2.1"
13+
jcr:language="en"
14+
jcr:primaryType="nt:unstructured"
15+
xmp:CreatorTool="AEM Forms AF Wizard"
16+
allowedRenderFormat="HTML"
17+
author="admin"
18+
availableInMobileApp="{Boolean}false"
19+
dorTemplateChanged="Boolean"
20+
dorType="none"
21+
formmodel="none"
22+
themeRef="/libs/fd/af/themes/canvas"
23+
title="datepickerlayoutissue"/>
24+
</jcr:content>
25+
</jcr:root>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
3+
jcr:primaryType="cq:Page">
4+
<jcr:content
5+
cq:deviceGroups="[/etc/mobile/groups/responsive]"
6+
cq:lastModified="{Date}2024-03-26T17:00:31.680+05:30"
7+
cq:lastModifiedBy="admin"
8+
cq:template="/conf/core-components-it/settings/wcm/templates/af-blank-v2"
9+
jcr:language="en"
10+
jcr:primaryType="cq:PageContent"
11+
jcr:title="datepickerlayoutissue"
12+
sling:configRef="/conf/forms/datepickerlayoutissue/"
13+
sling:resourceType="forms-components-examples/components/page">
14+
<guideContainer
15+
fd:version="2.1"
16+
jcr:lastModified="{Date}2024-03-20T11:03:06.898+05:30"
17+
jcr:lastModifiedBy="admin"
18+
jcr:primaryType="nt:unstructured"
19+
sling:resourceType="forms-components-examples/components/form/container"
20+
actionType="fd/dashboard/components/actions/aemworkflowsubmit"
21+
attachmentsFolderPath="b.pdf"
22+
attachmentsType="FOLDER_PAYLOAD"
23+
dataXMLPath="a.xml"
24+
dataXMLType="FOLDER_PAYLOAD"
25+
dorPath="c.pdf"
26+
dorType="none"
27+
fieldType="form"
28+
schemaType="none"
29+
textIsRich="true"
30+
thankYouMessage="Thank you for submitting the form."
31+
thankYouOption="page"
32+
themeRef="/libs/fd/af/themes/canvas"
33+
title="datepickerlayoutissue"
34+
workflowDorType="FOLDER_PAYLOAD"
35+
workflowModel="/var/workflow/models/dam/adddamsize">
36+
<datepicker
37+
jcr:created="{Date}2024-03-19T15:49:42.923+05:30"
38+
jcr:createdBy="admin"
39+
jcr:lastModified="{Date}2024-03-19T15:49:51.630+05:30"
40+
jcr:lastModifiedBy="admin"
41+
jcr:primaryType="nt:unstructured"
42+
jcr:title="Date Input"
43+
sling:resourceType="forms-components-examples/components/form/datepicker"
44+
displayFormat="EEEE, d MMMM, y"
45+
displayPatternType="EEEE, d MMMM, y"
46+
editFormat="EEEE, d MMMM, y"
47+
editPatternType="EEEE, d MMMM, y"
48+
enabled="{Boolean}true"
49+
fieldType="date-input"
50+
hideTitle="false"
51+
name="datepicker1710843583321"
52+
readOnly="{Boolean}false"
53+
textIsRich="[true,true]"
54+
unboundFormElement="{Boolean}false"
55+
visible="{Boolean}true"/>
56+
</guideContainer>
57+
</jcr:content>
58+
</jcr:root>

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

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if (typeof window.DatePickerWidget === 'undefined') {
5757
*/
5858
#defaultOptions = {
5959
yearsPerView: 16,
60-
width: 433,
60+
width: 340,
6161
viewHeight: 248,
6262
locale: {
6363
days: ["S","M","T","W","T","F","S"],
@@ -626,9 +626,8 @@ if (typeof window.DatePickerWidget === 'undefined') {
626626
var self = this,
627627
curDate = new Date(this.currentYear, this.currentMonth),
628628
maxDay = this.#maxDate(this.currentMonth),
629-
prevMaxDay = this.#maxDate((this.currentMonth + 12) % 12),
629+
prevMaxDay = this.#maxDate((this.currentMonth + 11) % 12),
630630
day1 = new Date(this.currentYear, this.currentMonth, 1).getDay(),
631-
rowsReq = Math.ceil((day1 + maxDay) / 7) + 1,
632631
data, display;
633632
var localizedYear = this.#getLocalizedYear(curDate);
634633

@@ -637,19 +636,22 @@ if (typeof window.DatePickerWidget === 'undefined') {
637636
caption: this.#options.locale.months[this.currentMonth] + ", "
638637
+ this.#convertNumberToLocale(localizedYear),
639638
header: this.#options.locale.days,
640-
numRows: rowsReq,
639+
numRows: 7,
641640
numColumns: 7,
642641
elementAt: function (row, col) {
643642
var day = (row - 1) * 7 + col - day1 + 1;
643+
var monthVal = self.currentMonth + 1;
644644
let gridId = "day-" + day;
645645
display = self.#convertNumberToLocale(day);
646646
data = day;
647647
if (day < 1) {
648648
display = self.#convertNumberToLocale(prevMaxDay + day);
649-
data = -1
649+
data = -1;
650+
monthVal = self.currentMonth;
650651
} else if (day > maxDay) {
651652
display = self.#convertNumberToLocale(day - maxDay);
652653
data = -1;
654+
monthVal = self.currentMonth + 2;
653655
} else {
654656
curDate.setDate(day);
655657
// check if the currentdate is valid based on max and min valid date
@@ -664,7 +666,7 @@ if (typeof window.DatePickerWidget === 'undefined') {
664666
gridId: gridId,
665667
display: display,
666668
ariaLabel: self.#options.editValue(
667-
self.currentYear + "-" + self.#pad2(self.currentMonth + 1)
669+
self.currentYear + "-" + self.#pad2(monthVal)
668670
+ "-" + self.#pad2(display))
669671
};
670672
}
@@ -857,20 +859,6 @@ if (typeof window.DatePickerWidget === 'undefined') {
857859
}
858860
this.insertRow(r++, row, false, options.elementAt);
859861
}
860-
861-
rows = this["$" + this.view.toLowerCase()].querySelectorAll("ul");
862-
rows = [...rows].filter((r) => {
863-
return !(r.offsetHeight === 0 && r.offsetWidth === 0)
864-
});
865-
let len = rows.length;
866-
while (len > options.numRows) {
867-
this["$" + this.view.toLowerCase()].querySelectorAll(
868-
"ul")[--len].style.display = "none";
869-
}
870-
while (options.numRows > len) {
871-
this["$" + this.view.toLowerCase()].querySelectorAll(
872-
"ul")[len++].style.display = "flex";
873-
}
874862
}
875863

876864
#hotKeysCallBack = this.#hotKeys.bind(this);

0 commit comments

Comments
 (0)