From 35a157619aca8ffed1af6f044987092b7494ad80 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Mon, 15 Jun 2020 14:06:03 +1000 Subject: [PATCH] FEATURE: Add "Now" as an option (default hidden) to the future date input selector (#10047) Sometimes you need to schedule things from now onward. "Now" in this case is now + 1 minute. this option is hidden by default. --- .../app/templates/components/future-date-input.hbs | 1 + .../addon/components/future-date-input-selector.js | 8 ++++++++ config/locales/client.en.yml | 1 + 3 files changed, 10 insertions(+) diff --git a/app/assets/javascripts/discourse/app/templates/components/future-date-input.hbs b/app/assets/javascripts/discourse/app/templates/components/future-date-input.hbs index 6e6b117e087..97bb5ef4384 100644 --- a/app/assets/javascripts/discourse/app/templates/components/future-date-input.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/future-date-input.hbs @@ -11,6 +11,7 @@ includeWeekend=includeWeekend includeFarFuture=includeFarFuture includeMidFuture=includeMidFuture + includeNow=includeNow clearable=clearable none="topic.auto_update_input.none" onChangeInput=onChangeInput diff --git a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js index a2770936e5f..7e286a1f2c3 100644 --- a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js +++ b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js @@ -18,6 +18,13 @@ function buildTimeframe(opts) { } export const TIMEFRAMES = [ + buildTimeframe({ + id: "now", + format: "h:mm a", + enabled: opts => opts.canScheduleNow, + when: time => time.add(1, "minute"), + icon: "magic" + }), buildTimeframe({ id: "later_today", format: "h a", @@ -214,6 +221,7 @@ export default ComboBoxComponent.extend(DatetimeMixin, { includeFarFuture: this.includeFarFuture, includeDateTime: this.includeDateTime, includeBasedOnLastPost: this.statusType === CLOSE_STATUS_TYPE, + canScheduleNow: this.includeNow || false, canScheduleToday: 24 - now.hour() > 6 }; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 104edd8793c..56088fe45c9 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2225,6 +2225,7 @@ en: time_frame_required: Please select a time frame auto_update_input: none: "Select a timeframe" + now: "Now" later_today: "Later today" tomorrow: "Tomorrow" later_this_week: "Later this week"