Update calendar on value change externally

pull/12/head
cagataycivici 2019-05-16 16:51:43 +03:00
parent 5b06d2e79d
commit b3f90755d7
1 changed files with 20 additions and 7 deletions

View File

@ -294,10 +294,7 @@ export default {
} }
}, },
created() { created() {
const viewDate = this.viewDate; this.updateCurrentMetaData();
this.currentMonth = viewDate.getMonth();
this.currentYear = viewDate.getFullYear();
this.initTime(viewDate);
}, },
data() { data() {
return { return {
@ -314,6 +311,11 @@ export default {
maskClickListener: null, maskClickListener: null,
mask: null, mask: null,
timePickerTimer: null, timePickerTimer: null,
watch: {
value() {
this.updateCurrentMetaData();
}
},
methods: { methods: {
isSelected(dateMeta) { isSelected(dateMeta) {
if (this.value) { if (this.value) {
@ -537,10 +539,15 @@ export default {
this.currentMinute = date.getMinutes(); this.currentMinute = date.getMinutes();
this.currentSecond = date.getSeconds(); this.currentSecond = date.getSeconds();
if (this.hourFormat == '12') if (this.hourFormat == '12') {
this.currentHour = date.getHours() == 0 ? 12 : date.getHours() % 12; if (hours >= 12)
else this.currentHour = (hours == 12) ? 12 : hours - 12;
else
this.currentHour = (hours == 0) ? 12 : hours;
}
else {
this.currentHour = date.getHours(); this.currentHour = date.getHours();
}
} }
else if (this.timeOnly) { else if (this.timeOnly) {
this.currentMinute = 0; this.currentMinute = 0;
@ -1153,6 +1160,12 @@ export default {
this.overlayVisible = false; this.overlayVisible = false;
} }
},
updateCurrentMetaData() {
const viewDate = this.viewDate;
this.currentMonth = viewDate.getMonth();
this.currentYear = viewDate.getFullYear();
this.initTime(viewDate);
} }
}, },
computed: { computed: {