В списке загруженных, книга в архив (из архива) переносится теперь со всей группой своих версий

This commit is contained in:
Book Pauk
2023-12-07 16:26:30 +07:00
parent d3ad23e9e4
commit e3770463a1
3 changed files with 63 additions and 13 deletions

View File

@@ -1379,6 +1379,7 @@ class Reader {
found = (found ? _.cloneDeep(found) : found); found = (found ? _.cloneDeep(found) : found);
if (found) { if (found) {
//если такой файл уже не загружен (path не совпадают)
if (wasOpened.sameBookKey != found.sameBookKey) { if (wasOpened.sameBookKey != found.sameBookKey) {
//спрашиваем, надо ли объединить файлы //спрашиваем, надо ли объединить файлы
const askResult = bookManager.keysEqual(found.path, addedBook.path) || const askResult = bookManager.keysEqual(found.path, addedBook.path) ||

View File

@@ -201,7 +201,7 @@
<div <div
class="del-button self-end row justify-center items-center clickable" class="del-button self-end row justify-center items-center clickable"
@click="handleDel(item.key)" @click="handleDel(item)"
> >
<q-icon class="la la-times" size="12px" /> <q-icon class="la la-times" size="12px" />
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%"> <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
@@ -212,7 +212,7 @@
<div <div
v-show="showArchive" v-show="showArchive"
class="restore-button self-start row justify-center items-center clickable" class="restore-button self-start row justify-center items-center clickable"
@click="handleRestore(item.key)" @click="handleRestore(item)"
> >
<q-icon class="la la-arrow-left" size="14px" /> <q-icon class="la la-arrow-left" size="14px" />
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%"> <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
@@ -593,21 +593,46 @@ class RecentBooksPage {
} }
} }
async handleDel(key) { async handleDel(item) {
if (!this.showArchive) { if (item.group) {
await bookManager.delRecentBook({key}); const keys = [{key: item.key}];
this.$root.notify.info('Перенесено в архив'); for (const book of item.group)
keys.push({key: book.key});
if (!this.showArchive) {
await bookManager.delRecentBooks(keys);
this.$root.notify.info(`Группа книг (всего ${keys.length}) перенесена в архив`);
} else {
if (await this.$root.stdDialog.confirm(`Подтвердите удаление группы книг (всего ${keys.length}) из архива:`, ' ')) {
await bookManager.delRecentBooks(keys, 2);
this.$root.notify.info('Группа книг удалена безвозвратно');
}
}
} else { } else {
if (await this.$root.stdDialog.confirm('Подтвердите удаление из архива:', ' ')) { if (!this.showArchive) {
await bookManager.delRecentBook({key}, 2); await bookManager.delRecentBooks([{key: item.key}]);
this.$root.notify.info('Удалено безвозвратно'); this.$root.notify.info('Книга перенесена в архив');
} else {
if (await this.$root.stdDialog.confirm('Подтвердите удаление книги из архива:', ' ')) {
await bookManager.delRecentBooks([{key: item.key}], 2);
this.$root.notify.info('Книга удалено безвозвратно');
}
} }
} }
} }
async handleRestore(key) { async handleRestore(item) {
await bookManager.restoreRecentBook({key}); if (item.group) {
this.$root.notify.info('Восстановлено из архива'); const keys = [{key: item.key}];
for (const book of item.group)
keys.push({key: book.key});
await bookManager.restoreRecentBooks(keys);
this.$root.notify.info(`Группа книг (всего ${keys.length}) восстановлена из архива`);
} else {
await bookManager.restoreRecentBooks([{key: item.key}]);
this.$root.notify.info('Книга восстановлена из архива');
}
} }
async loadBook(item, force = false) { async loadBook(item, force = false) {

View File

@@ -467,7 +467,7 @@ class BookManager {
async getRecentBook(value) { async getRecentBook(value) {
return this.recent[value.key]; return this.recent[value.key];
} }
/*
async delRecentBook(value, delFlag = 1) { async delRecentBook(value, delFlag = 1) {
const item = this.recent[value.key]; const item = this.recent[value.key];
item.deleted = delFlag; item.deleted = delFlag;
@@ -479,13 +479,37 @@ class BookManager {
await this.recentSetItem(item); await this.recentSetItem(item);
this.emit('recent-deleted', value.key); this.emit('recent-deleted', value.key);
} }
*/
async delRecentBooks(values, delFlag = 1) {
for (const value of values) {
const item = this.recent[value.key];
item.deleted = delFlag;
if (this.recentLastKey == value.key) {
await this.recentSetLastKey(null);
}
await this.recentSetItem(item);
}
this.emit('recent-deleted');
}
/*
async restoreRecentBook(value) { async restoreRecentBook(value) {
const item = this.recent[value.key]; const item = this.recent[value.key];
item.deleted = 0; item.deleted = 0;
await this.recentSetItem(item); await this.recentSetItem(item);
} }
*/
async restoreRecentBooks(values) {
for (const value of values) {
const item = this.recent[value.key];
item.deleted = 0;
await this.recentSetItem(item);
}
}
async setCheckBuc(value, checkBuc) { async setCheckBuc(value, checkBuc) {
const item = this.recent[value.key]; const item = this.recent[value.key];