2019-11-09 00:32:20 +08:00
|
|
|
import { equal } from "@ember/object/computed";
|
2019-11-01 01:37:24 +08:00
|
|
|
import { isEmpty } from "@ember/utils";
|
2023-10-11 02:38:59 +08:00
|
|
|
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
|
|
|
|
2022-04-21 19:49:11 +08:00
|
|
|
export default ComboBoxComponent.extend({
|
2017-11-21 18:53:09 +08:00
|
|
|
pluginApiIdentifiers: ["future-date-input-selector"],
|
2017-10-20 03:51:08 +08:00
|
|
|
classNames: ["future-date-input-selector"],
|
2022-04-21 19:49:11 +08:00
|
|
|
isCustom: equal("value", "custom"),
|
|
|
|
userTimezone: null,
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
selectKitOptions: {
|
|
|
|
autoInsertNoneItem: false,
|
|
|
|
headerComponent:
|
|
|
|
"future-date-input-selector/future-date-input-selector-header",
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
2022-04-21 19:49:11 +08:00
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
2022-12-06 00:25:30 +08:00
|
|
|
this.userTimezone = this.currentUser.user_option.timezone;
|
2022-04-21 19:49:11 +08:00
|
|
|
},
|
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
modifyComponentForRow() {
|
|
|
|
return "future-date-input-selector/future-date-input-selector-row";
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
actions: {
|
|
|
|
onChange(value) {
|
2022-04-21 19:49:11 +08:00
|
|
|
if (value !== "custom" && !isEmpty(value)) {
|
|
|
|
const { time } = this.content.find((x) => x.id === value);
|
|
|
|
if (time) {
|
2020-02-03 21:22:14 +08:00
|
|
|
this.attrs.onChangeInput &&
|
|
|
|
this.attrs.onChangeInput(time.locale("en").format(FORMAT));
|
|
|
|
}
|
2017-11-23 22:18:27 +08:00
|
|
|
}
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
this.attrs.onChange && this.attrs.onChange(value);
|
2017-11-23 22:18:27 +08:00
|
|
|
},
|
2017-10-20 03:51:08 +08:00
|
|
|
},
|
|
|
|
});
|