From 35bf05eb39fc05b6d36beaedca5d64aace81302e Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 11 Feb 2022 17:06:11 +0800 Subject: [PATCH] feat(webui): adapt card content depending on context closes #679 --- komga-webui/src/components/ItemBrowser.vue | 6 + komga-webui/src/components/ItemCard.vue | 46 +++-- .../components/ReadListsExpansionPanels.vue | 3 + komga-webui/src/locales/en.json | 4 +- komga-webui/src/types/items.ts | 180 ++++++++++++------ komga-webui/src/types/komga-books.ts | 2 + komga-webui/src/types/komga-series.ts | 1 + komga-webui/src/views/BrowseLibraries.vue | 8 + komga-webui/src/views/BrowseReadList.vue | 3 + komga-webui/src/views/BrowseSeries.vue | 8 + komga-webui/src/views/DashboardView.vue | 7 + komga-webui/src/views/SearchView.vue | 3 + .../komga/infrastructure/jooq/BookDtoDao.kt | 9 +- .../komga/interfaces/api/rest/dto/BookDto.kt | 1 + 14 files changed, 210 insertions(+), 71 deletions(-) diff --git a/komga-webui/src/components/ItemBrowser.vue b/komga-webui/src/components/ItemBrowser.vue index aedb06226..0193f9280 100644 --- a/komga-webui/src/components/ItemBrowser.vue +++ b/komga-webui/src/components/ItemBrowser.vue @@ -26,6 +26,7 @@ ItemContext[], + default: () => [], + }, fixedItemWidth: { type: Number, required: false, diff --git a/komga-webui/src/components/ItemCard.vue b/komga-webui/src/components/ItemCard.vue index 63ec786b7..18d94406b 100644 --- a/komga-webui/src/components/ItemCard.vue +++ b/komga-webui/src/components/ItemCard.vue @@ -101,14 +101,28 @@ @@ -123,17 +137,21 @@ import CollectionActionsMenu from '@/components/menus/CollectionActionsMenu.vue' import SeriesActionsMenu from '@/components/menus/SeriesActionsMenu.vue' import {getReadProgress, getReadProgressPercentage} from '@/functions/book-progress' import {ReadStatus} from '@/types/enum-books' -import {createItem, Item, ItemTypes} from '@/types/items' +import {createItem, Item, ItemContext, ItemTitle, ItemTypes} from '@/types/items' import Vue from 'vue' import {RawLocation} from 'vue-router' import ReadListActionsMenu from '@/components/menus/ReadListActionsMenu.vue' import {BookDto} from '@/types/komga-books' import {SeriesDto} from '@/types/komga-series' import { - THUMBNAILBOOK_ADDED, THUMBNAILBOOK_DELETED, - THUMBNAILCOLLECTION_ADDED, THUMBNAILCOLLECTION_DELETED, - THUMBNAILREADLIST_ADDED, THUMBNAILREADLIST_DELETED, - THUMBNAILSERIES_ADDED, THUMBNAILSERIES_DELETED, + THUMBNAILBOOK_ADDED, + THUMBNAILBOOK_DELETED, + THUMBNAILCOLLECTION_ADDED, + THUMBNAILCOLLECTION_DELETED, + THUMBNAILREADLIST_ADDED, + THUMBNAILREADLIST_DELETED, + THUMBNAILSERIES_ADDED, + THUMBNAILSERIES_DELETED, } from '@/types/events' import { ThumbnailBookSseDto, @@ -151,6 +169,10 @@ export default Vue.extend({ type: Object as () => BookDto | SeriesDto | CollectionDto | ReadListDto, required: true, }, + itemContext: { + type: Array as () => ItemContext[], + default: () => [], + }, // hide the bottom part of the card thumbnailOnly: { type: Boolean, @@ -248,14 +270,14 @@ export default Vue.extend({ thumbnailUrl(): string { return this.computedItem.thumbnailUrl() + this.thumbnailCacheBust }, - title(): string { - return this.computedItem.title() + title(): ItemTitle | ItemTitle[] { + return this.computedItem.title(this.itemContext) }, subtitleProps(): Object { return this.computedItem.subtitleProps() }, body(): string { - return this.computedItem.body() + return this.computedItem.body(this.itemContext) }, isInProgress(): boolean { if (this.computedItem.type() === ItemTypes.BOOK) return getReadProgress(this.item as BookDto) === ReadStatus.IN_PROGRESS diff --git a/komga-webui/src/components/ReadListsExpansionPanels.vue b/komga-webui/src/components/ReadListsExpansionPanels.vue index fcd398c07..21de8ab35 100644 --- a/komga-webui/src/components/ReadListsExpansionPanels.vue +++ b/komga-webui/src/components/ReadListsExpansionPanels.vue @@ -13,6 +13,7 @@