diff --git a/komga-webui/src/components/EditSeriesDialog.vue b/komga-webui/src/components/EditSeriesDialog.vue index a7be19fce..ba3f8b7fb 100644 --- a/komga-webui/src/components/EditSeriesDialog.vue +++ b/komga-webui/src/components/EditSeriesDialog.vue @@ -144,7 +144,7 @@ export default Vue.extend({ props: { value: Boolean, series: { - type: Array as () => SeriesDto[], + type: [Object as () => SeriesDto, Array as () => SeriesDto[]], required: true } }, @@ -161,32 +161,33 @@ export default Vue.extend({ }, computed: { multiple (): boolean { - return this.series.length > 1 + return Array.isArray(this.series) }, seriesStatus (): string[] { return Object.keys(SeriesStatus).map(x => capitalize(x)) }, dialogTitle (): string { return this.multiple - ? `Edit ${this.series.length} series` - : `Edit ${this.$_.get(this.series[0], 'metadata.title')}` + ? `Edit ${(this.series as SeriesDto[]).length} series` + : `Edit ${this.$_.get(this.series, 'metadata.title')}` } }, methods: { - dialogReset (series: SeriesDto[]) { - if (series.length === 0) return - if (series.length > 1) { + dialogReset (series: SeriesDto | SeriesDto[]) { + if (Array.isArray(series) && series.length === 0) return + if (Array.isArray(series) && series.length > 0) { const status = this.$_.uniq(series.map(x => x.metadata.status)) this.form.status = status.length > 1 ? '' : capitalize(status[0]) const statusLock = this.$_.uniq(series.map(x => x.metadata.statusLock)) this.form.statusLock = statusLock.length > 1 ? false : statusLock[0] } else { - this.form.status = capitalize(series[0].metadata.status) - this.form.statusLock = series[0].metadata.statusLock - this.form.title = series[0].metadata.title - this.form.titleLock = series[0].metadata.titleLock - this.form.titleSort = series[0].metadata.titleSort - this.form.titleSortLock = series[0].metadata.titleSortLock + const s = series as SeriesDto + this.form.status = capitalize(s.metadata.status) + this.form.statusLock = s.metadata.statusLock + this.form.title = s.metadata.title + this.form.titleLock = s.metadata.titleLock + this.form.titleSort = s.metadata.titleSort + this.form.titleSortLock = s.metadata.titleSortLock } }, dialogCancel () { @@ -203,7 +204,8 @@ export default Vue.extend({ }, async editSeries () { const updated = [] as SeriesDto[] - for (const s of this.series) { + const toUpdate = (this.multiple ? this.series : [this.series]) as SeriesDto[] + for (const s of toUpdate) { try { if (this.form.status === '') { return @@ -229,7 +231,7 @@ export default Vue.extend({ updated.push(s) } } - this.$emit('update:series', updated) + this.$emit('update:series', this.multiple ? updated : updated[0]) } } }) diff --git a/komga-webui/src/views/BrowseLibraries.vue b/komga-webui/src/views/BrowseLibraries.vue index 957628b84..386853732 100644 --- a/komga-webui/src/views/BrowseLibraries.vue +++ b/komga-webui/src/views/BrowseLibraries.vue @@ -132,7 +132,7 @@ export default mixins(VisibleElements).extend({ library: undefined as LibraryDto | undefined, series: [] as SeriesDto[], selectedSeries: [] as SeriesDto[], - editSeriesSingle: [] as SeriesDto[], + editSeriesSingle: {} as SeriesDto, pagesState: [] as LoadState[], pageSize: 20, totalElements: null as number | null, @@ -183,17 +183,15 @@ export default mixins(VisibleElements).extend({ val.forEach(s => { const index = this.series.findIndex(x => x.id === s.id) if (index !== -1) { - this.series[index] = s + this.series.splice(index, 1, s) } }) }, - editSeriesSingle (val: SeriesDto[]) { - val.forEach(s => { - const index = this.series.findIndex(x => x.id === s.id) - if (index !== -1) { - this.series[index] = s - } - }) + editSeriesSingle (val: SeriesDto) { + const index = this.series.findIndex(x => x.id === val.id) + if (index !== -1) { + this.series.splice(index, 1, val) + } } }, async created () { @@ -321,7 +319,7 @@ export default mixins(VisibleElements).extend({ } }, singleEdit (series: SeriesDto) { - this.editSeriesSingle = [series] + this.editSeriesSingle = series this.dialogEditSingle = true } } diff --git a/komga-webui/src/views/BrowseSeries.vue b/komga-webui/src/views/BrowseSeries.vue index 68ae39994..49997b5f7 100644 --- a/komga-webui/src/views/BrowseSeries.vue +++ b/komga-webui/src/views/BrowseSeries.vue @@ -89,7 +89,7 @@ + :series.sync="series"/> @@ -136,14 +136,6 @@ export default mixins(VisibleElements).extend({ }, thumbnailUrl (): string { return seriesThumbnailUrl(this.seriesId) - }, - seriesArray: { - get (): SeriesDto[] { - return [this.series] - }, - set (val: SeriesDto[]) { - this.series = val[0] - } } }, props: { diff --git a/komga-webui/src/views/Dashboard.vue b/komga-webui/src/views/Dashboard.vue index b0010aafe..56a5fc885 100644 --- a/komga-webui/src/views/Dashboard.vue +++ b/komga-webui/src/views/Dashboard.vue @@ -98,7 +98,7 @@ export default Vue.extend({ updatedSeries: Array(pageSize).fill(null) as SeriesDto[], books: Array(pageSize).fill(null) as BookDto[], pageSize: pageSize, - editSeriesSingle: [] as SeriesDto[], + editSeriesSingle: {} as SeriesDto, dialogEditSingle: false } }, @@ -112,13 +112,15 @@ export default Vue.extend({ } }, watch: { - editSeriesSingle (val: SeriesDto[]) { - val.forEach(s => { - const index = this.newSeries.findIndex(x => x.id === s.id) - if (index !== -1) { - this.newSeries[index] = s - } - }) + editSeriesSingle (val: SeriesDto) { + let index = this.newSeries.findIndex(x => x.id === val.id) + if (index !== -1) { + this.newSeries.splice(index, 1, val) + } + index = this.updatedSeries.findIndex(x => x.id === val.id) + if (index !== -1) { + this.updatedSeries.splice(index, 1, val) + } } }, methods: { @@ -137,7 +139,7 @@ export default Vue.extend({ this.books = (await this.$komgaBooks.getBooks(undefined, pageRequest)).content }, singleEdit (series: SeriesDto) { - this.editSeriesSingle = [series] + this.editSeriesSingle = series this.dialogEditSingle = true } }