Allow removing authors with no books

This commit is contained in:
Tiberiu Ichim 2026-02-12 19:21:25 +02:00
parent 771f8c586f
commit fc97b10f58
4 changed files with 127 additions and 16 deletions

View file

@ -25,6 +25,18 @@
</div>
</div>
</div>
<div v-if="isBookLibrary" class="w-full border border-black-200 p-4 my-8">
<div class="flex flex-wrap items-center">
<div>
<p class="text-lg">{{ $strings.LabelCleanupAuthors }}</p>
<p class="max-w-sm text-sm pt-2 text-gray-300">{{ $strings.LabelCleanupAuthorsHelp }}</p>
</div>
<div class="grow" />
<div>
<ui-btn @click.stop="cleanupAuthorsClick">{{ $strings.ButtonRemove }}</ui-btn>
</div>
</div>
</div>
</div>
</template>
@ -114,6 +126,38 @@ export default {
.finally(() => {
this.$emit('update:processing', false)
})
},
cleanupAuthorsClick() {
const payload = {
message: this.$strings.MessageConfirmCleanupAuthors,
persistent: true,
callback: (confirmed) => {
if (confirmed) {
this.cleanupAuthors()
}
},
type: 'yesNo'
}
this.$store.commit('globals/setConfirmPrompt', payload)
},
cleanupAuthors() {
this.$emit('update:processing', true)
this.$axios
.$delete(`/api/libraries/${this.libraryId}/authors/cleanup?force=1`)
.then((data) => {
if (data.removed) {
this.$toast.success(this.$getString('ToastCleanupAuthorsSuccess', [data.removed]))
} else {
this.$toast.info(this.$strings.ToastCleanupAuthorsNoAuthors)
}
})
.catch((error) => {
console.error('Failed to cleanup authors', error)
this.$toast.error(this.$strings.ToastCleanupAuthorsFailed)
})
.finally(() => {
this.$emit('update:processing', false)
})
}
},
mounted() {}