Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DateRangePicker Max/Min Date Problem #18730

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ protected TagHelperAttributeList ConvertDatePickerOptionsToAttributeList(IAbpDat

if (options.MinDate != null)
{
attrList.Add("data-min-date", options.MinDate);
attrList.Add("data-min-date", options.MinDate?.ToString("O"));
}

if (options.MaxDate != null)
{
attrList.Add("data-max-date", options.MaxDate);
attrList.Add("data-max-date", options.MaxDate?.ToString("O"));
}

if (options.MaxSpan != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
var today = moment();
$dateRangePicker.setStartDate(today);
$dateRangePicker.setEndDate(today);

if(options.singleDatePicker && options.autoApply){
$dateRangePicker.clickApply();
}else{
Expand Down Expand Up @@ -366,6 +366,14 @@
});
}

if (options.maxDate){
options.maxDate = convertToMoment(options.maxDate, options);
}

if (options.minDate){
options.minDate = convertToMoment(options.minDate, options);
}

if (typeof options.template !== 'string' && !(options.template instanceof $))
options.template =
'<div class="daterangepicker">' +
Expand Down Expand Up @@ -433,13 +441,13 @@

return '';
}

function createInitialAbpDate(date, options) {
date = convertToMoment(date, options, undefined, options.isUtc);
if (options.isUtc) {
date = date.local();
}

return AbpDate(date, options);
}

Expand Down Expand Up @@ -468,8 +476,9 @@
var singleOpenAndClearButton = options.singleOpenAndClearButton && $clearButton.length > 0 && $openButton.length > 0;

var startDate = createInitialAbpDate(options.startDate || options.date || (options.autoUpdateInput ? new Date() : undefined), options);

var oldStartDate = AbpDate(undefined, options);

var endDate = createInitialAbpDate(options.endDate || (options.autoUpdateInput ? new Date() : undefined), options);
var oldEndDate = AbpDate(undefined, options);

Expand Down Expand Up @@ -583,7 +592,7 @@
}else{
picker.setStartDate(convertToMoment(startDate, options, options.inputDateFormat));
}

if(singleDatePicker){
picker.setEndDate(picker.startDate);
}else if(isEmptyDate(endDate, options)){
Expand Down