2017-11-21 18:53:09 +08:00
|
|
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/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
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("buffer")
|
2018-10-02 12:34:08 +08:00
|
|
|
values(buffer) {
|
|
|
|
return buffer === null
|
2019-05-27 16:15:39 +08:00
|
|
|
? makeArray(this.selected).map(s => this.valueForContentItem(s))
|
2018-10-02 12:34:08 +08:00
|
|
|
: buffer;
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
computeContent() {
|
2019-05-27 16:15:39 +08:00
|
|
|
return makeArray(this.available);
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|