+
+
+ По каждому из заданных критериев у этой серии были найдены разные книги, но нет полного совпадения
+
+
+
Показать еще (~{{ showMoreCount }})
@@ -141,6 +116,67 @@ import * as utils from '../../../share/utils';
import _ from 'lodash';
class SeriesList extends BaseList {
+ get foundCountMessage() {
+ return `Найден${utils.wordEnding(this.list.totalFound, 4)} ${this.list.totalFound} сери${utils.wordEnding(this.list.totalFound, 1)}`;
+ }
+
+ isFoundSeriesBook(seriesItem, seriesBook) {
+ if (!seriesItem.booksSet) {
+ seriesItem.booksSet = new Set(seriesItem.books.map(b => b.id));
+ }
+
+ return seriesItem.booksSet.has(seriesBook.id);
+ }
+
+ getBookCount(item) {
+ let result = '';
+ if (!this.showCounts || item.count === undefined)
+ return result;
+
+ if (item.books) {
+ result = `${item.books.length}/${item.count}`;
+ } else
+ result = `#/${item.count}`;
+
+ return `(${result})`;
+ }
+
+ async getSeriesBooks(seriesItem) {
+ if (seriesItem.count > this.maxItemCount) {
+ seriesItem.bookLoading = true;
+ await this.$nextTick();
+ }
+
+ try {
+ await super.getSeriesBooks(seriesItem);
+
+ if (seriesItem.allBooksLoaded) {
+ const prepareBook = (book) => {
+ return Object.assign(
+ {
+ key: book.id,
+ type: 'book',
+ },
+ book
+ );
+ };
+
+ const filtered = this.filterBooks(seriesItem.allBooksLoaded);
+
+ //объединение по сериям
+ const books = [];
+ for (const book of filtered) {
+ books.push(prepareBook(book));
+ }
+
+ seriesItem.booksLoaded = books;
+ this.showMore(seriesItem);
+ }
+ } finally {
+ seriesItem.bookLoading = false;
+ }
+ }
+
async updateTableData() {
let result = [];
@@ -148,47 +184,44 @@ class SeriesList extends BaseList {
const series = this.searchResult.series;
if (!series)
return;
-/*
- let num = 0;
- this.hiddenCount = 0;
- for (const rec of authors) {
- this.cachedAuthors[rec.author] = rec;
+ let num = 0;
+ for (const rec of series) {
const count = (this.showDeleted ? rec.bookCount + rec.bookDelCount : rec.bookCount);
- if (!count) {
- this.hiddenCount++;
- continue;
- }
const item = reactive({
- key: rec.id,
+ key: rec.series,
+ series: rec.series,
num,
- author: rec.author,
- name: rec.author.replace(/,/g, ', '),
count,
+ bookLoading: false,
+
+ allBooksLoaded: false,
+ allBooks: false,
+ showAllBooks: false,
+ showMoreAll: false,
+
booksLoaded: false,
books: false,
- bookLoading: false,
showMore: false,
});
num++;
- if (expandedSet.has(item.author)) {
- if (authors.length > 1 || item.count > this.maxItemCount)
- this.getBooks(item);//no await
+ if (expandedSet.has(item.series)) {
+ if (series.length > 1 || item.count > this.maxItemCount)
+ this.getSeriesBooks(item);//no await
else
- await this.getBooks(item);
+ await this.getSeriesBooks(item);
}
result.push(item);
}
- if (result.length == 1 && !this.isExpandedAuthor(result[0])) {
- this.expandAuthor(result[0]);
+ if (result.length == 1 && !this.isExpandedSeries(result[0])) {
+ this.expandSeries(result[0]);
}
this.tableData = result;
-*/
}
async refresh() {
diff --git a/client/share/utils.js b/client/share/utils.js
index 807ec8c..0b497d9 100644
--- a/client/share/utils.js
+++ b/client/share/utils.js
@@ -38,7 +38,8 @@ export function wordEnding(num, type = 0) {
['ов', '', 'а', 'а', 'а', 'ов', 'ов', 'ов', 'ов', 'ов'],
['й', 'я', 'и', 'и', 'и', 'й', 'й', 'й', 'й', 'й'],
['о', '', 'о', 'о', 'о', 'о', 'о', 'о', 'о', 'о'],
- ['ий', 'ие', 'ия', 'ия', 'ия', 'ий', 'ий', 'ий', 'ий', 'ий']
+ ['ий', 'ие', 'ия', 'ия', 'ия', 'ий', 'ий', 'ий', 'ий', 'ий'],
+ ['о', 'а', 'о', 'о', 'о', 'о', 'о', 'о', 'о', 'о'],
];
const deci = num % 100;
if (deci > 10 && deci < 20) {
diff --git a/server/controllers/WebSocketController.js b/server/controllers/WebSocketController.js
index 2c3ba0e..7ff4f9f 100644
--- a/server/controllers/WebSocketController.js
+++ b/server/controllers/WebSocketController.js
@@ -163,7 +163,7 @@ class WebSocketController {
}
async getSeriesBookList(req, ws) {
- const result = await this.webWorker.getSeriesBookList(req.series, req.seriesId);
+ const result = await this.webWorker.getSeriesBookList(req.series);
this.send(result, req, ws);
}
diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js
index 161cf34..a146ba2 100644
--- a/server/core/DbSearcher.js
+++ b/server/core/DbSearcher.js
@@ -483,11 +483,11 @@ class DbSearcher {
}
}
- async getSeriesBookList(series, seriesId) {
+ async getSeriesBookList(series) {
if (this.closed)
throw new Error('DbSearcher closed');
- if (!series && !seriesId)
+ if (!series)
return {books: ''};
this.searchFlag++;
@@ -500,15 +500,16 @@ class DbSearcher {
//выборка серии по названию серии
let rows = await db.select({
table: 'series',
- where: `@@dirtyIndexLR('value', ${db.esc(series)}, ${db.esc(series)})`
+ rawResult: true,
+ where: `return Array.from(@dirtyIndexLR('value', ${db.esc(series)}, ${db.esc(series)}))`
});
let books;
- if (rows.length) {
+ if (rows.length && rows[0].rawResult.length) {
//выборка книг серии
rows = await db.select({
table: 'series_book',
- where: `@@id(${rows[0].id})`
+ where: `@@id(${rows[0].rawResult[0]})`
});
if (rows.length)
diff --git a/server/core/WebWorker.js b/server/core/WebWorker.js
index 20bf116..bb44c57 100644
--- a/server/core/WebWorker.js
+++ b/server/core/WebWorker.js
@@ -277,10 +277,10 @@ class WebWorker {
return await this.dbSearcher.getAuthorBookList(authorId);
}
- async getSeriesBookList(series, seriesId) {
+ async getSeriesBookList(series) {
this.checkMyState();
- return await this.dbSearcher.getSeriesBookList(series, seriesId);
+ return await this.dbSearcher.getSeriesBookList(series);
}
async getGenreTree() {