UX: sets min date on calendar when initial date is set (#7361)

This commit is contained in:
Joffrey JAFFEUX 2019-04-11 14:37:39 +02:00 committed by GitHub
parent 46dc38e5a5
commit 7dd684744c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -323,11 +323,13 @@ export default Ember.Component.extend({
focusFrom() { focusFrom() {
this.setProperties({ fromSelected: true, toSelected: false }); this.setProperties({ fromSelected: true, toSelected: false });
this._setPickerDate(this.get("fromConfig.date")); this._setPickerDate(this.get("fromConfig.date"));
this._setPickerMinDate(null);
}, },
focusTo() { focusTo() {
this.setProperties({ toSelected: true, fromSelected: false }); this.setProperties({ toSelected: true, fromSelected: false });
this._setPickerDate(this.get("toConfig.date")); this._setPickerDate(this.get("toConfig.date"));
this._setPickerMinDate(this.get("fromConfig.date"));
}, },
advancedMode() { advancedMode() {
@ -397,6 +399,17 @@ export default Ember.Component.extend({
}); });
}, },
_setPickerMinDate(date) {
console.log("_setPickerMinDate", date);
if (date && !moment(date, this.dateFormat).isValid()) {
date = null;
}
Ember.run.schedule("afterRender", () => {
this._picker.setMinDate(moment(date, this.dateFormat).toDate());
});
},
_setPickerDate(date) { _setPickerDate(date) {
if (date && !moment(date, this.dateFormat).isValid()) { if (date && !moment(date, this.dateFormat).isValid()) {
date = null; date = null;