FIX: manually adds tag if existing but not in returned matches
This commit is contained in:
parent
f71a18facd
commit
5685b45fa6
|
@ -169,9 +169,17 @@ export default ComboBox.extend(Tags, {
|
|||
|
||||
results = results.filter(r => !context.get("selection").includes(r.id));
|
||||
|
||||
return results.map(result => {
|
||||
results = results.map(result => {
|
||||
return { id: result.text, name: result.text, count: result.count };
|
||||
});
|
||||
|
||||
// if forbidden we probably have an existing tag which is not in the list of
|
||||
// returned tags, so we manually add it at the top
|
||||
if (json.forbidden) {
|
||||
results.unshift({ id: json.forbidden, name: json.forbidden, count: 0 });
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
|
||||
destroyTags(tags) {
|
||||
|
|
|
@ -108,8 +108,16 @@ export default MultiSelectComponent.extend(Tags, {
|
|||
results = results.sort((a, b) => a.id > b.id);
|
||||
}
|
||||
|
||||
return results.map(result => {
|
||||
results = results.map(result => {
|
||||
return { id: result.text, name: result.text, count: result.count };
|
||||
});
|
||||
|
||||
// if forbidden we probably have an existing tag which is not in the list of
|
||||
// returned tags, so we manually add it at the top
|
||||
if (json.forbidden) {
|
||||
results.unshift({ id: json.forbidden, name: json.forbidden, count: 0 });
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -72,8 +72,16 @@ export default MultiSelectComponent.extend(Tags, {
|
|||
_transformJson(context, json) {
|
||||
let results = json.results.sort((a, b) => a.id > b.id);
|
||||
|
||||
return results.map(result => {
|
||||
results = results.map(result => {
|
||||
return { id: result.text, name: result.text, count: result.count };
|
||||
});
|
||||
|
||||
// if forbidden we probably have an existing tag which is not in the list of
|
||||
// returned tags, so we manually add it at the top
|
||||
if (json.forbidden) {
|
||||
results.unshift({ id: json.forbidden, name: json.forbidden, count: 0 });
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue