discourse/app/assets/javascripts/select-kit/components/combo-box.js.es6

35 lines
1023 B
Plaintext
Raw Normal View History

import SingleSelectComponent from "select-kit/components/single-select";
import { on, default as computed } from "ember-addons/ember-computed-decorators";
2017-10-20 03:51:08 +08:00
export default SingleSelectComponent.extend({
pluginApiIdentifiers: ["combo-box"],
2017-10-20 03:51:08 +08:00
classNames: "combobox combo-box",
autoFilterable: true,
headerComponent: "combo-box/combo-box-header",
caretUpIcon: "caret-up fa-fw",
caretDownIcon: "caret-down fa-fw",
2017-10-20 03:51:08 +08:00
clearable: false,
computeHeaderContent() {
let content = this._super();
content.hasSelection = this.get("hasSelection");
return content;
},
@computed("isExpanded", "caretUpIcon", "caretDownIcon")
caretIcon(isExpanded, caretUpIcon, caretDownIcon) {
return isExpanded ? caretUpIcon : caretDownIcon;
},
2017-10-20 03:51:08 +08:00
@on("didReceiveAttrs")
_setComboBoxOptions() {
const placeholder = this.get('placeholder');
2017-11-10 02:57:53 +08:00
this.get("headerComponentOptions").setProperties({
2017-10-20 03:51:08 +08:00
clearable: this.get("clearable"),
placeholder: placeholder ? I18n.t(placeholder) : "",
2017-11-10 02:57:53 +08:00
});
2017-10-20 03:51:08 +08:00
}
});