2024-08-23 19:17:07 +08:00
|
|
|
import { action } from "@ember/object";
|
2020-02-03 21:22:14 +08:00
|
|
|
import { oneWay, readOnly } from "@ember/object/computed";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { classNameBindings, classNames } from "@ember-decorators/component";
|
2023-10-18 18:07:09 +08:00
|
|
|
import I18n from "discourse-i18n";
|
2023-10-11 02:38:59 +08:00
|
|
|
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { selectKitOptions } from "select-kit/components/select-kit";
|
2018-01-15 18:55:16 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@classNames("period-chooser")
|
|
|
|
@classNameBindings("showPeriods::hidden")
|
|
|
|
@selectKitOptions({
|
|
|
|
filterable: false,
|
|
|
|
autoFilterable: false,
|
|
|
|
fullDay: "fullDay",
|
|
|
|
customStyle: true,
|
|
|
|
headerComponent: "period-chooser/period-chooser-header",
|
|
|
|
headerAriaLabel: I18n.t("period_chooser.aria_label"),
|
|
|
|
})
|
|
|
|
export default class PeriodChooser extends DropdownSelectBoxComponent {
|
|
|
|
@oneWay("site.periods") content;
|
|
|
|
@readOnly("period") value;
|
|
|
|
|
|
|
|
valueProperty = null;
|
|
|
|
nameProperty = null;
|
|
|
|
showPeriods = true;
|
2020-02-03 21:22:14 +08:00
|
|
|
|
|
|
|
modifyComponentForRow() {
|
|
|
|
return "period-chooser/period-chooser-row";
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2018-05-09 16:05:40 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@action
|
|
|
|
_onChange(value) {
|
|
|
|
if (this.action) {
|
|
|
|
this.action(value);
|
|
|
|
} else {
|
|
|
|
this.onChange?.(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|