|
@@ -150,7 +150,7 @@
|
|
isDate,
|
|
isDate,
|
|
modifyDate,
|
|
modifyDate,
|
|
modifyTime,
|
|
modifyTime,
|
|
- modifyWithDefaultTime,
|
|
|
|
|
|
+ modifyWithTimeString,
|
|
clearMilliseconds,
|
|
clearMilliseconds,
|
|
clearTime,
|
|
clearTime,
|
|
prevYear,
|
|
prevYear,
|
|
@@ -192,7 +192,7 @@
|
|
if (isDate(val)) {
|
|
if (isDate(val)) {
|
|
this.date = new Date(val);
|
|
this.date = new Date(val);
|
|
} else {
|
|
} else {
|
|
- this.date = this.defaultValue ? new Date(this.defaultValue) : new Date();
|
|
|
|
|
|
+ this.date = this.getDefaultValue();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -233,7 +233,7 @@
|
|
},
|
|
},
|
|
|
|
|
|
handleClear() {
|
|
handleClear() {
|
|
- this.date = this.defaultValue ? new Date(this.defaultValue) : new Date();
|
|
|
|
|
|
+ this.date = this.getDefaultValue();
|
|
this.$emit('pick', null);
|
|
this.$emit('pick', null);
|
|
},
|
|
},
|
|
|
|
|
|
@@ -303,7 +303,9 @@
|
|
|
|
|
|
handleTimePick(value, visible, first) {
|
|
handleTimePick(value, visible, first) {
|
|
if (isDate(value)) {
|
|
if (isDate(value)) {
|
|
- const newDate = this.value ? modifyTime(this.date, value.getHours(), value.getMinutes(), value.getSeconds()) : modifyWithDefaultTime(value, this.defaultTime);
|
|
|
|
|
|
+ const newDate = this.value
|
|
|
|
+ ? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds())
|
|
|
|
+ : modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
|
|
this.date = newDate;
|
|
this.date = newDate;
|
|
this.emit(this.date, true);
|
|
this.emit(this.date, true);
|
|
} else {
|
|
} else {
|
|
@@ -334,7 +336,9 @@
|
|
|
|
|
|
handleDatePick(value) {
|
|
handleDatePick(value) {
|
|
if (this.selectionMode === 'day') {
|
|
if (this.selectionMode === 'day') {
|
|
- this.date = this.value ? modifyDate(this.date, value.getFullYear(), value.getMonth(), value.getDate()) : modifyWithDefaultTime(value, this.defaultTime);
|
|
|
|
|
|
+ this.date = this.value
|
|
|
|
+ ? modifyDate(this.value, value.getFullYear(), value.getMonth(), value.getDate())
|
|
|
|
+ : modifyWithTimeString(value, this.defaultTime);
|
|
this.emit(this.date, this.showTime);
|
|
this.emit(this.date, this.showTime);
|
|
} else if (this.selectionMode === 'week') {
|
|
} else if (this.selectionMode === 'week') {
|
|
this.emit(value.date);
|
|
this.emit(value.date);
|
|
@@ -366,8 +370,13 @@
|
|
if (this.selectionMode === 'dates') {
|
|
if (this.selectionMode === 'dates') {
|
|
this.emit(this.selectedDate);
|
|
this.emit(this.selectedDate);
|
|
} else {
|
|
} else {
|
|
- const date = this.value ? this.date : modifyWithDefaultTime(this.date, this.defaultTime);
|
|
|
|
- this.emit(date);
|
|
|
|
|
|
+ // value were emitted in handle{Date,Time}Pick, nothing to update here
|
|
|
|
+ // deal with the scenario where: user opens the picker, then confirm without doing anything
|
|
|
|
+ const value = this.value
|
|
|
|
+ ? this.value
|
|
|
|
+ : modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
|
|
|
|
+ this.date = new Date(value); // refresh date
|
|
|
|
+ this.emit(value);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -466,6 +475,12 @@
|
|
? !this.disabledDate(value)
|
|
? !this.disabledDate(value)
|
|
: true
|
|
: true
|
|
);
|
|
);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ getDefaultValue() {
|
|
|
|
+ // if default-value is set, return it
|
|
|
|
+ // otherwise, return now (the moment this method gets called)
|
|
|
|
+ return this.defaultValue ? new Date(this.defaultValue) : new Date();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -478,7 +493,7 @@
|
|
popperClass: '',
|
|
popperClass: '',
|
|
date: new Date(),
|
|
date: new Date(),
|
|
value: '',
|
|
value: '',
|
|
- defaultValue: null,
|
|
|
|
|
|
+ defaultValue: null, // use getDefaultValue() for time computation
|
|
defaultTime: null,
|
|
defaultTime: null,
|
|
showTime: false,
|
|
showTime: false,
|
|
selectionMode: 'day',
|
|
selectionMode: 'day',
|