-
+
+
+
{{ getTaggedMonitorCount(tag) }}
-
+
@@ -162,12 +184,6 @@ export default {
Status,
Tag,
},
- props: {
- filterState: {
- type: Object,
- required: true,
- }
- },
emits: [ "updateFilter" ],
data() {
return {
@@ -176,72 +192,68 @@ export default {
},
computed: {
numFiltersActive() {
- let num = 0;
-
- Object.values(this.filterState).forEach(item => {
- if (item != null && item.length > 0) {
- num += 1;
- }
- });
-
- return num;
+ return this.$router.currentRoute.value.query.status?.length > 0 ? 1 : 0 +
+ this.$router.currentRoute.value.query.active?.length > 0 ? 1 : 0 +
+ this.$router.currentRoute.value.query.tags?.length > 0 ? 1 : 0;
}
},
mounted() {
this.getExistingTags();
},
methods: {
+ getActiveFilters: function () {
+ const filters = this.$router.currentRoute.value.query;
+
+ return {
+ status: filters["status"] ? filters["status"].split(",") : [],
+ active: filters["active"] ? filters["active"].split(",") : [],
+ tags: filters["tags"] ? filters["tags"].split(",") : [],
+ };
+ },
toggleStatusFilter(status) {
let newFilter = {
- ...this.filterState
+ ...this.getActiveFilters(),
};
- if (newFilter.status == null) {
- newFilter.status = [ status ];
+ if (newFilter.status.includes("" + status)) {
+ newFilter.status = newFilter.status.filter(item => item !== "" + status);
} else {
- if (newFilter.status.includes(status)) {
- newFilter.status = newFilter.status.filter(item => item !== status);
- } else {
- newFilter.status.push(status);
- }
+ newFilter.status.push(status);
}
+
this.$emit("updateFilter", newFilter);
},
toggleActiveFilter(active) {
let newFilter = {
- ...this.filterState
+ ...this.getActiveFilters(),
};
- if (newFilter.active == null) {
- newFilter.active = [ active ];
+ if (newFilter.active.includes("" + active)) {
+ newFilter.active = newFilter.active.filter(item => item !== "" + active);
} else {
- if (newFilter.active.includes(active)) {
- newFilter.active = newFilter.active.filter(item => item !== active);
- } else {
- newFilter.active.push(active);
- }
+ newFilter.active.push(active);
}
+
this.$emit("updateFilter", newFilter);
},
toggleTagFilter(tag) {
let newFilter = {
- ...this.filterState
+ ...this.getActiveFilters(),
};
- if (newFilter.tags == null) {
- newFilter.tags = [ tag.id ];
+ if (newFilter.tags.includes("" + tag.id)) {
+ newFilter.tags = newFilter.tags.filter(item => item !== "" + tag.id);
} else {
- if (newFilter.tags.includes(tag.id)) {
- newFilter.tags = newFilter.tags.filter(item => item !== tag.id);
- } else {
- newFilter.tags.push(tag.id);
- }
+ newFilter.tags.push(tag.id);
}
+
this.$emit("updateFilter", newFilter);
},
clearFilters() {
this.$emit("updateFilter", {
- status: null,
+ status: undefined,
+ active: undefined,
+ tags: undefined,
});
},
getExistingTags() {
diff --git a/src/components/TagEditDialog.vue b/src/components/TagEditDialog.vue
index 77fce2609..c09658c49 100644
--- a/src/components/TagEditDialog.vue
+++ b/src/components/TagEditDialog.vue
@@ -17,11 +17,15 @@
v-model="tag.name"
type="text"
class="form-control"
- :class="{'is-invalid': nameInvalid}"
+ :class="{'is-invalid': nameInvalid || nameContainsComma}"
required
>
- {{ $t("Tag with this name already exist.") }}
+ {{
+ nameInvalid
+ ? $t("Tag with this name already exist.")
+ : $t("Tag name contains a comma.")
+ }}
@@ -160,6 +164,7 @@ export default {
addingMonitor: [],
selectedAddMonitor: null,
nameInvalid: false,
+ nameContainsComma: false,
};
},
@@ -260,6 +265,13 @@ export default {
this.nameInvalid = true;
return false;
}
+
+ this.nameContainsComma = false;
+ if (this.tag?.name?.includes(",")) {
+ this.nameContainsComma = true;
+ return false;
+ }
+
return true;
},
diff --git a/src/lang/en.json b/src/lang/en.json
index e215f1031..5d6c972e0 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -190,6 +190,7 @@
"Add New below or Select...": "Add New below or Select…",
"Tag with this name already exist.": "Tag with this name already exists.",
"Tag with this value already exist.": "Tag with this value already exists.",
+ "Tag name contains a comma.": "Tag name contains a comma.",
"color": "Color",
"value (optional)": "value (optional)",
"Gray": "Gray",