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

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

diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6
index f2c3c10..f154cb1 100644
--- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6
+++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6
@@ -323,11 +323,13 @@ export default Ember.Component.extend({
     focusFrom() {
       this.setProperties({ fromSelected: true, toSelected: false });
       this._setPickerDate(this.get("fromConfig.date"));
+      this._setPickerMinDate(null);
     },
 
     focusTo() {
       this.setProperties({ toSelected: true, fromSelected: false });
       this._setPickerDate(this.get("toConfig.date"));
+      this._setPickerMinDate(this.get("fromConfig.date"));
     },
 
     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) {
     if (date && !moment(date, this.dateFormat).isValid()) {
       date = null;

GitHub sha: 7dd68474