|
|
|
@ -34,7 +34,8 @@
|
|
|
|
|
label="name"
|
|
|
|
|
>
|
|
|
|
|
<template #option="{ option }">
|
|
|
|
|
<div class="mx-2 py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
<div
|
|
|
|
|
class="mx-2 py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
style="margin-top: -5px; margin-bottom: -5px; height: 24px;"
|
|
|
|
|
:style="{ color: textColor(option), backgroundColor: option.color + ' !important' }"
|
|
|
|
|
>
|
|
|
|
@ -43,7 +44,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template #singleLabel="{ option }">
|
|
|
|
|
<div class="py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
<div
|
|
|
|
|
class="py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
style="height: 24px;"
|
|
|
|
|
:style="{ color: textColor(option), backgroundColor: option.color + ' !important' }"
|
|
|
|
|
>
|
|
|
|
@ -53,7 +55,8 @@
|
|
|
|
|
</vue-multiselect>
|
|
|
|
|
<div v-if="newDraftTag.select?.name == null" class="d-flex mb-2">
|
|
|
|
|
<div class="w-50 pe-2">
|
|
|
|
|
<input v-model="newDraftTag.name" class="form-control"
|
|
|
|
|
<input
|
|
|
|
|
v-model="newDraftTag.name" class="form-control"
|
|
|
|
|
:class="{'is-invalid': validateDraftTag.nameInvalid}"
|
|
|
|
|
:placeholder="$t('Name')"
|
|
|
|
|
@keydown.enter.prevent="onEnter"
|
|
|
|
@ -75,7 +78,8 @@
|
|
|
|
|
deselect-label=""
|
|
|
|
|
>
|
|
|
|
|
<template #option="{ option }">
|
|
|
|
|
<div class="mx-2 py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
<div
|
|
|
|
|
class="mx-2 py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
style="height: 24px; color: white;"
|
|
|
|
|
:style="{ backgroundColor: option.color + ' !important' }"
|
|
|
|
|
>
|
|
|
|
@ -83,7 +87,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template #singleLabel="{ option }">
|
|
|
|
|
<div class="py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
<div
|
|
|
|
|
class="py-1 px-3 rounded d-inline-flex"
|
|
|
|
|
style="height: 24px; color: white;"
|
|
|
|
|
:style="{ backgroundColor: option.color + ' !important' }"
|
|
|
|
|
>
|
|
|
|
@ -94,7 +99,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-2">
|
|
|
|
|
<input v-model="newDraftTag.value" class="form-control"
|
|
|
|
|
<input
|
|
|
|
|
v-model="newDraftTag.value" class="form-control"
|
|
|
|
|
:class="{'is-invalid': validateDraftTag.valueInvalid}"
|
|
|
|
|
:placeholder="$t('value (optional)')"
|
|
|
|
|
@keydown.enter.prevent="onEnter"
|
|
|
|
@ -123,8 +129,8 @@
|
|
|
|
|
<script>
|
|
|
|
|
import { Modal } from "bootstrap";
|
|
|
|
|
import VueMultiselect from "vue-multiselect";
|
|
|
|
|
import Tag from "../components/Tag.vue";
|
|
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
|
import Tag from "../components/Tag.vue";
|
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
@ -159,14 +165,14 @@ export default {
|
|
|
|
|
tagOptions() {
|
|
|
|
|
const tagOptions = this.existingTags;
|
|
|
|
|
for (const tag of this.newTags) {
|
|
|
|
|
if (!tagOptions.find(t => t.name == tag.name && t.color == tag.color)) {
|
|
|
|
|
if (!tagOptions.find(t => t.name === tag.name && t.color === tag.color)) {
|
|
|
|
|
tagOptions.push(tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tagOptions;
|
|
|
|
|
},
|
|
|
|
|
selectedTags() {
|
|
|
|
|
return this.preSelectedTags.concat(this.newTags).filter(tag => !this.deleteTags.find(monitorTag => monitorTag.id == tag.id));
|
|
|
|
|
return this.preSelectedTags.concat(this.newTags).filter(tag => !this.deleteTags.find(monitorTag => monitorTag.id === tag.id));
|
|
|
|
|
},
|
|
|
|
|
colorOptions() {
|
|
|
|
|
return [
|
|
|
|
@ -192,7 +198,7 @@ export default {
|
|
|
|
|
let nameInvalid = false;
|
|
|
|
|
let valueInvalid = false;
|
|
|
|
|
let invalid = true;
|
|
|
|
|
if (this.deleteTags.find(tag => tag.name == this.newDraftTag.select?.name && tag.value == this.newDraftTag.value)) {
|
|
|
|
|
if (this.deleteTags.find(tag => tag.name === this.newDraftTag.select?.name && tag.value === this.newDraftTag.value)) {
|
|
|
|
|
// Undo removing a Tag
|
|
|
|
|
nameInvalid = false;
|
|
|
|
|
valueInvalid = false;
|
|
|
|
@ -202,9 +208,9 @@ export default {
|
|
|
|
|
nameInvalid = true;
|
|
|
|
|
invalid = true;
|
|
|
|
|
} else if (this.newTags.concat(this.preSelectedTags).filter(tag => (
|
|
|
|
|
tag.name == this.newDraftTag.select?.name && tag.value == this.newDraftTag.value
|
|
|
|
|
tag.name === this.newDraftTag.select?.name && tag.value === this.newDraftTag.value
|
|
|
|
|
) || (
|
|
|
|
|
tag.name == this.newDraftTag.name && tag.value == this.newDraftTag.value
|
|
|
|
|
tag.name === this.newDraftTag.name && tag.value === this.newDraftTag.value
|
|
|
|
|
)).length > 0) {
|
|
|
|
|
// Try to add a tag with existing name and value
|
|
|
|
|
valueInvalid = true;
|
|
|
|
@ -250,7 +256,7 @@ export default {
|
|
|
|
|
deleteTag(item) {
|
|
|
|
|
if (item.new) {
|
|
|
|
|
// Undo Adding a new Tag
|
|
|
|
|
this.newTags = this.newTags.filter(tag => !(tag.name == item.name && tag.value == item.value));
|
|
|
|
|
this.newTags = this.newTags.filter(tag => !(tag.name === item.name && tag.value === item.value));
|
|
|
|
|
} else {
|
|
|
|
|
// Remove an Existing Tag
|
|
|
|
|
this.deleteTags.push(item);
|
|
|
|
@ -266,9 +272,9 @@ export default {
|
|
|
|
|
addDraftTag() {
|
|
|
|
|
console.log("Adding Draft Tag: ", this.newDraftTag);
|
|
|
|
|
if (this.newDraftTag.select != null) {
|
|
|
|
|
if (this.deleteTags.find(tag => tag.name == this.newDraftTag.select.name && tag.value == this.newDraftTag.value)) {
|
|
|
|
|
if (this.deleteTags.find(tag => tag.name === this.newDraftTag.select.name && tag.value === this.newDraftTag.value)) {
|
|
|
|
|
// Undo removing a tag
|
|
|
|
|
this.deleteTags = this.deleteTags.filter(tag => !(tag.name == this.newDraftTag.select.name && tag.value == this.newDraftTag.value));
|
|
|
|
|
this.deleteTags = this.deleteTags.filter(tag => !(tag.name === this.newDraftTag.select.name && tag.value === this.newDraftTag.value));
|
|
|
|
|
} else {
|
|
|
|
|
// Add an existing Tag
|
|
|
|
|
this.newTags.push({
|
|
|
|
@ -345,7 +351,7 @@ export default {
|
|
|
|
|
tagId = newTagResult.id;
|
|
|
|
|
// Assign the new ID to the tags of the same name & color
|
|
|
|
|
this.newTags.map(tag => {
|
|
|
|
|
if (tag.name == newTag.name && tag.color == newTag.color) {
|
|
|
|
|
if (tag.name === newTag.name && tag.color === newTag.color) {
|
|
|
|
|
tag.id = newTagResult.id;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|