FEATURE: Add "Now" as an option (default hidden) to the future date input selector (#10047)

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.

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 6e6b117..97bb5ef 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 a277093..7e286a1 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
@@ -19,6 +19,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",
     enabled: opts => opts.canScheduleToday,
@@ -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 104edd8..56088fe 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"

GitHub sha: 35a15761

1 Like

This commit appears in #10047 which was merged by martin.