mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 07:08:44 +08:00
62029ec4eb
This option was always on. Essentially, we set it only in two places and always use `|| true` with it. Note that we're going to switch future-date-input-selector to another source of time shortcuts(https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/lib/time-shortcut.js) and also change its API to make it more customizable. Removing the includeMidFuture option is a part of that change.
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
import ComboBoxComponent from "select-kit/components/combo-box";
|
|
import DatetimeMixin from "select-kit/components/future-date-input-selector/mixin";
|
|
import { computed } from "@ember/object";
|
|
import { equal } from "@ember/object/computed";
|
|
import { isEmpty } from "@ember/utils";
|
|
import buildTimeframes from "discourse/lib/timeframes-builder";
|
|
import I18n from "I18n";
|
|
|
|
export const FORMAT = "YYYY-MM-DD HH:mmZ";
|
|
|
|
export default ComboBoxComponent.extend(DatetimeMixin, {
|
|
pluginApiIdentifiers: ["future-date-input-selector"],
|
|
classNames: ["future-date-input-selector"],
|
|
isCustom: equal("value", "pick_date_and_time"),
|
|
|
|
selectKitOptions: {
|
|
autoInsertNoneItem: false,
|
|
headerComponent:
|
|
"future-date-input-selector/future-date-input-selector-header",
|
|
},
|
|
|
|
modifyComponentForRow() {
|
|
return "future-date-input-selector/future-date-input-selector-row";
|
|
},
|
|
|
|
content: computed("statusType", function () {
|
|
const now = moment();
|
|
const opts = {
|
|
now,
|
|
day: now.day(),
|
|
includeWeekend: this.includeWeekend,
|
|
includeFarFuture: this.includeFarFuture,
|
|
includeDateTime: this.includeDateTime,
|
|
canScheduleNow: this.includeNow || false,
|
|
canScheduleToday: 24 - now.hour() > 6,
|
|
};
|
|
|
|
return buildTimeframes(opts).map((tf) => {
|
|
return {
|
|
id: tf.id,
|
|
name: I18n.t(`topic.auto_update_input.${tf.id}`),
|
|
datetime: this._computeDatetimeForValue(tf.id),
|
|
icons: this._computeIconsForValue(tf.id),
|
|
};
|
|
});
|
|
}),
|
|
|
|
actions: {
|
|
onChange(value) {
|
|
if (value !== "pick_date_and_time") {
|
|
const { time } = this._updateAt(value);
|
|
if (time && !isEmpty(value)) {
|
|
this.attrs.onChangeInput &&
|
|
this.attrs.onChangeInput(time.locale("en").format(FORMAT));
|
|
}
|
|
}
|
|
|
|
this.attrs.onChange && this.attrs.onChange(value);
|
|
},
|
|
},
|
|
});
|