diff --git a/src/components/TagEditDialog.vue b/src/components/TagEditDialog.vue
index b77e1286f..795589947 100644
--- a/src/components/TagEditDialog.vue
+++ b/src/components/TagEditDialog.vue
@@ -12,7 +12,17 @@
@@ -112,7 +122,11 @@ export default {
updated: {
type: Function,
default: () => {},
- }
+ },
+ existingTags: {
+ type: Array,
+ default: () => [],
+ },
},
data() {
return {
@@ -132,6 +146,7 @@ export default {
removingMonitor: [],
addingMonitor: [],
selectedAddMonitor: null,
+ nameInvalid: false,
};
},
@@ -165,6 +180,11 @@ export default {
this.selectedColor.color = to;
}
},
+ "tag.name"(to, from) {
+ if (to != null) {
+ this.validate();
+ }
+ },
selectedColor(to, from) {
if (to != null) {
this.tag.color = to.color;
@@ -212,6 +232,20 @@ export default {
this.addingMonitor = [];
},
+ /**
+ * Check for existing tags of the same name, set invalid input
+ * @returns {boolean} True if editing tag is valid
+ */
+ validate() {
+ this.nameInvalid = false;
+ const sameName = this.existingTags.find((existingTag) => existingTag.name === this.tag.name);
+ if (sameName != null && sameName.id !== this.tag.id) {
+ this.nameInvalid = true;
+ return false;
+ }
+ return true;
+ },
+
/**
* Load tag information for display in the edit dialog
* @param {Object} tag tag object to edit
@@ -243,6 +277,11 @@ export default {
this.processing = true;
let editResult = true;
+ if (!this.validate()) {
+ this.processing = false;
+ return;
+ }
+
if (this.tag.id == null) {
await this.addTagAsync(this.tag).then((res) => {
if (!res.ok) {
diff --git a/src/components/settings/Tags.vue b/src/components/settings/Tags.vue
index d54d0c49e..71ad9b7bd 100644
--- a/src/components/settings/Tags.vue
+++ b/src/components/settings/Tags.vue
@@ -23,7 +23,7 @@
-