2019-11-08 11:32:20 -05:00
|
|
|
import { alias } from "@ember/object/computed";
|
2017-11-21 05:53:09 -05:00
|
|
|
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
2018-06-15 11:03:24 -04:00
|
|
|
import {
|
2019-11-07 16:38:28 -05:00
|
|
|
default as discourseComputed,
|
2019-01-10 05:06:01 -05:00
|
|
|
observes,
|
2018-06-15 11:03:24 -04:00
|
|
|
on
|
2019-11-07 16:38:28 -05:00
|
|
|
} from "discourse-common/utils/decorators";
|
2017-10-19 15:51:08 -04:00
|
|
|
import { buttonDetails } from "discourse/lib/notification-levels";
|
|
|
|
import { allLevels } from "discourse/lib/notification-levels";
|
|
|
|
|
|
|
|
export default DropdownSelectBoxComponent.extend({
|
|
|
|
classNames: "notifications-button",
|
|
|
|
nameProperty: "key",
|
|
|
|
fullWidthOnMobile: true,
|
|
|
|
content: allLevels,
|
|
|
|
castInteger: true,
|
|
|
|
autofilterable: false,
|
|
|
|
filterable: false,
|
|
|
|
rowComponent: "notifications-button/notifications-button-row",
|
2017-11-21 05:53:09 -05:00
|
|
|
allowInitialValueMutation: false,
|
2017-10-19 15:51:08 -04:00
|
|
|
i18nPrefix: "",
|
|
|
|
i18nPostfix: "",
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("iconForSelectedDetails")
|
2018-06-15 11:03:24 -04:00
|
|
|
headerIcon(iconForSelectedDetails) {
|
|
|
|
return iconForSelectedDetails;
|
|
|
|
},
|
2017-11-21 05:53:09 -05:00
|
|
|
|
2019-01-10 05:06:01 -05:00
|
|
|
@on("init")
|
|
|
|
@observes("i18nPostfix")
|
|
|
|
_setNotificationsButtonComponentOptions() {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.rowComponentOptions.setProperties({
|
|
|
|
i18nPrefix: this.i18nPrefix,
|
|
|
|
i18nPostfix: this.i18nPostfix
|
2019-01-10 05:06:01 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-11-08 11:32:20 -05:00
|
|
|
iconForSelectedDetails: alias("selectedDetails.icon"),
|
2017-11-21 05:53:09 -05:00
|
|
|
|
|
|
|
computeHeaderContent() {
|
2019-01-19 04:05:51 -05:00
|
|
|
let content = this._super(...arguments);
|
2018-06-15 11:03:24 -04:00
|
|
|
content.name = I18n.t(
|
2019-05-27 04:15:39 -04:00
|
|
|
`${this.i18nPrefix}.${this.get("selectedDetails.key")}${this.get(
|
2018-06-26 08:31:43 -04:00
|
|
|
"i18nPostfix"
|
|
|
|
)}.title`
|
2018-06-15 11:03:24 -04:00
|
|
|
);
|
2019-05-27 04:15:39 -04:00
|
|
|
content.hasSelection = this.hasSelection;
|
2017-11-21 05:53:09 -05:00
|
|
|
return content;
|
|
|
|
},
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("computedValue")
|
2017-10-19 15:51:08 -04:00
|
|
|
selectedDetails(computedValue) {
|
|
|
|
return buttonDetails(computedValue);
|
|
|
|
}
|
|
|
|
});
|