FIX: manually adds tag if existing but not in returned matches

This commit is contained in:
Joffrey JAFFEUX 2018-04-02 18:33:46 +02:00 committed by GitHub
parent f71a18facd
commit 5685b45fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View File

@ -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) {

View File

@ -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;
}
});

View File

@ -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;
},
});