feat: add remove functionality to tag view, add confirm alert

This commit is contained in:
Christoph Kluge 2025-04-23 15:01:12 +02:00
parent 543ddf540e
commit 1b3a12a4dc

View File

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