@@ -138,7 +138,7 @@
-
+
@@ -207,16 +207,51 @@ export default {
},
computed: {
tagOptions() {
- const tagOptions = this.existingTags;
+ const tagOptions = [ ...this.existingTags ]; // Create a copy
+
+ // Add tags from newTags
for (const tag of this.newTags) {
if (!tagOptions.find(t => t.name === tag.name && t.color === tag.color)) {
tagOptions.push(tag);
}
}
+
+ // Add newly created system tags from staging area
+ for (const stagedTag of this.stagedForBatchAdd) {
+ if (stagedTag.isNewSystemTag) {
+ // Check if this system tag is already in the options
+ if (!tagOptions.find(t => t.name === stagedTag.name && t.color === stagedTag.color)) {
+ // Create a tag option object for the dropdown
+ tagOptions.push({
+ id: null, // Will be assigned when actually created
+ name: stagedTag.name,
+ color: stagedTag.color
+ });
+ }
+ }
+ }
+
return tagOptions;
},
selectedTags() {
- return this.preSelectedTags.concat(this.newTags).filter(tag => !this.deleteTags.find(monitorTag => monitorTag.tag_id === tag.tag_id));
+ // Helper function to normalize tag values for comparison
+ const normalizeValue = (value) => {
+ if (value === null || value === undefined) {
+ return "";
+ }
+ return String(value).trim();
+ };
+
+ // Helper function to get tag ID from different structures
+ const getTagId = (tag) => tag.tag_id || tag.id;
+
+ return this.preSelectedTags.concat(this.newTags).filter(tag =>
+ !this.deleteTags.find(monitorTag => {
+ const tagIdMatch = getTagId(monitorTag) === getTagId(tag);
+ const valueMatch = normalizeValue(monitorTag.value) === normalizeValue(tag.value);
+ return tagIdMatch && valueMatch;
+ })
+ );
},
/**
* @returns {boolean} True if more new system tags can be staged, false otherwise.