discourse/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.0 KiB
JavaScript
Raw Normal View History

import { equal } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import ComboBoxComponent from "select-kit/components/combo-box";
2017-10-20 03:51:08 +08:00
2017-11-29 03:16:13 +08:00
export const FORMAT = "YYYY-MM-DD HH:mmZ";
2017-10-20 03:51:08 +08:00
export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["future-date-input-selector"],
2017-10-20 03:51:08 +08:00
classNames: ["future-date-input-selector"],
isCustom: equal("value", "custom"),
userTimezone: null,
2017-10-20 03:51:08 +08:00
selectKitOptions: {
autoInsertNoneItem: false,
headerComponent:
"future-date-input-selector/future-date-input-selector-header",
},
init() {
this._super(...arguments);
this.userTimezone = this.currentUser.user_option.timezone;
},
modifyComponentForRow() {
return "future-date-input-selector/future-date-input-selector-row";
},
actions: {
onChange(value) {
if (value !== "custom" && !isEmpty(value)) {
const { time } = this.content.find((x) => x.id === value);
if (time) {
2023-11-27 19:16:31 +08:00
this.onChangeInput?.(time.locale("en").format(FORMAT));
}
}
2017-10-20 03:51:08 +08:00
2023-11-27 19:16:31 +08:00
this.onChange?.(value);
},
2017-10-20 03:51:08 +08:00
},
});