Fix: Tag Interface Delete Button #104256
@ -2,12 +2,6 @@
|
|||||||
<div class="col col-tags-list">
|
<div class="col col-tags-list">
|
||||||
<h2 class="column-title">Available Tags</h2>
|
<h2 class="column-title">Available Tags</h2>
|
||||||
|
|
||||||
<div class="action-buttons btn-bar-group">
|
|
||||||
<div class="btn-bar">
|
|
||||||
<button @click="deleteTag" :disabled="!selectedTag">Delete Tag</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="action-buttons btn-bar">
|
<div class="action-buttons btn-bar">
|
||||||
<form @submit="createTag">
|
<form @submit="createTag">
|
||||||
<div class="create-tag-container">
|
<div class="create-tag-container">
|
||||||
@ -126,12 +120,22 @@ export default {
|
|||||||
|
|
||||||
const tag_options = {
|
const tag_options = {
|
||||||
columns: [
|
columns: [
|
||||||
{ title: 'Name', field: 'name', sorter: 'string', editor: 'input' },
|
{
|
||||||
|
title: 'Name',
|
||||||
|
field: 'name',
|
||||||
|
sorter: 'string',
|
||||||
|
editor: 'input',
|
||||||
|
vertAlign: 'center',
|
||||||
|
widthGrow: 1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Description',
|
title: 'Description',
|
||||||
field: 'description',
|
field: 'description',
|
||||||
sorter: 'string',
|
sorter: 'string',
|
||||||
editor: 'input',
|
editor: 'input',
|
||||||
|
vertAlign: 'center',
|
||||||
|
widthGrow: 2,
|
||||||
dr.sybren marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
formatter(cell) {
|
formatter(cell) {
|
||||||
const cellValue = cell.getData().description;
|
const cellValue = cell.getData().description;
|
||||||
if (!cellValue) {
|
if (!cellValue) {
|
||||||
@ -140,15 +144,33 @@ export default {
|
|||||||
return cellValue;
|
return cellValue;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '',
|
||||||
|
headerHozAlign: 'right',
|
||||||
|
width: 60,
|
||||||
|
|
||||||
|
formatter: (cell) => {
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.classList.add('remove-tag-button');
|
||||||
|
button.innerHTML = '❌';
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
const tag = cell.getRow().getData();
|
||||||
|
this.deleteTag(tag);
|
||||||
|
});
|
||||||
|
|
||||||
|
return button;
|
||||||
|
},
|
||||||
|
headerSort: false,
|
||||||
|
vertAlign: 'center',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
layout: 'fitData',
|
layout: 'fitColumns',
|
||||||
dr.sybren marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
Not sure if a fixed width is going to work well here, especially when the window gets resized. Not sure if a fixed width is going to work well here, especially when the window gets resized.
|
|||||||
layoutColumnsOnNewData: true,
|
layoutColumnsOnNewData: true,
|
||||||
height: '82%',
|
height: '82%',
|
||||||
selectable: true,
|
selectable: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.tabulator = new Tabulator('#tag-table-container', tag_options);
|
this.tabulator = new Tabulator('#tag-table-container', tag_options);
|
||||||
this.tabulator.on('rowClick', this.onRowClick);
|
|
||||||
this.tabulator.on('tableBuilt', () => {
|
this.tabulator.on('tableBuilt', () => {
|
||||||
this.fetchTags();
|
this.fetchTags();
|
||||||
});
|
});
|
||||||
@ -211,17 +233,16 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteTag() {
|
deleteTag(tag) {
|
||||||
if (!this.selectedTag) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const api = new WorkerMgtApi(getAPIClient());
|
const api = new WorkerMgtApi(getAPIClient());
|
||||||
api
|
api
|
||||||
.deleteWorkerTag(this.selectedTag.id)
|
.deleteWorkerTag(tag.id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.selectedTag = null;
|
this.tabulator.getRows().forEach((row) => {
|
||||||
this.tabulator.setData(this.tags);
|
if (row.getData().id === tag.id) {
|
||||||
|
row.delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
const errorMsg = JSON.stringify(error);
|
const errorMsg = JSON.stringify(error);
|
||||||
dr.sybren marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
This shouldn't happen anyway, so you can just remove the entire conditional return here. Better to raise an error that you can see & debug (because of the This shouldn't happen anyway, so you can just remove the entire conditional return here. Better to raise an error that you can see & debug (because of the `tag.id` access failing) than to silently ignore mistakes.
|
|||||||
@ -229,17 +250,6 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRowClick(event, row) {
|
|
||||||
const tag = row.getData();
|
|
||||||
const rowIndex = row.getIndex();
|
|
||||||
|
|
||||||
this.tabulator.deselectRow();
|
|
||||||
this.tabulator.selectRow(rowIndex);
|
|
||||||
|
|
||||||
this.selectedTag = tag;
|
|
||||||
this.activeRowIndex = rowIndex;
|
|
||||||
},
|
|
||||||
|
|
||||||
// SocketIO connection event handlers:
|
// SocketIO connection event handlers:
|
||||||
onSIOReconnected() {
|
onSIOReconnected() {
|
||||||
this.fetchTags();
|
this.fetchTags();
|
||||||
|
Loading…
Reference in New Issue
Block a user
Add this column to the end, so that it has the same layout as the job blocklist (there the ❌ is on the right as well).