Skip to content

Commit

Permalink
airDatepicker: umpdated disabledDates js method
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Aug 28, 2024
1 parent ca76456 commit 1eb5e3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion inst/packer/air-datepicker.js

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions srcjs/inputs/air-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function onRenderCell(disabledDates, disabledDaysOfWeek, highlightedDates) {
return {
html: html,
classes: classes,
disabled: disabled
disabled: disabled > 0
};
}
};
Expand Down Expand Up @@ -157,9 +157,7 @@ $.extend(AirDatepickerBindings, {

// disable dates
var disabledDates = [];
if (config.hasOwnProperty("disabledDates")) {
disabledDates = config.disabledDates;
}

var disabledDaysOfWeek = [];
if (config.hasOwnProperty("disabledDaysOfWeek")) {
disabledDaysOfWeek = config.disabledDaysOfWeek;
Expand All @@ -186,6 +184,9 @@ $.extend(AirDatepickerBindings, {
if (config.hasOwnProperty("startView")) {
dp.date = as_date({date: config.startView, tz: options.tz});
}
if (config.hasOwnProperty("disabledDates")) {
dp.disableDate(config.disabledDates);
}
AirDatepickerBindings.updateStore(el, dp);
},
find: scope => {
Expand Down Expand Up @@ -263,14 +264,14 @@ $.extend(AirDatepickerBindings, {
}

if (
options.hasOwnProperty("disabledDates") |
options.hasOwnProperty("disabledDaysOfWeek") |
options.hasOwnProperty("highlightedDates")
) {
//dp.enableDate(dp.disabledDates);
var disabledDates = [];
if (options.hasOwnProperty("disabledDates")) {
disabledDates = options.disabledDates;
}
//if (options.hasOwnProperty("disabledDates")) {
// disabledDates = options.disabledDates;
//}
var disabledDaysOfWeek = [];
if (options.hasOwnProperty("disabledDaysOfWeek")) {
disabledDaysOfWeek = options.disabledDaysOfWeek;
Expand All @@ -279,11 +280,21 @@ $.extend(AirDatepickerBindings, {
if (options.hasOwnProperty("highlightedDates")) {
highlightedDates = options.highlightedDates;
}

options.onRenderCell = onRenderCell(disabledDates, disabledDaysOfWeek, highlightedDates);
}

dp.update(options);

if (options.hasOwnProperty("disabledDates")) {
if (dp.disabledDates.size > 0) {
dp.disabledDates.forEach(function (value) {
dp.enableDate(value);
});
}
dp.disableDate(options.disabledDates);
}

if (options.hasOwnProperty("startView")) {
dp.date = as_date({date: options.startView, tz: options.tz});
}
Expand Down

0 comments on commit 1eb5e3f

Please sign in to comment.