diff --git a/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 b/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 index cb7650e7..4cfd4883 100644 --- a/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 +++ b/assets/javascripts/discourse/controllers/next-session-scheduled.js.es6 @@ -1,58 +1,27 @@ import { default as discourseComputed } from 'discourse-common/utils/decorators'; -import { scheduleOnce } from "@ember/runloop"; import Controller from "@ember/controller"; export default Controller.extend({ title: 'admin.wizard.after_time_modal.title', setup() { - const dateTime = this.get('model.dateTime'); - const ROUNDING = 30 * 60 * 1000; - const nextInterval = moment(Math.ceil((+moment()) / ROUNDING) * ROUNDING); - const mDateTime = dateTime ? moment(dateTime) : nextInterval; - const mDateTimeLocal = mDateTime.local(); - const date = mDateTimeLocal.format('YYYY-MM-DD'); - const time = mDateTimeLocal.format('HH:mm'); - - this.setProperties({ date, time }); - - scheduleOnce('afterRender', this, () => { - const $timePicker = $("#time-picker"); - $timePicker.timepicker({ timeFormat: 'H:i' }); - $timePicker.timepicker('setTime', time); - $timePicker.change(() => this.set('time', $timePicker.val())); - }); + this.set('bufferedDateTime', moment(this.model.dateTime)); }, - @discourseComputed('date', 'time') - dateTime: function(date, time) { - return moment(date + 'T' + time).format(); - }, - - @discourseComputed('dateTime') + @discourseComputed('bufferedDateTime') submitDisabled(dateTime) { return moment().isAfter(dateTime); }, - resetProperties() { - this.setProperties({ - date: null, - time: null - }); - }, - actions: { - clear() { - this.resetProperties(); - this.get('model.update')(null); - }, - submit() { - const dateTime = this.get('dateTime'); - const formatted = moment(dateTime).utc().toISOString(); - this.get('model.update')(formatted); - this.resetProperties(); + const dateTime = this.get('bufferedDateTime'); + this.get('model.update')(moment(dateTime).utc().toISOString()); this.send("closeModal"); + }, + + dateTimeChanged(dateTime) { + this.set('bufferedDateTime', dateTime); } } }); diff --git a/assets/javascripts/discourse/templates/modal/next-session-scheduled.hbs b/assets/javascripts/discourse/templates/modal/next-session-scheduled.hbs index 36c08a3f..1b138360 100644 --- a/assets/javascripts/discourse/templates/modal/next-session-scheduled.hbs +++ b/assets/javascripts/discourse/templates/modal/next-session-scheduled.hbs @@ -1,24 +1,16 @@ {{#d-modal-body class="next-session-time-modal" title=title}} -