discourse/app/assets/javascripts/select-kit/components/notifications-button.js.es6
Joffrey JAFFEUX d48542796e
FIX: select-kit refactoring
- improve mini-tag-chooser keyboard behavior
- all multil select now respond to select all and left/right arrows
- improve events handling
- many minor tweaks
2018-03-22 11:29:55 +01:00

44 lines
1.4 KiB
JavaScript

import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
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,
castInteger: true,
autofilterable: false,
filterable: false,
rowComponent: "notifications-button/notifications-button-row",
allowInitialValueMutation: false,
i18nPrefix: "",
i18nPostfix: "",
@computed("iconForSelectedDetails")
headerIcon(iconForSelectedDetails) { return iconForSelectedDetails; },
iconForSelectedDetails: Ember.computed.alias("selectedDetails.icon"),
computeHeaderContent() {
let content = this._super();
content.name = I18n.t(`${this.get("i18nPrefix")}.${this.get("selectedDetails.key")}.title`);
content.hasSelection = this.get("hasSelection");
return content;
},
@on("didReceiveAttrs")
_setNotificationsButtonComponentOptions() {
this.get("rowComponentOptions").setProperties({
i18nPrefix: this.get("i18nPrefix"),
i18nPostfix: this.get("i18nPostfix")
});
},
@computed("computedValue")
selectedDetails(computedValue) {
return buttonDetails(computedValue);
}
});