Skip to content

Commit c6134f7

Browse files
committed
fix Datatable Date and Time Header Filters should not contain initial values
1 parent 1b8bab1 commit c6134f7

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/DateHeaderFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static <T> DateHeaderFilter<T> create() {
5151
/** Initializes a new DateHeaderFilter. */
5252
public DateHeaderFilter() {
5353
this.dateBox =
54-
DateBox.create()
54+
DateBox.empty()
5555
.setPlaceholder("Search")
5656
.addCss(dui_m_b_0)
5757
.apply(

domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/TimeHeaderFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static <T> TimeHeaderFilter<T> create() {
5252
*/
5353
public TimeHeaderFilter() {
5454
this.timeBox =
55-
TimeBox.create()
55+
TimeBox.empty()
5656
.setPlaceholder("Search")
5757
.apply(
5858
element -> {

domino-ui/src/main/java/org/dominokit/domino/ui/forms/DateBox.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public DateBox(
142142
public DateBox(
143143
Date date, DateTimeFormatInfo dateTimeFormatInfo, CalendarInitConfig calendarInitConfig) {
144144
this.value = date;
145-
this.calendar = Calendar.create(date, dateTimeFormatInfo, calendarInitConfig);
145+
this.calendar =
146+
Calendar.create(nonNull(date) ? date : new Date(), dateTimeFormatInfo, calendarInitConfig);
146147
this.pattern = dateTimeFormatInfo.dateFormatFull();
147148
this.popover =
148149
Popover.create(this.getWrapperElement())
@@ -240,6 +241,18 @@ public DateBox(
240241
setStringValue(value, this.calendar.getDateTimeFormatInfo());
241242
}
242243

244+
// TODO : This needs to be refactored, datebox should be default to empty if data is not specified
245+
// and instead of DateBox.empty() we need to add DateBox.now()
246+
247+
/**
248+
* Creates a new DateBox with the current date and default configuration.
249+
*
250+
* @return A new DateBox instance
251+
*/
252+
public static DateBox empty() {
253+
return new DateBox(null, new CalendarInitConfig());
254+
}
255+
243256
/**
244257
* Creates a new DateBox with the current date and default configuration.
245258
*

domino-ui/src/main/java/org/dominokit/domino/ui/forms/TimeBox.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public TimeBox(String label, Date date, DateTimeFormatInfo dateTimeFormatInfo) {
116116
*/
117117
public TimeBox(Date date, DateTimeFormatInfo dateTimeFormatInfo) {
118118
this.value = date;
119-
this.timePicker = TimePicker.create(date, dateTimeFormatInfo);
119+
this.timePicker = TimePicker.create(nonNull(date) ? date : new Date(), dateTimeFormatInfo);
120120
this.pattern = dateTimeFormatInfo.timeFormatFull();
121121
this.popover =
122122
Popover.create(this.getWrapperElement())
@@ -190,6 +190,18 @@ public TimeBox(Date date, DateTimeFormatInfo dateTimeFormatInfo) {
190190
setStringValue(value, this.timePicker.getDateTimeFormatInfo());
191191
}
192192

193+
// TODO : This needs to be refactored, timebox should be default to empty if data is not specified
194+
// and instead of Timebox.empty() we need to add Timebox.now()
195+
196+
/**
197+
* Creates and returns an empty TimeBox instance with a null Date.
198+
*
199+
* @return a new TimeBox instance with a null Date.
200+
*/
201+
public static TimeBox empty() {
202+
return new TimeBox((Date) null);
203+
}
204+
193205
/**
194206
* Factory method to create a new instance of {@link TimeBox} with the current date set.
195207
*

0 commit comments

Comments
 (0)