Добавлено отображение общего количества книг в серии, без ее раскрытия
This commit is contained in:
@@ -239,6 +239,10 @@ class Api {
|
|||||||
return await this.request({action: 'get-author-book-list', authorId});
|
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) {
|
async getSeriesBookList(series) {
|
||||||
return await this.request({action: 'get-series-book-list', series});
|
return await this.request({action: 'get-series-book-list', series});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="q-ml-sm text-bold" style="color: #555">
|
<div class="q-ml-sm text-bold" style="color: #555">
|
||||||
{{ getSeriesBookCount(book) }}
|
{{ getSeriesBookCount(item, book) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -188,15 +188,17 @@ class AuthorList extends BaseList {
|
|||||||
return `(${result})`;
|
return `(${result})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSeriesBookCount(book) {
|
getSeriesBookCount(item, book) {
|
||||||
let result = '';
|
let result = '';
|
||||||
if (!this.showCounts || book.type != 'series')
|
if (!this.showCounts || book.type != 'series')
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
let count = book.seriesBooks.length;
|
let count = book.seriesBooks.length;
|
||||||
result = `${count}`;
|
result = `${count}`;
|
||||||
if (book.allBooksLoaded) {
|
if (item.seriesLoaded) {
|
||||||
result += `/${book.allBooksLoaded.length}`;
|
const rec = item.seriesLoaded[book.series];
|
||||||
|
const totalCount = (this.showDeleted ? rec.bookCount + rec.bookDelCount : rec.bookCount);
|
||||||
|
result += `/${totalCount}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `(${result})`;
|
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) {
|
async getAuthorBooks(item) {
|
||||||
if (item.books) {
|
if (item.books) {
|
||||||
if (item.count > this.maxItemCount) {
|
if (item.count > this.maxItemCount) {
|
||||||
@@ -328,6 +343,7 @@ class AuthorList extends BaseList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
item.booksLoaded = books;
|
item.booksLoaded = books;
|
||||||
|
this.getAuthorSeries(item);//no await
|
||||||
this.showMore(item);
|
this.showMore(item);
|
||||||
|
|
||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
@@ -360,6 +376,7 @@ class AuthorList extends BaseList {
|
|||||||
name: rec.author.replace(/,/g, ', '),
|
name: rec.author.replace(/,/g, ', '),
|
||||||
count,
|
count,
|
||||||
booksLoaded: false,
|
booksLoaded: false,
|
||||||
|
seriesLoaded: false,
|
||||||
books: false,
|
books: false,
|
||||||
bookLoading: false,
|
bookLoading: false,
|
||||||
showMore: 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) {
|
async loadSeriesBooks(series) {
|
||||||
try {
|
try {
|
||||||
let result;
|
let result;
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ class WebSocketController {
|
|||||||
await this.search(req, ws); break;
|
await this.search(req, ws); break;
|
||||||
case 'get-author-book-list':
|
case 'get-author-book-list':
|
||||||
await this.getAuthorBookList(req, ws); break;
|
await this.getAuthorBookList(req, ws); break;
|
||||||
|
case 'get-author-series-list':
|
||||||
|
await this.getAuthorSeriesList(req, ws); break;
|
||||||
case 'get-series-book-list':
|
case 'get-series-book-list':
|
||||||
await this.getSeriesBookList(req, ws); break;
|
await this.getSeriesBookList(req, ws); break;
|
||||||
case 'get-genre-tree':
|
case 'get-genre-tree':
|
||||||
@@ -169,6 +171,12 @@ class WebSocketController {
|
|||||||
this.send(result, req, ws);
|
this.send(result, req, ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAuthorSeriesList(req, ws) {
|
||||||
|
const result = await this.webWorker.getAuthorSeriesList(req.authorId);
|
||||||
|
|
||||||
|
this.send(result, req, ws);
|
||||||
|
}
|
||||||
|
|
||||||
async getSeriesBookList(req, ws) {
|
async getSeriesBookList(req, ws) {
|
||||||
const result = await this.webWorker.getSeriesBookList(req.series);
|
const result = await this.webWorker.getSeriesBookList(req.series);
|
||||||
|
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ class DbSearcher {
|
|||||||
throw new Error('DbSearcher closed');
|
throw new Error('DbSearcher closed');
|
||||||
|
|
||||||
if (!authorId && !author)
|
if (!authorId && !author)
|
||||||
return {author: '', books: ''};
|
return {author: '', books: []};
|
||||||
|
|
||||||
this.searchFlag++;
|
this.searchFlag++;
|
||||||
|
|
||||||
@@ -638,12 +638,58 @@ class DbSearcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAuthorSeriesList(authorId) {
|
||||||
|
if (this.closed)
|
||||||
|
throw new Error('DbSearcher closed');
|
||||||
|
|
||||||
|
if (!authorId)
|
||||||
|
return {author: '', series: []};
|
||||||
|
|
||||||
|
this.searchFlag++;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const db = this.db;
|
||||||
|
|
||||||
|
//выборка книг автора по authorId
|
||||||
|
const bookList = await this.getAuthorBookList(authorId);
|
||||||
|
const books = bookList.books;
|
||||||
|
const seriesSet = new Set();
|
||||||
|
for (const book of books) {
|
||||||
|
if (book.series)
|
||||||
|
seriesSet.add(book.series.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
let series = [];
|
||||||
|
if (seriesSet.size) {
|
||||||
|
//выборка серий по названиям
|
||||||
|
series = await db.select({
|
||||||
|
table: 'series',
|
||||||
|
map: `(r) => ({id: r.id, series: r.name, bookCount: r.bookCount, bookDelCount: r.bookDelCount})`,
|
||||||
|
where: `
|
||||||
|
const seriesArr = ${db.esc(Array.from(seriesSet))};
|
||||||
|
const ids = new Set();
|
||||||
|
for (const value of seriesArr) {
|
||||||
|
for (const id of @dirtyIndexLR('value', value, value))
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids;
|
||||||
|
`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {author: bookList.author, series};
|
||||||
|
} finally {
|
||||||
|
this.searchFlag--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getSeriesBookList(series) {
|
async getSeriesBookList(series) {
|
||||||
if (this.closed)
|
if (this.closed)
|
||||||
throw new Error('DbSearcher closed');
|
throw new Error('DbSearcher closed');
|
||||||
|
|
||||||
if (!series)
|
if (!series)
|
||||||
return {books: ''};
|
return {books: []};
|
||||||
|
|
||||||
this.searchFlag++;
|
this.searchFlag++;
|
||||||
|
|
||||||
|
|||||||
@@ -279,6 +279,12 @@ class WebWorker {
|
|||||||
return await this.dbSearcher.getAuthorBookList(authorId, author);
|
return await this.dbSearcher.getAuthorBookList(authorId, author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAuthorSeriesList(authorId) {
|
||||||
|
this.checkMyState();
|
||||||
|
|
||||||
|
return await this.dbSearcher.getAuthorSeriesList(authorId);
|
||||||
|
}
|
||||||
|
|
||||||
async getSeriesBookList(series) {
|
async getSeriesBookList(series) {
|
||||||
this.checkMyState();
|
this.checkMyState();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user