2017-11-21 18:53:09 +08:00
|
|
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
2018-03-22 18:29:55 +08:00
|
|
|
const { isNone, makeArray } = Ember;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
|
|
export default MultiSelectComponent.extend({
|
|
|
|
pluginApiIdentifiers: ["list-setting"],
|
|
|
|
classNames: "list-setting",
|
|
|
|
tokenSeparator: "|",
|
|
|
|
settingValue: "",
|
|
|
|
choices: null,
|
|
|
|
filterable: true,
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super();
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
if (!isNone(this.get("settingName"))) {
|
2017-11-21 18:53:09 +08:00
|
|
|
this.set("nameProperty", this.get("settingName"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.get("nameProperty").indexOf("color") > -1) {
|
2018-09-12 18:19:04 +08:00
|
|
|
this.get("headerComponentOptions").setProperties({
|
|
|
|
selectedNameComponent: "multi-select/selected-color"
|
|
|
|
});
|
2017-11-21 18:53:09 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computeContent() {
|
|
|
|
let content;
|
2018-03-22 18:29:55 +08:00
|
|
|
if (isNone(this.get("choices"))) {
|
2018-06-15 23:03:24 +08:00
|
|
|
content = this.get("settingValue").split(this.get("tokenSeparator"));
|
|
|
|
} else {
|
2017-11-21 18:53:09 +08:00
|
|
|
content = this.get("choices");
|
|
|
|
}
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
return makeArray(content).filter(c => c);
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
mutateValues(values) {
|
|
|
|
this.set("settingValue", values.join(this.get("tokenSeparator")));
|
|
|
|
},
|
|
|
|
|
|
|
|
computeValues() {
|
|
|
|
return this.get("settingValue")
|
2018-06-15 23:03:24 +08:00
|
|
|
.split(this.get("tokenSeparator"))
|
|
|
|
.filter(c => c);
|
2017-11-21 18:53:09 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
_handleTabOnKeyDown(event) {
|
|
|
|
if (this.$highlightedRow().length === 1) {
|
|
|
|
this._super(event);
|
|
|
|
} else {
|
|
|
|
this.close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|