DEV: better detection of new item (#8889)
This commit is contained in:
parent
a0bf2ac313
commit
252989e261
|
@ -87,6 +87,7 @@ export default Component.extend(
|
||||||
hasNoContent: true,
|
hasNoContent: true,
|
||||||
highlighted: null,
|
highlighted: null,
|
||||||
noneItem: null,
|
noneItem: null,
|
||||||
|
newItem: null,
|
||||||
filter: null,
|
filter: null,
|
||||||
|
|
||||||
modifyContent: bind(this, this._modifyContentWrapper),
|
modifyContent: bind(this, this._modifyContentWrapper),
|
||||||
|
@ -224,7 +225,8 @@ export default Component.extend(
|
||||||
|
|
||||||
this.selectKit.setProperties({
|
this.selectKit.setProperties({
|
||||||
hasSelection: !isEmpty(this.value),
|
hasSelection: !isEmpty(this.value),
|
||||||
noneItem: this._modifyNoSelectionWrapper()
|
noneItem: this._modifyNoSelectionWrapper(),
|
||||||
|
newItem: null
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.selectKit.isExpanded) {
|
if (this.selectKit.isExpanded) {
|
||||||
|
@ -563,7 +565,6 @@ export default Component.extend(
|
||||||
}
|
}
|
||||||
|
|
||||||
const noneItem = this.selectKit.noneItem;
|
const noneItem = this.selectKit.noneItem;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.selectKit.options.allowAny &&
|
this.selectKit.options.allowAny &&
|
||||||
filter &&
|
filter &&
|
||||||
|
@ -571,7 +572,8 @@ export default Component.extend(
|
||||||
) {
|
) {
|
||||||
filter = this.createContentFromInput(filter);
|
filter = this.createContentFromInput(filter);
|
||||||
if (this.validateCreate(filter, content)) {
|
if (this.validateCreate(filter, content)) {
|
||||||
content.unshift(this.defaultItem(filter, filter));
|
this.selectKit.set("newItem", this.defaultItem(filter, filter));
|
||||||
|
content.unshift(this.selectKit.newItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +592,7 @@ export default Component.extend(
|
||||||
this.selectKit.setProperties({
|
this.selectKit.setProperties({
|
||||||
highlighted:
|
highlighted:
|
||||||
this.singleSelect && this.value
|
this.singleSelect && this.value
|
||||||
? this.itemForValue(this.value)
|
? this.itemForValue(this.value, this.mainCollection)
|
||||||
: this.mainCollection.firstObject,
|
: this.mainCollection.firstObject,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasNoContent
|
hasNoContent
|
||||||
|
|
|
@ -47,7 +47,8 @@ export default Component.extend(UtilsMixin, {
|
||||||
if (
|
if (
|
||||||
this.selectKit.options.allowAny &&
|
this.selectKit.options.allowAny &&
|
||||||
this.rowValue === this.selectKit.filter &&
|
this.rowValue === this.selectKit.filter &&
|
||||||
this.getName(this.selectKit.noneItem) !== this.rowName
|
this.getName(this.selectKit.noneItem) !== this.rowName &&
|
||||||
|
this.getName(this.selectKit.newItem) === this.rowName
|
||||||
) {
|
) {
|
||||||
return I18n.t("select_kit.create", { content: label });
|
return I18n.t("select_kit.create", { content: label });
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ export default Mixin.create({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
itemForValue(value) {
|
itemForValue(value, content) {
|
||||||
if (this.selectKit.valueProperty) {
|
if (this.selectKit.valueProperty) {
|
||||||
return this.mainCollection.findBy(this.selectKit.valueProperty, value);
|
return content.findBy(this.selectKit.valueProperty, value);
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue