2017-11-21 18:53:09 +08:00
|
|
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
2018-10-02 12:34:08 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2017-11-21 18:53:09 +08:00
|
|
|
const { makeArray } = Ember;
|
|
|
|
|
|
|
|
export default MultiSelectComponent.extend({
|
|
|
|
pluginApiIdentifiers: ["admin-group-selector"],
|
|
|
|
classNames: "admin-group-selector",
|
|
|
|
selected: null,
|
|
|
|
available: null,
|
|
|
|
allowAny: false,
|
2018-10-02 12:34:08 +08:00
|
|
|
buffer: null,
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2018-10-02 12:34:08 +08:00
|
|
|
@computed("buffer")
|
|
|
|
values(buffer) {
|
|
|
|
return buffer === null
|
|
|
|
? makeArray(this.get("selected")).map(s => this.valueForContentItem(s))
|
|
|
|
: buffer;
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
computeContent() {
|
|
|
|
return makeArray(this.get("available"));
|
|
|
|
},
|
|
|
|
|
|
|
|
computeContentItem(contentItem, name) {
|
2018-03-22 18:29:55 +08:00
|
|
|
let computedContentItem = this._super(contentItem, name);
|
|
|
|
computedContentItem.locked = contentItem.automatic;
|
|
|
|
return computedContentItem;
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
mutateValues(values) {
|
2018-10-02 12:34:08 +08:00
|
|
|
this.set("buffer", values);
|
2017-11-21 18:53:09 +08:00
|
|
|
}
|
|
|
|
});
|