Добавлено отображение общего количества книг в серии, без ее раскрытия
This commit is contained in:
@@ -239,6 +239,10 @@ class Api {
|
||||
return await this.request({action: 'get-author-book-list', authorId});
|
||||
}
|
||||
|
||||
async getAuthorSeriesList(authorId) {
|
||||
return await this.request({action: 'get-author-series-list', authorId});
|
||||
}
|
||||
|
||||
async getSeriesBookList(series) {
|
||||
return await this.request({action: 'get-series-book-list', series});
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
|
||||
<div class="q-ml-sm text-bold" style="color: #555">
|
||||
{{ getSeriesBookCount(book) }}
|
||||
{{ getSeriesBookCount(item, book) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -188,15 +188,17 @@ class AuthorList extends BaseList {
|
||||
return `(${result})`;
|
||||
}
|
||||
|
||||
getSeriesBookCount(book) {
|
||||
getSeriesBookCount(item, book) {
|
||||
let result = '';
|
||||
if (!this.showCounts || book.type != 'series')
|
||||
return result;
|
||||
|
||||
let count = book.seriesBooks.length;
|
||||
result = `${count}`;
|
||||
if (book.allBooksLoaded) {
|
||||
result += `/${book.allBooksLoaded.length}`;
|
||||
if (item.seriesLoaded) {
|
||||
const rec = item.seriesLoaded[book.series];
|
||||
const totalCount = (this.showDeleted ? rec.bookCount + rec.bookDelCount : rec.bookCount);
|
||||
result += `/${totalCount}`;
|
||||
}
|
||||
|
||||
return `(${result})`;
|
||||
@@ -227,6 +229,19 @@ class AuthorList extends BaseList {
|
||||
}
|
||||
}
|
||||
|
||||
async getAuthorSeries(item) {
|
||||
if (item.seriesLoaded)
|
||||
return;
|
||||
|
||||
const series = await this.loadAuthorSeries(item.key);
|
||||
const loaded = {};
|
||||
for (const s of series) {
|
||||
loaded[s.series] = {bookCount: s.bookCount, bookDelCount: s.bookDelCount};
|
||||
}
|
||||
|
||||
item.seriesLoaded = loaded;
|
||||
}
|
||||
|
||||
async getAuthorBooks(item) {
|
||||
if (item.books) {
|
||||
if (item.count > this.maxItemCount) {
|
||||
@@ -328,6 +343,7 @@ class AuthorList extends BaseList {
|
||||
}
|
||||
|
||||
item.booksLoaded = books;
|
||||
this.getAuthorSeries(item);//no await
|
||||
this.showMore(item);
|
||||
|
||||
await this.$nextTick();
|
||||
@@ -360,6 +376,7 @@ class AuthorList extends BaseList {
|
||||
name: rec.author.replace(/,/g, ', '),
|
||||
count,
|
||||
booksLoaded: false,
|
||||
seriesLoaded: false,
|
||||
books: false,
|
||||
bookLoading: false,
|
||||
showMore: false,
|
||||
|
||||
@@ -259,6 +259,29 @@ export default class BaseList {
|
||||
}
|
||||
}
|
||||
|
||||
async loadAuthorSeries(authorId) {
|
||||
try {
|
||||
let result;
|
||||
|
||||
if (this.abCacheEnabled) {
|
||||
const key = `author-${authorId}-series-${this.list.inpxHash}`;
|
||||
const data = await authorBooksStorage.getData(key);
|
||||
if (data) {
|
||||
result = JSON.parse(data);
|
||||
} else {
|
||||
result = await this.api.getAuthorSeriesList(authorId);
|
||||
await authorBooksStorage.setData(key, JSON.stringify(result));
|
||||
}
|
||||
} else {
|
||||
result = await this.api.getAuthorSeriesList(authorId);
|
||||
}
|
||||
|
||||
return result.series;
|
||||
} catch (e) {
|
||||
this.$root.stdDialog.alert(e.message, 'Ошибка');
|
||||
}
|
||||
}
|
||||
|
||||
async loadSeriesBooks(series) {
|
||||
try {
|
||||
let result;
|
||||
|
||||
Reference in New Issue
Block a user