diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index e99836f..57dcb14 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -67,7 +67,7 @@
- Найдено {{ totalFound }} авторов + {{ foundAuthorsMessage }}
Ничего не найдено @@ -76,7 +76,7 @@
-
+
Страница
@@ -87,14 +87,17 @@ из {{ totalPages }}
+
+
-
- {{ item.value }} +
+ {{ item.key }} {{ item.name }}
+ -
+
Страница
@@ -105,6 +108,7 @@ из {{ totalPages }}
+
@@ -255,18 +259,26 @@ class Search { this.lastScrollTop = curScrollTop; } + get foundAuthorsMessage() { + return `Найден${utils.wordEnding(this.totalFound, 2)} ${this.totalFound} автор${utils.wordEnding(this.totalFound)}`; + } + updatePageCount() { - this.totalPages = Math.floor(this.totalFound/this.limit); + this.totalPages = Math.ceil(this.totalFound/this.limit); this.totalPages = (this.totalPages < 1 ? 1 : this.totalPages); if (this.page > this.totalPages) this.page = 1; } + authorClick(authorName) { + this.author = `=${authorName}`; + } + async updateTableData() { let result = []; for (const rec of this.searchResult.author) { - result.push({key: rec.id, value: `${rec.id} ${rec.author.replace(/,/g, ', ')}`}); + result.push({key: rec.id, type: 'author', value: rec.author, name: rec.author.replace(/,/g, ', ')}); } this.tableData = result; diff --git a/client/share/utils.js b/client/share/utils.js index 3fe79a0..3b3dbfb 100644 --- a/client/share/utils.js +++ b/client/share/utils.js @@ -28,3 +28,17 @@ export function keyEventToCode(event) { return result.join('+'); } +export function wordEnding(num, type = 0) { + const endings = [ + ['ов', '', 'а', 'а', 'а', 'ов', 'ов', 'ов', 'ов', 'ов'], + ['й', 'я', 'и', 'и', 'и', 'й', 'й', 'й', 'й', 'й'], + ['о', '', 'о', 'о', 'о', 'о', 'о', 'о', 'о', 'о'], + ['ий', 'ие', 'ия', 'ия', 'ия', 'ий', 'ий', 'ий', 'ий', 'ий'] + ]; + const deci = num % 100; + if (deci > 10 && deci < 20) { + return endings[type][0]; + } else { + return endings[type][num % 10]; + } +}