mirror of
https://github.com/discourse/discourse.git
synced 2025-02-08 17:12:46 +08:00
![Joffrey JAFFEUX](/assets/img/avatar_default.png)
* renames `select-box-kit` into `select-kit` * introduces `single-select` and `multi-select` as base components * introduces {{search-advanced-category-chooser}} as a better component for selecting category in advanced search * improves events handling in select-kit * recreates color selection inputs using {{multi-select}} and a custom {{selected-color}} component * replaces category-selector by a component using select-kit and based on multi-select * improves positioning of wrapper * removes the need for offscreen, and instead use `select-kit-header` as a base focus point for all select-kit based components * introduces a formal plugin api for select-kit based components * introduces a formal pattern for loading and updating select-kit based components: ``` computeValue() computeContent() mutateValue() ```
46 lines
1.4 KiB
JavaScript
46 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,
|
|
collectionHeight: "auto",
|
|
castInteger: true,
|
|
autofilterable: false,
|
|
filterable: false,
|
|
rowComponent: "notifications-button/notifications-button-row",
|
|
allowInitialValueMutation: false,
|
|
i18nPrefix: "",
|
|
i18nPostfix: "",
|
|
|
|
@computed("iconForSelectedDetails")
|
|
headerIcon(iconForSelectedDetails) { return iconForSelectedDetails; },
|
|
|
|
@computed("selectedDetails.icon")
|
|
iconForSelectedDetails(icon) { return icon; },
|
|
|
|
computeHeaderContent() {
|
|
let content = this.baseHeaderComputedContent();
|
|
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);
|
|
}
|
|
});
|