Работа над проектом
This commit is contained in:
@@ -8,11 +8,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="getBooksMessage" class="fit row justify-center items-center" style="position: absolute; background-color: rgba(0, 0, 0, 0.2); z-index: 1">
|
<div v-show="loadingMessage2" class="fit row justify-center items-center" style="position: absolute; background-color: rgba(0, 0, 0, 0.2); z-index: 1">
|
||||||
<div class="bg-white row justify-center items-center q-px-lg" style="min-width: 180px; height: 50px; border-radius: 10px; box-shadow: 2px 2px 10px #333333">
|
<div class="bg-white row justify-center items-center q-px-lg" style="min-width: 180px; height: 50px; border-radius: 10px; box-shadow: 2px 2px 10px #333333">
|
||||||
<q-spinner color="primary" size="2em" />
|
<q-spinner color="primary" size="2em" />
|
||||||
<div class="q-ml-sm">
|
<div class="q-ml-sm">
|
||||||
{{ getBooksMessage }}
|
{{ loadingMessage2 }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -115,15 +115,15 @@
|
|||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="item.books" class="q-ml-sm" style="font-weight: bold">
|
<div class="q-ml-sm" style="font-weight: bold">
|
||||||
({{ item.books.rows.length }})
|
{{ getBookCount(item) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="isExpanded(item) && item.books">
|
<div v-if="isExpanded(item) && item.books">
|
||||||
<div v-for="row in item.books.rows" :key="row.key" class="book-row column">
|
<div v-for="book in item.books" :key="book.key" class="book-row column">
|
||||||
<div class="q-my-sm" @click="selectAuthor(row.title)">
|
<div class="q-my-sm" @click="selectAuthor(book.title)">
|
||||||
{{ row.title }} {{ row.src.del }}
|
{{ book.title }} {{ book.src.del }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -159,6 +159,9 @@ const componentOptions = {
|
|||||||
config() {
|
config() {
|
||||||
this.makeTitle();
|
this.makeTitle();
|
||||||
},
|
},
|
||||||
|
settings() {
|
||||||
|
this.loadSettings();
|
||||||
|
},
|
||||||
author() {
|
author() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
@@ -178,21 +181,17 @@ const componentOptions = {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
limit(newValue) {
|
limit(newValue) {
|
||||||
const newSettings = _.cloneDeep(this.settings);
|
this.setSetting('limit', newValue);
|
||||||
newSettings.limit = newValue;
|
|
||||||
this.commit('setSettings', newSettings);
|
|
||||||
|
|
||||||
this.updatePageCount();
|
this.updatePageCount();
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
|
showDeleted(newValue) {
|
||||||
|
this.setSetting('showDeleted', newValue);
|
||||||
|
},
|
||||||
totalFound() {
|
totalFound() {
|
||||||
this.updatePageCount();
|
this.updatePageCount();
|
||||||
},
|
},
|
||||||
expanded(newValue) {
|
|
||||||
const newSettings = _.cloneDeep(this.settings);
|
|
||||||
newSettings.expanded = _.cloneDeep(newValue);
|
|
||||||
this.commit('setSettings', newSettings);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
class Search {
|
class Search {
|
||||||
@@ -201,10 +200,9 @@ class Search {
|
|||||||
projectName = '';
|
projectName = '';
|
||||||
|
|
||||||
loadingMessage = '';
|
loadingMessage = '';
|
||||||
getBooksMessage = '';
|
loadingMessage2 = '';
|
||||||
page = 1;
|
page = 1;
|
||||||
pageCount = 1;
|
pageCount = 1;
|
||||||
expanded = [];
|
|
||||||
|
|
||||||
//input field consts
|
//input field consts
|
||||||
inputMaxLength = 1000;
|
inputMaxLength = 1000;
|
||||||
@@ -216,7 +214,11 @@ class Search {
|
|||||||
title = '';
|
title = '';
|
||||||
genre = '';
|
genre = '';
|
||||||
lang = '';
|
lang = '';
|
||||||
limit = 50;
|
limit = 50;//settings
|
||||||
|
|
||||||
|
//settings
|
||||||
|
expanded = [];
|
||||||
|
showDeleted = false;
|
||||||
|
|
||||||
//stuff
|
//stuff
|
||||||
queryFound = -1;
|
queryFound = -1;
|
||||||
@@ -257,6 +259,7 @@ class Search {
|
|||||||
|
|
||||||
this.limit = settings.limit;
|
this.limit = settings.limit;
|
||||||
this.expanded = _.cloneDeep(settings.expanded);
|
this.expanded = _.cloneDeep(settings.expanded);
|
||||||
|
this.showDeleted = settings.showDeleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
get config() {
|
get config() {
|
||||||
@@ -351,6 +354,12 @@ class Search {
|
|||||||
return this.expanded.indexOf(item.author) >= 0;
|
return this.expanded.indexOf(item.author) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSetting(name, newValue) {
|
||||||
|
const newSettings = _.cloneDeep(this.settings);
|
||||||
|
newSettings[name] = _.cloneDeep(newValue);
|
||||||
|
this.commit('setSettings', newSettings);
|
||||||
|
}
|
||||||
|
|
||||||
expandAuthor(item) {
|
expandAuthor(item) {
|
||||||
const expanded = _.cloneDeep(this.expanded);
|
const expanded = _.cloneDeep(this.expanded);
|
||||||
const author = item.author;
|
const author = item.author;
|
||||||
@@ -364,17 +373,34 @@ class Search {
|
|||||||
expanded.shift();
|
expanded.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.expanded = expanded;
|
this.setSetting('expanded', expanded);
|
||||||
this.ignoreScroll();
|
this.ignoreScroll();
|
||||||
} else {
|
} else {
|
||||||
const i = expanded.indexOf(author);
|
const i = expanded.indexOf(author);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
expanded.splice(i, 1);
|
expanded.splice(i, 1);
|
||||||
this.expanded = expanded;
|
this.setSetting('expanded', expanded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBookCount(item) {
|
||||||
|
let result = '';
|
||||||
|
if (item.bookCount === undefined)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
if (this.showDeleted) {
|
||||||
|
result = item.bookCount + item.bookDelCount;
|
||||||
|
} else {
|
||||||
|
result = item.bookCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.books && item.books.length < result)
|
||||||
|
result = `${item.books.length}/${result}`;
|
||||||
|
|
||||||
|
return `(${result})`;
|
||||||
|
}
|
||||||
|
|
||||||
async loadBooks(author, authorId) {
|
async loadBooks(author, authorId) {
|
||||||
try {
|
try {
|
||||||
const result = await this.api.getBookList(authorId);
|
const result = await this.api.getBookList(authorId);
|
||||||
@@ -403,7 +429,7 @@ class Search {
|
|||||||
(async() => {
|
(async() => {
|
||||||
await utils.sleep(500);
|
await utils.sleep(500);
|
||||||
if (this.getBooksFlag > 0)
|
if (this.getBooksFlag > 0)
|
||||||
this.getBooksMessage = 'Загрузка списка книг...';
|
this.loadingMessage2 = 'Загрузка списка книг...';
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,22 +439,16 @@ class Search {
|
|||||||
|
|
||||||
filtered.sort((a, b) => a.title.localeCompare(b.title));
|
filtered.sort((a, b) => a.title.localeCompare(b.title));
|
||||||
|
|
||||||
const rows = [];
|
const books = [];
|
||||||
for (const book of filtered) {
|
for (const book of filtered) {
|
||||||
rows.push({key: book.id, title: book.title, src: book});
|
books.push({key: book.id, title: book.title, src: book});
|
||||||
}
|
}
|
||||||
|
|
||||||
const books = {
|
|
||||||
totalCount: loadedBooks.length,
|
|
||||||
filteredCount: filtered.length,
|
|
||||||
rows,
|
|
||||||
};
|
|
||||||
|
|
||||||
item.books = books;
|
item.books = books;
|
||||||
} finally {
|
} finally {
|
||||||
this.getBooksFlag--;
|
this.getBooksFlag--;
|
||||||
if (this.getBooksFlag == 0)
|
if (this.getBooksFlag == 0)
|
||||||
this.getBooksMessage = '';
|
this.loadingMessage2 = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,6 +465,8 @@ class Search {
|
|||||||
num,
|
num,
|
||||||
author: rec.author,
|
author: rec.author,
|
||||||
name: rec.author.replace(/,/g, ', '),
|
name: rec.author.replace(/,/g, ', '),
|
||||||
|
bookCount: rec.bookCount,
|
||||||
|
bookDelCount: rec.bookDelCount,
|
||||||
book: false,
|
book: false,
|
||||||
});
|
});
|
||||||
num++;
|
num++;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const state = {
|
|||||||
settings: {
|
settings: {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
expanded: [],
|
expanded: [],
|
||||||
|
showDeleted: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class DbCreator {
|
|||||||
const authorTmpId = authorMap.get(value);
|
const authorTmpId = authorMap.get(value);
|
||||||
authorRec = authorArr[authorTmpId];
|
authorRec = authorArr[authorTmpId];
|
||||||
} else {
|
} else {
|
||||||
authorRec = {tmpId: authorArr.length, author: a, value, bookId: []};
|
authorRec = {tmpId: authorArr.length, author: a, value, bookCount: 0, bookDelCount: 0, bookId: []};
|
||||||
authorArr.push(authorRec);
|
authorArr.push(authorRec);
|
||||||
authorMap.set(value, authorRec.tmpId);
|
authorMap.set(value, authorRec.tmpId);
|
||||||
|
|
||||||
@@ -94,6 +94,13 @@ class DbCreator {
|
|||||||
if (a[0].toUpperCase() === a[0])
|
if (a[0].toUpperCase() === a[0])
|
||||||
authorRec.author = a;
|
authorRec.author = a;
|
||||||
|
|
||||||
|
//счетчики
|
||||||
|
if (!rec.del) {
|
||||||
|
authorRec.bookCount++;
|
||||||
|
} else {
|
||||||
|
authorRec.bookDelCount++;
|
||||||
|
}
|
||||||
|
|
||||||
//ссылки на книги
|
//ссылки на книги
|
||||||
authorRec.bookId.push(id);
|
authorRec.bookId.push(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class DbSearcher {
|
|||||||
//выборка найденных авторов
|
//выборка найденных авторов
|
||||||
let result = await db.select({
|
let result = await db.select({
|
||||||
table: 'author',
|
table: 'author',
|
||||||
map: `(r) => ({id: r.id, author: r.author})`,
|
map: `(r) => ({id: r.id, author: r.author, bookCount: r.bookCount, bookDelCount: r.bookDelCount})`,
|
||||||
where: `@@id(${db.esc(authorIds.slice(offset, offset + limit))})`
|
where: `@@id(${db.esc(authorIds.slice(offset, offset + limit))})`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user