discourse/app/assets/javascripts/select-kit/components/notifications-button.js.es6

55 lines
1.5 KiB
Plaintext
Raw Normal View History

import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
2018-06-15 23:03:24 +08:00
import {
default as computed,
observes,
2018-06-15 23:03:24 +08:00
on
} from "ember-addons/ember-computed-decorators";
2017-10-20 03:51:08 +08: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",
allowInitialValueMutation: false,
2017-10-20 03:51:08 +08:00
i18nPrefix: "",
i18nPostfix: "",
@computed("iconForSelectedDetails")
2018-06-15 23:03:24 +08:00
headerIcon(iconForSelectedDetails) {
return iconForSelectedDetails;
},
@on("init")
@observes("i18nPostfix")
_setNotificationsButtonComponentOptions() {
this.get("rowComponentOptions").setProperties({
i18nPrefix: this.get("i18nPrefix"),
i18nPostfix: this.get("i18nPostfix")
});
},
2017-11-24 01:15:37 +08:00
iconForSelectedDetails: Ember.computed.alias("selectedDetails.icon"),
computeHeaderContent() {
let content = this._super(...arguments);
2018-06-15 23:03:24 +08:00
content.name = I18n.t(
2018-06-26 20:31:43 +08:00
`${this.get("i18nPrefix")}.${this.get("selectedDetails.key")}${this.get(
"i18nPostfix"
)}.title`
2018-06-15 23:03:24 +08:00
);
content.hasSelection = this.get("hasSelection");
return content;
},
2017-10-20 03:51:08 +08:00
@computed("computedValue")
selectedDetails(computedValue) {
return buttonDetails(computedValue);
}
});