2017-11-21 18:53:09 +08:00
|
|
|
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
2017-10-20 03:51:08 +08:00
|
|
|
import { default as computed, on } from "ember-addons/ember-computed-decorators";
|
|
|
|
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,
|
|
|
|
collectionHeight: "auto",
|
|
|
|
castInteger: true,
|
|
|
|
autofilterable: false,
|
|
|
|
filterable: false,
|
|
|
|
rowComponent: "notifications-button/notifications-button-row",
|
2017-11-21 18:53:09 +08:00
|
|
|
allowInitialValueMutation: false,
|
2017-10-20 03:51:08 +08:00
|
|
|
i18nPrefix: "",
|
|
|
|
i18nPostfix: "",
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
@computed("iconForSelectedDetails")
|
|
|
|
headerIcon(iconForSelectedDetails) { return iconForSelectedDetails; },
|
|
|
|
|
2017-11-24 01:15:37 +08:00
|
|
|
iconForSelectedDetails: Ember.computed.alias("selectedDetails.icon"),
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
|
|
computeHeaderContent() {
|
|
|
|
let content = this.baseHeaderComputedContent();
|
|
|
|
content.name = I18n.t(`${this.get("i18nPrefix")}.${this.get("selectedDetails.key")}.title`);
|
|
|
|
content.hasSelection = this.get("hasSelection");
|
|
|
|
return content;
|
|
|
|
},
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
@on("didReceiveAttrs")
|
|
|
|
_setNotificationsButtonComponentOptions() {
|
2017-11-10 02:57:53 +08:00
|
|
|
this.get("rowComponentOptions").setProperties({
|
2017-10-20 03:51:08 +08:00
|
|
|
i18nPrefix: this.get("i18nPrefix"),
|
|
|
|
i18nPostfix: this.get("i18nPostfix")
|
2017-11-10 02:57:53 +08:00
|
|
|
});
|
2017-10-20 03:51:08 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed("computedValue")
|
|
|
|
selectedDetails(computedValue) {
|
|
|
|
return buttonDetails(computedValue);
|
|
|
|
}
|
|
|
|
});
|