2017-11-21 05:53:09 -05:00
|
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
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";
|
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
|
|
|
|
2022-04-21 07:49:11 -04:00
|
|
|
export default ComboBoxComponent.extend({
|
2017-11-21 05:53:09 -05:00
|
|
|
pluginApiIdentifiers: ["future-date-input-selector"],
|
2017-10-19 15:51:08 -04:00
|
|
|
classNames: ["future-date-input-selector"],
|
2022-04-21 07:49:11 -04:00
|
|
|
isCustom: equal("value", "custom"),
|
|
|
|
userTimezone: null,
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2020-02-03 08:22:14 -05:00
|
|
|
selectKitOptions: {
|
|
|
|
autoInsertNoneItem: false,
|
|
|
|
headerComponent:
|
|
|
|
"future-date-input-selector/future-date-input-selector-header",
|
2017-11-21 05:53:09 -05:00
|
|
|
},
|
|
|
|
|
2022-04-21 07:49:11 -04:00
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
2022-12-05 11:25:30 -05:00
|
|
|
this.userTimezone = this.currentUser.user_option.timezone;
|
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";
|
2017-11-21 05:53:09 -05:00
|
|
|
},
|
|
|
|
|
2020-02-03 08:22:14 -05:00
|
|
|
actions: {
|
|
|
|
onChange(value) {
|
2022-04-21 07:49:11 -04:00
|
|
|
if (value !== "custom" && !isEmpty(value)) {
|
|
|
|
const { time } = this.content.find((x) => x.id === value);
|
|
|
|
if (time) {
|
2020-02-03 08:22:14 -05:00
|
|
|
this.attrs.onChangeInput &&
|
|
|
|
this.attrs.onChangeInput(time.locale("en").format(FORMAT));
|
|
|
|
}
|
2017-11-23 09:18:27 -05:00
|
|
|
}
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2020-02-03 08:22:14 -05:00
|
|
|
this.attrs.onChange && this.attrs.onChange(value);
|
2017-11-23 09:18:27 -05:00
|
|
|
},
|
2017-10-19 15:51:08 -04:00
|
|
|
},
|
|
|
|
});
|