mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:54:33 +08:00
FIX: adds select-kit api to modify header computed content (#5476)
This api would allow to simply modify header text or icons, eg: ``` api.modifySelectKit("select-kit") .modifyHeaderComputedContent((context, computedContent) => { computedContent.title = "Not so evil"; return computedContent; }); ```
This commit is contained in:
@ -45,7 +45,7 @@ export default SelectKitComponent.extend({
|
||||
values = this.willComputeValues(values);
|
||||
values = this.computeValues(values);
|
||||
values = this._beforeDidComputeValues(values);
|
||||
this.set("headerComputedContent", this.computeHeaderContent());
|
||||
this._setHeaderComputedContent();
|
||||
this.didComputeContent(content);
|
||||
this.didComputeValues(values);
|
||||
this.didComputeAttributes();
|
||||
@ -86,7 +86,7 @@ export default SelectKitComponent.extend({
|
||||
this.mutateContent(this.get("computedContent"));
|
||||
this.mutateValues(this.get("computedValues"));
|
||||
applyOnSelectPluginApiCallbacks(this.get("pluginApiIdentifiers"), this.get("computedValues"), this);
|
||||
this.set("headerComputedContent", this.computeHeaderContent());
|
||||
this._setHeaderComputedContent();
|
||||
});
|
||||
},
|
||||
mutateValues(computedValues) {
|
||||
|
@ -5,7 +5,8 @@ import DomHelpersMixin from "select-kit/mixins/dom-helpers";
|
||||
import EventsMixin from "select-kit/mixins/events";
|
||||
import PluginApiMixin from "select-kit/mixins/plugin-api";
|
||||
import {
|
||||
applyContentPluginApiCallbacks
|
||||
applyContentPluginApiCallbacks,
|
||||
applyHeaderContentPluginApiCallbacks
|
||||
} from "select-kit/mixins/plugin-api";
|
||||
|
||||
export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixin, EventsMixin, {
|
||||
@ -224,6 +225,15 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
|
||||
this.setProperties({ filter: "" });
|
||||
},
|
||||
|
||||
_setHeaderComputedContent() {
|
||||
const headerComputedContent = applyHeaderContentPluginApiCallbacks(
|
||||
this.get("pluginApiIdentifiers"),
|
||||
this.computeHeaderContent(),
|
||||
this
|
||||
);
|
||||
this.set("headerComputedContent", headerComputedContent);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onToggle() {
|
||||
if (this.get("onToggle")) this.sendAction("onToggle");
|
||||
@ -231,6 +241,8 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
|
||||
if (this.get("onExpand") && this.get("isExpanded") === false) this.sendAction("onExpand");
|
||||
|
||||
this.get("isExpanded") === true ? this.collapse() : this.expand();
|
||||
|
||||
this._setHeaderComputedContent();
|
||||
},
|
||||
|
||||
onHighlight(rowComputedContent) {
|
||||
|
@ -26,7 +26,7 @@ export default SelectKitComponent.extend({
|
||||
value = this._beforeDidComputeValue(value);
|
||||
this.didComputeContent(content);
|
||||
this.didComputeValue(value);
|
||||
this.set("headerComputedContent", this.computeHeaderContent());
|
||||
this._setHeaderComputedContent();
|
||||
this.didComputeAttributes();
|
||||
|
||||
if (this.get("allowInitialValueMutation")) this.mutateAttributes();
|
||||
@ -40,7 +40,7 @@ export default SelectKitComponent.extend({
|
||||
this.mutateContent(this.get("computedContent"));
|
||||
this.mutateValue(this.get("computedValue"));
|
||||
applyOnSelectPluginApiCallbacks(this.get("pluginApiIdentifiers"), this.get("computedValue"), this);
|
||||
this.set("headerComputedContent", this.computeHeaderContent());
|
||||
this._setHeaderComputedContent();
|
||||
});
|
||||
},
|
||||
mutateContent() {},
|
||||
|
Reference in New Issue
Block a user