From b196acf15145f6f337c89b7c9f91687fca1bef5c Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Fri, 15 May 2020 12:06:21 +1000 Subject: [PATCH] Update after-time modal to use new date time inputs --- .../controllers/next-session-scheduled.js.es6 | 47 +++------------- .../modal/next-session-scheduled.hbs | 30 ++++------- assets/stylesheets/common/wizard-admin.scss | 54 +++---------------- 3 files changed, 25 insertions(+), 106 deletions(-) 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}} -
- -
-
+ {{date-time-input + date=bufferedDateTime + onChange=(action "dateTimeChanged") + showTime=true + clearable=true + }} {{/d-modal-body}} diff --git a/assets/stylesheets/common/wizard-admin.scss b/assets/stylesheets/common/wizard-admin.scss index fba44a3e..5eacc613 100644 --- a/assets/stylesheets/common/wizard-admin.scss +++ b/assets/stylesheets/common/wizard-admin.scss @@ -481,54 +481,12 @@ min-height: 150px; } -.next-session-time-modal { - text-align: center; - - .date-time-card { - width: 270px; - padding: 10px 20px; - text-align: left; - } - - .modal-date-time-set{ - padding-top: 3px; - padding-bottom: 4px; - display: flex; - flex-direction: row; - - .modal-date-area{ - order: 1; - } - - .modal-time-area{ - order: 2; - margin-left: 10px; - - .modal-time{ - width: 127px; - } - } - } - - .ui-timepicker-input { - width: 119px; - text-align: center; - } - - .date-picker{ - width: 121px; - } - - .pika-single { - position: relative !important; - - .pika-lendar { - border: 1px solid #eee; - padding: 14px; - margin: 0; - float: none; - width: auto; - } +.modal .modal-body.next-session-time-modal { + overflow: visible; + + .picker-container { + position: absolute; + top: 30px; } }