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