2024-08-23 12:17:07 +01:00
|
|
|
import { action } from "@ember/object";
|
2019-11-08 10:32:20 -06:00
|
|
|
import { equal } from "@ember/object/computed";
|
2019-10-31 13:37:24 -04:00
|
|
|
import { isEmpty } from "@ember/utils";
|
2024-08-23 12:17:07 +01:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
2023-10-10 19:38:59 +01:00
|
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
2024-08-23 12:17:07 +01:00
|
|
|
import {
|
|
|
|
pluginApiIdentifiers,
|
|
|
|
selectKitOptions,
|
|
|
|
} from "select-kit/components/select-kit";
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2017-11-28 14:16:13 -05:00
|
|
|
export const FORMAT = "YYYY-MM-DD HH:mmZ";
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2024-08-23 12:17:07 +01: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-19 12:51:08 -07:00
|
|
|
|
2024-08-23 12:17:07 +01:00
|
|
|
userTimezone = null;
|
2017-11-21 11:53:09 +01:00
|
|
|
|
2022-04-21 15:49:11 +04:00
|
|
|
init() {
|
2024-08-23 12:17:07 +01:00
|
|
|
super.init(...arguments);
|
2022-12-05 18:25:30 +02:00
|
|
|
this.userTimezone = this.currentUser.user_option.timezone;
|
2024-08-23 12:17:07 +01:00
|
|
|
}
|
2022-04-21 15:49:11 +04:00
|
|
|
|
2020-02-03 14:22:14 +01:00
|
|
|
modifyComponentForRow() {
|
|
|
|
return "future-date-input-selector/future-date-input-selector-row";
|
2024-08-23 12:17:07 +01:00
|
|
|
}
|
2017-11-21 11:53:09 +01:00
|
|
|
|
2024-08-23 12:17:07 +01: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 15:18:27 +01:00
|
|
|
}
|
2024-08-23 12:17:07 +01:00
|
|
|
}
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2024-08-23 12:17:07 +01:00
|
|
|
this.onChange?.(value);
|
|
|
|
}
|
|
|
|
}
|