FIX: reverts combobox placeholder and introduces noneLabel

noneLabels works almost like none but instead of actually adding a row in the list, it will only change the text displayed in the header, when there's no selection.
This commit is contained in:
Joffrey JAFFEUX
2018-03-29 13:42:00 +02:00
committed by GitHub
parent 125434dcdf
commit 3287ac77e0
10 changed files with 41 additions and 23 deletions

View File

@@ -24,11 +24,8 @@ export default SingleSelectComponent.extend({
@on("didReceiveAttrs")
_setComboBoxOptions() {
const placeholder = this.get('placeholder');
this.get("headerComponentOptions").setProperties({
clearable: this.get("clearable"),
placeholder: placeholder ? I18n.t(placeholder) : "",
clearable: this.get("clearable")
});
}
});

View File

@@ -7,6 +7,5 @@ export default SelectKitHeaderComponent.extend({
clearable: Ember.computed.alias("options.clearable"),
caretUpIcon: Ember.computed.alias("options.caretUpIcon"),
caretDownIcon: Ember.computed.alias("options.caretDownIcon"),
shouldDisplayClearableButton: Ember.computed.and("clearable", "computedContent.hasSelection"),
placeholder: Ember.computed.alias("options.placeholder"),
shouldDisplayClearableButton: Ember.computed.and("clearable", "computedContent.hasSelection")
});

View File

@@ -262,7 +262,8 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
@computed("none")
noneRowComputedContent(none) {
if (isNone(none)) { return null; }
if (isNone(none)) return null;
let noneRowComputedContent;
switch (typeof none) {

View File

@@ -4,7 +4,7 @@ const { isEmpty, makeArray } = Ember;
export default Ember.Component.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-header",
classNames: ["select-kit-header"],
classNameBindings: ["isFocused"],
classNameBindings: ["isFocused", "isNone"],
attributeBindings: [
"tabindex",
"ariaLabel:aria-label",
@@ -14,6 +14,8 @@ export default Ember.Component.extend({
"name:data-name",
],
isNone: Ember.computed.none("computedContent.value"),
ariaHasPopup: true,
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),

View File

@@ -84,12 +84,18 @@ export default SelectKitComponent.extend({
},
computeHeaderContent() {
return {
let content = {
title: this.get("title"),
icons: makeArray(this.getWithDefault("headerIcon", [])),
value: this.get("selection.value"),
name: this.get("selection.name") || this.get("noneRowComputedContent.name")
};
if (!this.get("hasSelection") && this.get("noneLabel")) {
content.title = content.name = I18n.t(this.get("noneLabel"));
}
return content;
},
@computed("computedAsyncContent.[]", "computedValue")