Merge pull request #4256 from SergioCrisostomo/fix-4249

Use last selected multiple date in date panel navigation
This commit is contained in:
Aresn 2018-08-20 10:45:30 +08:00 committed by GitHub
commit bc39c5c1d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -150,7 +150,8 @@
watch: {
value (newVal) {
this.dates = newVal;
this.panelDate = this.startDate || (this.multiple ? this.dates[this.dates.length - 1] : this.dates[0]) || new Date();
const panelDate = this.multiple ? this.dates[this.dates.length - 1] : (this.startDate || this.dates[0]);
this.panelDate = panelDate || new Date();
},
currentView (currentView) {
this.$emit('on-selection-mode-change', currentView);
@ -170,7 +171,7 @@
const isDifferentYear = date.getFullYear() !== this.panelDate.getFullYear();
const isDifferentMonth = isDifferentYear || date.getMonth() !== this.panelDate.getMonth();
if (isDifferentYear || isDifferentMonth){
this.panelDate = date;
if (!this.multiple) this.panelDate = date;
}
}
},

View file

@ -646,7 +646,6 @@
}
},
onPick(dates, visible = false, type) {
dates = this.parseDate(dates);
if (this.multiple){
const pickedTimeStamp = dates.getTime();
const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp);
@ -654,6 +653,7 @@
const timeStamps = allDates.map(date => date.getTime()).filter((ts, i, arr) => arr.indexOf(ts) === i && i !== indexOfPickedDate); // filter away duplicates
this.internalValue = timeStamps.map(ts => new Date(ts));
} else {
dates = this.parseDate(dates);
this.internalValue = Array.isArray(dates) ? dates : [dates];
}