Prevent selecting disabled dates

This commit is contained in:
Sergio Crisostomo 2018-05-21 08:24:56 +02:00
parent e9d7ff50f5
commit 939a162ad7
4 changed files with 13 additions and 4 deletions

View file

@ -385,7 +385,15 @@
if (this.type.match(/range/)){
this.$refs.pickerPanel.handleRangePick(this.focusedDate, 'date');
} else {
this.onPick(this.focusedDate, false, 'date');
const panels = findComponentsDownward(this, 'PanelTable');
const compareDate = (d) => {
const sliceIndex = ['year', 'month', 'date'].indexOf((this.type)) + 1;
return [d.getFullYear(), d.getMonth(), d.getDate()].slice(0, sliceIndex).join('-');
};
const dateIsValid = panels.find(({cells}) => {
return cells.find(({date, disabled}) => compareDate(date) === compareDate(this.focusedDate) && !disabled);
});
if (dateIsValid) this.onPick(this.focusedDate, false, 'date');
}
}