From fc630923a4a11dcc154d0a8c210e609b09783d21 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 12 Jul 2022 18:50:35 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecentBooksPage/RecentBooksPage.vue | 154 ++++++++---------- 1 file changed, 67 insertions(+), 87 deletions(-) diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index ede6a354..c602bbdb 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -39,10 +39,35 @@ + + + Метод сортировки + + + + + @@ -131,90 +156,6 @@ - - @@ -239,6 +180,9 @@ const componentOptions = { search() { this.updateTableData(); }, + sortMethod() { + this.updateTableData(); + }, settings() { this.loadSettings(); }, @@ -271,6 +215,8 @@ class RecentBooksPage { //this.$refs.input.focus();//плохо на планшетах }); + this.inited = true; + (async() => { this.showBar(); await this.updateTableData(); @@ -289,6 +235,9 @@ class RecentBooksPage { } async updateTableData() { + if (!this.inited) + return; + await this.lock.get(); try { let result = []; @@ -346,7 +295,6 @@ class RecentBooksPage { //для сортировки loadTimeRaw, touchTimeRaw: book.touchTime, - descString: `${author}${title}${perc}${textLen}`, }); } @@ -385,6 +333,18 @@ class RecentBooksPage { case 'touchTimeAsc': result.sort((a, b) => a.touchTimeRaw - b.touchTimeRaw); break; + case 'authorDesc': + result.sort((a, b) => b.desc.author.localeCompare(a.desc.author)); + break; + case 'authorAsc': + result.sort((a, b) => a.desc.author.localeCompare(b.desc.author)); + break; + case 'titleDesc': + result.sort((a, b) => b.desc.title.localeCompare(a.desc.title)); + break; + case 'titleAsc': + result.sort((a, b) => a.desc.title.localeCompare(b.desc.title)); + break; } //группировка @@ -540,6 +500,12 @@ class RecentBooksPage { this.updateTableData(); } + sortMethodSelected() { + const newSettings = _.cloneDeep(this.settings); + newSettings.recentSortMethod = this.sortMethod; + this.commit('reader/setSettings', newSettings); + } + async scrollToActiveBook() { this.lockScroll = true; try { @@ -586,6 +552,20 @@ class RecentBooksPage { } } + + get sortMethodOptions() { + return [ + {label: ' Время загрузки', value: 'loadTimeDesc'}, + {label: ' Время загрузки', value: 'loadTimeAsc'}, + {label: ' Время чтения', value: 'touchTimeDesc'}, + {label: ' Время чтения', value: 'touchTimeAsc'}, + {label: ' Автор', value: 'authorDesc'}, + {label: ' Автор', value: 'authorAsc'}, + {label: ' Название', value: 'titleDesc'}, + {label: ' Название', value: 'titleAsc'}, + ]; + } + close() { this.$emit('recent-books-close'); }