Update:Series page toolbar add context menu and confirm dialog for marking series as finished

This commit is contained in:
advplyr 2022-12-31 14:56:18 -06:00
parent d8ee61bfab
commit 6bfa281dc5

View File

@ -50,18 +50,8 @@
</div> </div>
<div class="flex-grow" /> <div class="flex-grow" />
<ui-checkbox v-if="!isBatchSelecting" v-model="settings.collapseBookSeries" :label="$strings.LabelCollapseSeries" checkbox-bg="bg" check-color="white" small class="mr-2" @input="updateCollapseBookSeries" /> <ui-checkbox v-if="!isBatchSelecting" v-model="settings.collapseBookSeries" :label="$strings.LabelCollapseSeries" checkbox-bg="bg" check-color="white" small class="mr-2" @input="updateCollapseBookSeries" />
<ui-btn v-if="!isBatchSelecting" color="primary" small :loading="processingSeries" class="items-center ml-1 sm:ml-4 hidden md:flex" @click="markSeriesFinished">
<div class="h-5 w-5"> <ui-context-menu-dropdown v-if="!isBatchSelecting && seriesContextMenuItems.length" :items="seriesContextMenuItems" class="mx-px" @action="seriesContextMenuAction" />
<svg v-if="isSeriesFinished" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="rgb(63, 181, 68)">
<path d="M19 1H5c-1.1 0-1.99.9-1.99 2L3 15.93c0 .69.35 1.3.88 1.66L12 23l8.11-5.41c.53-.36.88-.97.88-1.66L21 3c0-1.1-.9-2-2-2zm-9 15l-5-5 1.41-1.41L10 13.17l7.59-7.59L19 7l-9 9z" />
</svg>
<svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M19 1H5c-1.1 0-1.99.9-1.99 2L3 15.93c0 .69.35 1.3.88 1.66L12 23l8.11-5.41c.53-.36.88-.97.88-1.66L21 3c0-1.1-.9-2-2-2zm-7 19.6l-7-4.66V3h14v12.93l-7 4.67zm-2.01-7.42l-2.58-2.59L6 12l4 4 8-8-1.42-1.42z" />
</svg>
</div>
<span class="pl-2"> {{ $strings.LabelMarkSeries }} {{ isSeriesFinished ? $strings.LabelNotFinished : $strings.LabelFinished }}</span>
</ui-btn>
<ui-btn v-if="isSeriesRemovedFromContinueListening && !isBatchSelecting" small :loading="processingSeries" @click="reAddSeriesToContinueListening" class="hidden md:block ml-2"> Re-Add Series to Continue Listening </ui-btn>
</template> </template>
<!-- library & collections page --> <!-- library & collections page -->
<template v-else-if="page !== 'search' && page !== 'podcast-search' && page !== 'recent-episodes' && !isHome"> <template v-else-if="page !== 'search' && page !== 'podcast-search' && page !== 'recent-episodes' && !isHome">
@ -114,10 +104,42 @@ export default {
totalEntities: 0, totalEntities: 0,
processingSeries: false, processingSeries: false,
processingIssues: false, processingIssues: false,
processingAuthors: false processingAuthors: false,
contextMenuItems: [
{
text: 'cat',
action: 'dog'
}
]
} }
}, },
computed: { computed: {
seriesContextMenuItems() {
if (!this.selectedSeries) return []
const items = [
{
text: this.isSeriesFinished ? 'Mark series as not finished' : 'Mark series as finished',
action: 'mark-series-finished'
}
]
if (this.userIsAdminOrUp || this.selectedSeries.rssFeed) {
items.push({
text: this.$strings.LabelOpenRSSFeed,
action: 'open-rss-feed'
})
}
if (this.isSeriesRemovedFromContinueListening) {
items.push({
text: 'Re-Add Series to Continue Listening',
action: 're-add-to-continue-listening'
})
}
return items
},
seriesSortItems() { seriesSortItems() {
return [ return [
{ {
@ -229,6 +251,23 @@ export default {
} }
}, },
methods: { methods: {
seriesContextMenuAction(action) {
if (action === 'open-rss-feed') {
// TODO: Open RSS Feed
} else if (action === 're-add-to-continue-listening') {
if (this.processingSeries) {
console.warn('Already processing series')
return
}
this.reAddSeriesToContinueListening()
} else if (action === 'mark-series-finished') {
if (this.processingSeries) {
console.warn('Already processing series')
return
}
this.markSeriesFinished()
}
},
reAddSeriesToContinueListening() { reAddSeriesToContinueListening() {
this.processingSeries = true this.processingSeries = true
this.$axios this.$axios
@ -293,9 +332,16 @@ export default {
} }
}, },
markSeriesFinished() { markSeriesFinished() {
var newIsFinished = !this.isSeriesFinished const newIsFinished = !this.isSeriesFinished
const message = newIsFinished ? 'Are you sure you want to mark all books in this series as finished?' : 'Are you sure you want to reset your progress on all books in this series?'
const payload = {
message,
callback: (confirmed) => {
if (confirmed) {
this.processingSeries = true this.processingSeries = true
var updateProgressPayloads = this.seriesLibraryItemIds.map((lid) => { const updateProgressPayloads = this.seriesLibraryItemIds.map((lid) => {
return { return {
libraryItemId: lid, libraryItemId: lid,
isFinished: newIsFinished isFinished: newIsFinished
@ -314,6 +360,11 @@ export default {
console.error('Failed to batch update read/not read', error) console.error('Failed to batch update read/not read', error)
this.processingSeries = false this.processingSeries = false
}) })
}
},
type: 'yesNo'
}
this.$store.commit('globals/setConfirmPrompt', payload)
}, },
updateOrder() { updateOrder() {
this.saveSettings() this.saveSettings()