mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-04-29 14:41:43 +02:00
feat: add remove functionality to tag view, add confirm alert
This commit is contained in:
parent
543ddf540e
commit
1b3a12a4dc
@ -46,23 +46,22 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function removeTag(tag, tagType) {
|
function removeTag(tag, tagType) {
|
||||||
pendingChange = tagType;
|
if (confirm("Are you sure you want to completely remove this tag?\n\n" + tagType + ':' + tag.name)) {
|
||||||
removeTagMutation({tagIds: [tag.id] }).subscribe(
|
pendingChange = tagType;
|
||||||
(res) => {
|
removeTagMutation({tagIds: [tag.id] }).subscribe(
|
||||||
if (res.fetching === false && !res.error) {
|
(res) => {
|
||||||
// console.log('Removed:', res.data.removeTagFromList)
|
if (res.fetching === false && !res.error) {
|
||||||
// console.log('Targets:', tagType, tagmap[tagType])
|
tagmap[tagType] = tagmap[tagType].filter((t) => !res.data.removeTagFromList.includes(t.id));
|
||||||
// console.log('Filter:', tagmap[tagType].filter((t) => !res.data.removeTagFromList.includes(t.id)))
|
if (tagmap[tagType].length === 0) {
|
||||||
tagmap[tagType] = tagmap[tagType].filter((t) => !res.data.removeTagFromList.includes(t.id));
|
delete tagmap[tagType]
|
||||||
if (tagmap[tagType].length === 0) {
|
}
|
||||||
delete tagmap[tagType]
|
pendingChange = "none";
|
||||||
|
} else if (res.fetching === false && res.error) {
|
||||||
|
throw res.error;
|
||||||
}
|
}
|
||||||
pendingChange = "none";
|
},
|
||||||
} else if (res.fetching === false && res.error) {
|
);
|
||||||
throw res.error;
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user