2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

select-kit initial plugin api implementation (0.8.13)

```
api.modifySelectKit("identifier-of-the-select-targeted")
  .modifyContent((context, existingContent) => {})
  .appendContent(() => {})
  .prependContent(() => {})
  .onSelect((context, val) => {});
```
This commit is contained in:
Joffrey JAFFEUX 2017-11-22 10:34:12 +01:00 committed by GitHub
parent 211dac6f71
commit b2b565c2fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 88 additions and 25 deletions

View file

@ -1,10 +1,12 @@
const { isNone, run, makeArray } = Ember;
const { isNone, makeArray } = Ember;
import computed from "ember-addons/ember-computed-decorators";
import UtilsMixin from "select-kit/mixins/utils";
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 } from "select-kit/mixins/plugin-api";
import {
applyContentPluginApiCallbacks
} from "select-kit/mixins/plugin-api";
export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixin, EventsMixin, {
pluginApiIdentifiers: ["select-kit"],
@ -81,7 +83,7 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
willComputeContent(content) { return content; },
computeContent(content) { return content; },
_beforeDidComputeContent(content) {
content = applyContentPluginApiCallbacks(this.get("pluginApiIdentifiers"), content);
content = applyContentPluginApiCallbacks(this.get("pluginApiIdentifiers"), content, this);
const existingCreatedComputedContent = this.get("computedContent").filterBy("created", true);
this.setProperties({
@ -91,16 +93,6 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
},
didComputeContent() {},
mutateAttributes() {
run.next(() => {
this.mutateContent(this.get("computedContent"));
this.mutateValue(this.get("computedValue"));
this.set("headerComputedContent", this.computeHeaderContent());
});
},
mutateContent() {},
mutateValue(computedValue) { this.set("value", computedValue); },
computeHeaderContent() {
return this.baseHeaderComputedContent();
},