2024-08-23 19:17:07 +08:00
|
|
|
import { action } from "@ember/object";
|
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";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
2023-10-11 02:38:59 +08:00
|
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
2024-08-23 19:17:07 +08:00
|
|
|
import {
|
|
|
|
pluginApiIdentifiers,
|
|
|
|
selectKitOptions,
|
|
|
|
} from "select-kit/components/select-kit";
|
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
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@classNames("future-date-input-selector")
|
|
|
|
@selectKitOptions({
|
|
|
|
autoInsertNoneItem: false,
|
|
|
|
headerComponent:
|
|
|
|
"future-date-input-selector/future-date-input-selector-header",
|
|
|
|
})
|
|
|
|
@pluginApiIdentifiers("future-date-input-selector")
|
|
|
|
export default class FutureDateInputSelector extends ComboBoxComponent {
|
|
|
|
@equal("value", "custom") isCustom;
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
userTimezone = null;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2022-04-21 19:49:11 +08:00
|
|
|
init() {
|
2024-08-23 19:17:07 +08:00
|
|
|
super.init(...arguments);
|
2022-12-06 00:25:30 +08:00
|
|
|
this.userTimezone = this.currentUser.user_option.timezone;
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
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";
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@action
|
|
|
|
_onChange(value) {
|
|
|
|
if (value !== "custom" && !isEmpty(value)) {
|
|
|
|
const { time } = this.content.find((x) => x.id === value);
|
|
|
|
if (time) {
|
|
|
|
this.onChangeInput?.(time.locale("en").format(FORMAT));
|
2017-11-23 22:18:27 +08:00
|
|
|
}
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
this.onChange?.(value);
|
|
|
|
}
|
|
|
|
}
|