feat(wiki): add batch tag remove mode to admin wiki page

Add add/remove toggle to batch tag picker. Clean up unused requireAdmin
import from wiki sync route.
This commit is contained in:
Jennie Robinson Faber 2026-04-09 23:52:00 +01:00
parent a516f172fb
commit 50a358b294
3 changed files with 25 additions and 17 deletions

View file

@ -58,13 +58,17 @@
Select all in "{{ collectionFilter }}"
</button>
<div class="batch-tag-picker">
<select v-model="batchTagToAdd" aria-label="Tag to add" class="batch-select">
<option value="">Add tag...</option>
<select v-model="batchTagMode" aria-label="Batch tag mode" class="batch-select batch-mode-select">
<option value="add">Add</option>
<option value="remove">Remove</option>
</select>
<select v-model="batchTagSelected" :aria-label="batchTagMode === 'add' ? 'Tag to add' : 'Tag to remove'" class="batch-select">
<option value="">Select tag...</option>
<option v-for="tag in availableTags" :key="tag.slug" :value="tag.slug">{{ tag.label }}</option>
</select>
<button
class="btn btn-primary"
:disabled="!batchTagToAdd || batchApplying"
:disabled="!batchTagSelected || batchApplying"
@click="applyBatchTag"
>
{{ batchApplying ? 'Applying...' : 'Apply' }}
@ -402,27 +406,31 @@ const saveArticleTags = async () => {
}
// ---- Batch Tagging ----
const batchTagToAdd = ref('')
const batchTagMode = ref('add')
const batchTagSelected = ref('')
const batchApplying = ref(false)
const applyBatchTag = async () => {
if (!batchTagToAdd.value || !selectedIds.value.length) return
if (!batchTagSelected.value || !selectedIds.value.length) return
batchApplying.value = true
try {
const body = { articleIds: selectedIds.value }
if (batchTagMode.value === 'add') {
body.addTags = [batchTagSelected.value]
} else {
body.removeTags = [batchTagSelected.value]
}
const result = await $fetch('/api/admin/wiki/batch-tag', {
method: 'POST',
body: {
articleIds: selectedIds.value,
addTags: [batchTagToAdd.value],
},
body,
})
await refresh()
const action = batchTagMode.value === 'add' ? 'added to' : 'removed from'
toast.add({
title: 'Batch tag applied',
description: `${result.modified} articles updated`,
title: `Tag ${action} ${result.modified} articles`,
color: 'green',
})
batchTagToAdd.value = ''
batchTagSelected.value = ''
selectedIds.value = []
} catch (err) {
toast.add({
@ -553,6 +561,11 @@ const applyBatchTag = async () => {
outline: none;
}
.batch-mode-select {
width: auto;
min-width: 80px;
}
/* ---- TABLE ---- */
.table-wrap {
padding: 0 28px 24px;