mirror of
https://github.com/gotson/komga.git
synced 2026-05-04 18:42:10 +02:00
feat(webui): better handling of library deletion
depending on the current screen, data can be reloaded or redirection to home page
This commit is contained in:
parent
37d790d1fc
commit
0297210dc2
12 changed files with 98 additions and 41 deletions
|
|
@ -53,11 +53,5 @@ export default Vue.extend({
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.list-warning:hover {
|
@import "../styles/list-warning.css";
|
||||||
background: #F44336;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-warning:hover .v-list-item__title {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,25 @@
|
||||||
:collection="deleteCollection"
|
:collection="deleteCollection"
|
||||||
@deleted="collectionDeleted"
|
@deleted="collectionDeleted"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<library-delete-dialog
|
||||||
|
v-model="deleteLibraryDialog"
|
||||||
|
:library="deleteLibrary"
|
||||||
|
@deleted="libraryDeleted"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CollectionAddToDialog from '@/components/CollectionAddToDialog.vue'
|
import CollectionAddToDialog from '@/components/CollectionAddToDialog.vue'
|
||||||
import CollectionDeleteDialog from '@/components/CollectionDeleteDialog.vue'
|
import CollectionDeleteDialog from '@/components/CollectionDeleteDialog.vue'
|
||||||
import { COLLECTION_CHANGED, SERIES_CHANGED } from '@/types/events'
|
import LibraryDeleteDialog from '@/components/LibraryDeleteDialog.vue'
|
||||||
|
import { COLLECTION_CHANGED, LIBRARY_DELETED, SERIES_CHANGED } from '@/types/events'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'Dialogs',
|
name: 'Dialogs',
|
||||||
components: { CollectionAddToDialog, CollectionDeleteDialog },
|
components: { CollectionAddToDialog, CollectionDeleteDialog, LibraryDeleteDialog },
|
||||||
computed: {
|
computed: {
|
||||||
addToCollectionDialog: {
|
addToCollectionDialog: {
|
||||||
get (): boolean {
|
get (): boolean {
|
||||||
|
|
@ -46,6 +53,17 @@ export default Vue.extend({
|
||||||
deleteCollection (): CollectionDto {
|
deleteCollection (): CollectionDto {
|
||||||
return this.$store.state.deleteCollection
|
return this.$store.state.deleteCollection
|
||||||
},
|
},
|
||||||
|
deleteLibraryDialog: {
|
||||||
|
get (): boolean {
|
||||||
|
return this.$store.state.deleteLibraryDialog
|
||||||
|
},
|
||||||
|
set (val) {
|
||||||
|
this.$store.dispatch('dialogDeleteLibraryDisplay', val)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
deleteLibrary (): LibraryDto {
|
||||||
|
return this.$store.state.deleteLibrary
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
collectionAdded () {
|
collectionAdded () {
|
||||||
|
|
@ -67,6 +85,11 @@ export default Vue.extend({
|
||||||
collectionDeleted () {
|
collectionDeleted () {
|
||||||
this.$eventHub.$emit(COLLECTION_CHANGED)
|
this.$eventHub.$emit(COLLECTION_CHANGED)
|
||||||
},
|
},
|
||||||
|
libraryDeleted () {
|
||||||
|
this.$eventHub.$emit(LIBRARY_DELETED, {
|
||||||
|
id: this.deleteLibrary.id,
|
||||||
|
} as EventLibraryDeleted)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -22,25 +22,13 @@
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
|
|
||||||
<library-delete-dialog v-model="modalDeleteLibrary"
|
|
||||||
:library="library"
|
|
||||||
@deleted="navigateHome"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import LibraryDeleteDialog from '@/components/LibraryDeleteDialog.vue'
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'LibraryActionsMenu',
|
name: 'LibraryActionsMenu',
|
||||||
components: { LibraryDeleteDialog },
|
|
||||||
data: function () {
|
|
||||||
return {
|
|
||||||
modalDeleteLibrary: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
library: {
|
library: {
|
||||||
type: Object as () => LibraryDto,
|
type: Object as () => LibraryDto,
|
||||||
|
|
@ -63,20 +51,11 @@ export default Vue.extend({
|
||||||
this.$komgaLibraries.refreshMetadata(this.library)
|
this.$komgaLibraries.refreshMetadata(this.library)
|
||||||
},
|
},
|
||||||
promptDeleteLibrary () {
|
promptDeleteLibrary () {
|
||||||
this.modalDeleteLibrary = true
|
this.$store.dispatch('dialogDeleteLibrary', this.library)
|
||||||
},
|
|
||||||
navigateHome () {
|
|
||||||
this.$router.push({ name: 'home' })
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.list-warning:hover {
|
@import "../styles/list-warning.css";
|
||||||
background: #F44336;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-warning:hover .v-list-item__title {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ export default new Vuex.Store({
|
||||||
addToCollectionDialog: false,
|
addToCollectionDialog: false,
|
||||||
deleteCollection: {} as CollectionDto,
|
deleteCollection: {} as CollectionDto,
|
||||||
deleteCollectionDialog: false,
|
deleteCollectionDialog: false,
|
||||||
|
deleteLibrary: {} as LibraryDto,
|
||||||
|
deleteLibraryDialog: false,
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setAddToCollectionSeries (state, series) {
|
setAddToCollectionSeries (state, series) {
|
||||||
|
|
@ -23,6 +25,12 @@ export default new Vuex.Store({
|
||||||
setDeleteCollectionDialog (state, dialog) {
|
setDeleteCollectionDialog (state, dialog) {
|
||||||
state.deleteCollectionDialog = dialog
|
state.deleteCollectionDialog = dialog
|
||||||
},
|
},
|
||||||
|
setDeleteLibrary (state, library) {
|
||||||
|
state.deleteLibrary = library
|
||||||
|
},
|
||||||
|
setDeleteLibraryDialog (state, dialog) {
|
||||||
|
state.deleteLibraryDialog = dialog
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
dialogAddSeriesToCollection ({ commit }, series) {
|
dialogAddSeriesToCollection ({ commit }, series) {
|
||||||
|
|
@ -39,5 +47,12 @@ export default new Vuex.Store({
|
||||||
dialogDeleteCollectionDisplay ({ commit }, value) {
|
dialogDeleteCollectionDisplay ({ commit }, value) {
|
||||||
commit('setDeleteCollectionDialog', value)
|
commit('setDeleteCollectionDialog', value)
|
||||||
},
|
},
|
||||||
|
dialogDeleteLibrary ({ commit }, library) {
|
||||||
|
commit('setDeleteLibrary', library)
|
||||||
|
commit('setDeleteLibraryDialog', true)
|
||||||
|
},
|
||||||
|
dialogDeleteLibraryDisplay ({ commit }, value) {
|
||||||
|
commit('setDeleteLibraryDialog', value)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
7
komga-webui/src/styles/list-warning.css
Normal file
7
komga-webui/src/styles/list-warning.css
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
.list-warning:hover {
|
||||||
|
background: #F44336;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-warning:hover .v-list-item__title {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
@ -7,3 +7,7 @@ interface EventSeriesChanged {
|
||||||
id: number,
|
id: number,
|
||||||
libraryId: number
|
libraryId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EventLibraryDeleted {
|
||||||
|
id: number
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
export const BOOK_CHANGED = 'book-changed'
|
export const BOOK_CHANGED = 'book-changed'
|
||||||
export const SERIES_CHANGED = 'series-changed'
|
export const SERIES_CHANGED = 'series-changed'
|
||||||
export const COLLECTION_CHANGED = 'collection-changed'
|
export const COLLECTION_CHANGED = 'collection-changed'
|
||||||
|
export const LIBRARY_DELETED = 'library-deleted'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
interface BookDto {
|
interface BookDto {
|
||||||
id: number,
|
id: number,
|
||||||
seriesId: number,
|
seriesId: number,
|
||||||
|
libraryId: number,
|
||||||
name: string,
|
name: string,
|
||||||
url: string,
|
url: string,
|
||||||
number: number,
|
number: number,
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ import { getReadProgress, getReadProgressPercentage } from '@/functions/book-pro
|
||||||
import { getBookTitleCompact } from '@/functions/book-title'
|
import { getBookTitleCompact } from '@/functions/book-title'
|
||||||
import { bookFileUrl, bookThumbnailUrl } from '@/functions/urls'
|
import { bookFileUrl, bookThumbnailUrl } from '@/functions/urls'
|
||||||
import { ReadStatus } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
import { BOOK_CHANGED } from '@/types/events'
|
import { BOOK_CHANGED, LIBRARY_DELETED } from '@/types/events'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
|
|
@ -173,9 +173,11 @@ export default Vue.extend({
|
||||||
async created () {
|
async created () {
|
||||||
this.loadBook(this.bookId)
|
this.loadBook(this.bookId)
|
||||||
this.$eventHub.$on(BOOK_CHANGED, this.reloadBook)
|
this.$eventHub.$on(BOOK_CHANGED, this.reloadBook)
|
||||||
|
this.$eventHub.$on(LIBRARY_DELETED, this.libraryDeleted)
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
this.$eventHub.$off(BOOK_CHANGED, this.reloadBook)
|
this.$eventHub.$off(BOOK_CHANGED, this.reloadBook)
|
||||||
|
this.$eventHub.$off(LIBRARY_DELETED, this.libraryDeleted)
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
async book (val) {
|
async book (val) {
|
||||||
|
|
@ -234,6 +236,11 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
libraryDeleted (event: EventLibraryDeleted) {
|
||||||
|
if (event.id === this.book.libraryId) {
|
||||||
|
this.$router.push({ name: 'home' })
|
||||||
|
}
|
||||||
|
},
|
||||||
reloadBook (event: EventBookChanged) {
|
reloadBook (event: EventBookChanged) {
|
||||||
if (event.id === this.bookId) this.loadBook(this.bookId)
|
if (event.id === this.bookId) this.loadBook(this.bookId)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ import ToolbarSticky from '@/components/ToolbarSticky.vue'
|
||||||
import { parseQueryFilter, parseQuerySort } from '@/functions/query-params'
|
import { parseQueryFilter, parseQuerySort } from '@/functions/query-params'
|
||||||
import { ReadStatus } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
import { SeriesStatus } from '@/types/enum-series'
|
import { SeriesStatus } from '@/types/enum-series'
|
||||||
import { COLLECTION_CHANGED, SERIES_CHANGED } from '@/types/events'
|
import { COLLECTION_CHANGED, LIBRARY_DELETED, SERIES_CHANGED } from '@/types/events'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
const cookiePageSize = 'pagesize'
|
const cookiePageSize = 'pagesize'
|
||||||
|
|
@ -210,10 +210,12 @@ export default Vue.extend({
|
||||||
created () {
|
created () {
|
||||||
this.$eventHub.$on(COLLECTION_CHANGED, this.reloadCollections)
|
this.$eventHub.$on(COLLECTION_CHANGED, this.reloadCollections)
|
||||||
this.$eventHub.$on(SERIES_CHANGED, this.reloadSeries)
|
this.$eventHub.$on(SERIES_CHANGED, this.reloadSeries)
|
||||||
|
this.$eventHub.$on(LIBRARY_DELETED, this.libraryDeleted)
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
this.$eventHub.$off(COLLECTION_CHANGED, this.reloadCollections)
|
this.$eventHub.$off(COLLECTION_CHANGED, this.reloadCollections)
|
||||||
this.$eventHub.$off(SERIES_CHANGED, this.reloadSeries)
|
this.$eventHub.$off(SERIES_CHANGED, this.reloadSeries)
|
||||||
|
this.$eventHub.$off(LIBRARY_DELETED, this.libraryDeleted)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.$cookies.isKey(cookiePageSize)) {
|
if (this.$cookies.isKey(cookiePageSize)) {
|
||||||
|
|
@ -271,6 +273,13 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
libraryDeleted (event: EventLibraryDeleted) {
|
||||||
|
if (event.id === this.libraryId) {
|
||||||
|
this.$router.push({ name: 'home' })
|
||||||
|
} else if (this.libraryId === 0) {
|
||||||
|
this.loadLibrary(this.libraryId)
|
||||||
|
}
|
||||||
|
},
|
||||||
setWatches () {
|
setWatches () {
|
||||||
this.sortUnwatch = this.$watch('sortActive', this.updateRouteAndReload)
|
this.sortUnwatch = this.$watch('sortActive', this.updateRouteAndReload)
|
||||||
this.filterUnwatch = this.$watch('filters', this.updateRouteAndReload)
|
this.filterUnwatch = this.$watch('filters', this.updateRouteAndReload)
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ import ToolbarSticky from '@/components/ToolbarSticky.vue'
|
||||||
import { parseQueryFilter, parseQuerySort } from '@/functions/query-params'
|
import { parseQueryFilter, parseQuerySort } from '@/functions/query-params'
|
||||||
import { seriesThumbnailUrl } from '@/functions/urls'
|
import { seriesThumbnailUrl } from '@/functions/urls'
|
||||||
import { ReadStatus } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
import { BOOK_CHANGED, SERIES_CHANGED } from '@/types/events'
|
import { BOOK_CHANGED, LIBRARY_DELETED, SERIES_CHANGED } from '@/types/events'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
const cookiePageSize = 'pagesize'
|
const cookiePageSize = 'pagesize'
|
||||||
|
|
@ -319,10 +319,12 @@ export default Vue.extend({
|
||||||
created () {
|
created () {
|
||||||
this.$eventHub.$on(SERIES_CHANGED, this.reloadSeries)
|
this.$eventHub.$on(SERIES_CHANGED, this.reloadSeries)
|
||||||
this.$eventHub.$on(BOOK_CHANGED, this.reloadBooks)
|
this.$eventHub.$on(BOOK_CHANGED, this.reloadBooks)
|
||||||
|
this.$eventHub.$on(LIBRARY_DELETED, this.libraryDeleted)
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
this.$eventHub.$off(SERIES_CHANGED, this.reloadSeries)
|
this.$eventHub.$off(SERIES_CHANGED, this.reloadSeries)
|
||||||
this.$eventHub.$on(BOOK_CHANGED, this.reloadBooks)
|
this.$eventHub.$off(BOOK_CHANGED, this.reloadBooks)
|
||||||
|
this.$eventHub.$off(LIBRARY_DELETED, this.libraryDeleted)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.$cookies.isKey(cookiePageSize)) {
|
if (this.$cookies.isKey(cookiePageSize)) {
|
||||||
|
|
@ -391,6 +393,11 @@ export default Vue.extend({
|
||||||
|
|
||||||
this.setWatches()
|
this.setWatches()
|
||||||
},
|
},
|
||||||
|
libraryDeleted (event: EventLibraryDeleted) {
|
||||||
|
if (event.id === this.series.libraryId) {
|
||||||
|
this.$router.push({ name: 'home' })
|
||||||
|
}
|
||||||
|
},
|
||||||
reloadSeries (event: EventSeriesChanged) {
|
reloadSeries (event: EventSeriesChanged) {
|
||||||
if (event.id === this.seriesId) this.loadSeries(this.seriesId)
|
if (event.id === this.seriesId) this.loadSeries(this.seriesId)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ import EmptyState from '@/components/EmptyState.vue'
|
||||||
import HorizontalScroller from '@/components/HorizontalScroller.vue'
|
import HorizontalScroller from '@/components/HorizontalScroller.vue'
|
||||||
import ItemCard from '@/components/ItemCard.vue'
|
import ItemCard from '@/components/ItemCard.vue'
|
||||||
import { ReadStatus } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
|
import { LIBRARY_DELETED } from '@/types/events'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
|
|
@ -107,12 +108,14 @@ export default Vue.extend({
|
||||||
dialogEditBookSingle: false,
|
dialogEditBookSingle: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created () {
|
||||||
|
this.$eventHub.$on(LIBRARY_DELETED, this.loadAll)
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this.$eventHub.$off(LIBRARY_DELETED, this.loadAll)
|
||||||
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.loadNewSeries()
|
this.loadAll()
|
||||||
this.loadUpdatedSeries()
|
|
||||||
this.loadLatestBooks()
|
|
||||||
this.loadInProgressBooks()
|
|
||||||
this.loadOnDeckBooks()
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
editSeriesSingle (val: SeriesDto) {
|
editSeriesSingle (val: SeriesDto) {
|
||||||
|
|
@ -150,6 +153,13 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
loadAll () {
|
||||||
|
this.loadNewSeries()
|
||||||
|
this.loadUpdatedSeries()
|
||||||
|
this.loadLatestBooks()
|
||||||
|
this.loadInProgressBooks()
|
||||||
|
this.loadOnDeckBooks()
|
||||||
|
},
|
||||||
async loadNewSeries () {
|
async loadNewSeries () {
|
||||||
this.newSeries = (await this.$komgaSeries.getNewSeries()).content
|
this.newSeries = (await this.$komgaSeries.getNewSeries()).content
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue