FEATURE: select-kit api to modify collection header

This commit is contained in:
Joffrey JAFFEUX
2018-01-26 14:42:24 +01:00
committed by GitHub
parent 0eb71cef98
commit 56834dbd98
8 changed files with 45 additions and 5 deletions

View File

@@ -46,6 +46,7 @@ export default SelectKitComponent.extend({
values = this.computeValues(values);
values = this._beforeDidComputeValues(values);
this._setHeaderComputedContent();
this._setCollectionHeaderComputedContent();
this.didComputeContent(content);
this.didComputeValues(values);
this.didComputeAttributes();
@@ -85,6 +86,7 @@ export default SelectKitComponent.extend({
Ember.run.next(() => {
this.mutateContent(this.get("computedContent"));
this.mutateValues(this.get("computedValues"));
this._setCollectionHeaderComputedContent();
this._setHeaderComputedContent();
});
},

View File

@@ -7,7 +7,8 @@ import PluginApiMixin from "select-kit/mixins/plugin-api";
import {
applyContentPluginApiCallbacks,
applyHeaderContentPluginApiCallbacks,
applyOnSelectPluginApiCallbacks
applyOnSelectPluginApiCallbacks,
applyCollectionHeaderCallbacks
} from "select-kit/mixins/plugin-api";
export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixin, EventsMixin, {
@@ -51,6 +52,7 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
headerComponent: "select-kit/select-kit-header",
headerComponentOptions: null,
headerComputedContent: null,
collectionHeaderComputedContent: null,
collectionComponent: "select-kit/select-kit-collection",
collectionHeight: 200,
verticalOffset: 0,
@@ -237,6 +239,15 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
this.setProperties({ filter: "" });
},
_setCollectionHeaderComputedContent() {
const collectionHeaderComputedContent = applyCollectionHeaderCallbacks(
this.get("pluginApiIdentifiers"),
this.get("collectionHeader"),
this
);
this.set("collectionHeaderComputedContent", collectionHeaderComputedContent);
},
_setHeaderComputedContent() {
const headerComputedContent = applyHeaderContentPluginApiCallbacks(
this.get("pluginApiIdentifiers"),

View File

@@ -26,6 +26,7 @@ export default SelectKitComponent.extend({
if (this.get("allowInitialValueMutation")) this.mutateAttributes();
this._setCollectionHeaderComputedContent();
this._setHeaderComputedContent();
});
},
@@ -36,6 +37,7 @@ export default SelectKitComponent.extend({
run.next(() => {
this.mutateContent(this.get("computedContent"));
this.mutateValue(this.get("computedValue"));
this._setCollectionHeaderComputedContent();
this._setHeaderComputedContent();
});
},