Fix: Tag Interface Delete Button #104256
@ -11,7 +11,12 @@
|
||||
|
||||
<div class="action-buttons">
|
||||
<form @submit="createTag">
|
||||
<input type="text" name="newtagname" v-model="newTagName" placeholder="New Tag Name">
|
||||
<input
|
||||
type="text"
|
||||
name="newtagname"
|
||||
v-model="newTagName"
|
||||
placeholder="New Tag Name"
|
||||
/>
|
||||
<button type="submit">Create Tag</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -105,8 +110,8 @@
|
||||
<script>
|
||||
import { useWorkers } from "@/stores/workers";
|
||||
import { useNotifs } from "@/stores/notifications";
|
||||
import { WorkerMgtApi } from '@/manager-api';
|
||||
import { WorkerTag } from '@/manager-api';
|
||||
import { WorkerMgtApi } from "@/manager-api";
|
||||
import { WorkerTag } from "@/manager-api";
|
||||
import { getAPIClient } from "@/api-client";
|
||||
import TabItem from "@/components/TabItem.vue";
|
||||
import TabsWrapper from "@/components/TabsWrapper.vue";
|
||||
@ -134,7 +139,8 @@ export default {
|
||||
|
||||
methods: {
|
||||
fetchTags() {
|
||||
this.workers.refreshTags()
|
||||
this.workers
|
||||
.refreshTags()
|
||||
.then(() => {
|
||||
this.tags = this.workers.tags;
|
||||
})
|
||||
@ -150,7 +156,8 @@ export default {
|
||||
const api = new WorkerMgtApi(getAPIClient());
|
||||
const newTag = new WorkerTag(this.newTagName);
|
||||
|
||||
api.createWorkerTag(newTag)
|
||||
api
|
||||
.createWorkerTag(newTag)
|
||||
.then(this.fetchTags)
|
||||
.catch((error) => {
|
||||
const errorMsg = JSON.stringify(error);
|
||||
@ -166,10 +173,20 @@ export default {
|
||||
return;
|
||||
}
|
||||
// Find the index of the selected tag in the tags array
|
||||
const index = this.tags.findIndex((tag) => tag === this.selectedTag);
|
||||
const index = this.tags.findIndex((tag) => tag.id === this.selectedTag.id);
|
||||
if (index !== -1) {
|
||||
this.tags.splice(index, 1);
|
||||
this.selectedTag = null;
|
||||
const api = new WorkerMgtApi(getAPIClient());
|
||||
|
||||
api
|
||||
.deleteWorkerTag(this.selectedTag.id)
|
||||
.then(() => {
|
||||
this.tags.splice(index, 1);
|
||||
this.selectedTag = null;
|
||||
})
|
||||
.catch((error) => {
|
||||
const errorMsg = JSON.stringify(error);
|
||||
useNotifs().add(`Error: ${errorMsg}`);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user