From 561e7fdad04ebaba7c8bb854c80d51c1f884ecd6 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Tue, 7 Dec 2021 09:33:24 +0100 Subject: [PATCH] evaluate length of dictionaries individually. Fix missing results bug --- src/components/DictionaryView.vue | 14 +++++++------- src/components/SearchResults.vue | 13 +++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index f071317a..455f237c 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -186,15 +186,15 @@ function navigate_to_query(self, word) { let params = {w: query.match || query.q, dict: self.lang, scope: self.scope, meta: 'y'} let offset = 0 if (self.page) { - offset = 10 * (self.page -1) + offset = self.perPage * (self.page -1) } if (self.pos_selected != "ALL") params.wc = self.pos_selected api.get('articles?', {params}).then((response) => { self.article_info = response.data self.search_results = {} Promise.all([ - load_articles(self, query, offset, 10, "bm"), - load_articles(self, query, offset, 10, "nn") + load_articles(self, query, offset, self.perPage, "bm"), + load_articles(self, query, offset, self.perPage, "nn") ]) .then(() => { self.waiting_for_articles = false @@ -236,7 +236,7 @@ export default { pos_selected: "ALL", article_info: null, page: 1, - perPage: null, + perPage: 10, } }, computed: { @@ -315,14 +315,14 @@ export default { this.$router.push({path, query}) let offset = 0 if (this.page) { - offset = 10 * (this.page -1) + offset = this.perPage * (this.page -1) } console.log(this) let self = this Promise.all([ - load_articles(this, query, offset, 10, "bm"), - load_articles(this, query, offset, 10, "nn")]).then(() => { + load_articles(this, query, offset, this.perPage, "bm"), + load_articles(this, query, offset, this.perPage, "nn")]).then(() => { history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang, diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index a97c1802..7d5da933 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -1,7 +1,7 @@ <template> <section id="search_results"> - <span flat color="tertiary" class = "pagination" v-if="!$parent.article && $parent.article_info && $parent.total_results() > 20"> - <v-pagination @input="$emit('update-page')" v-model="$parent.page" :class="$vuetify.breakpoint.name" :total-visible="$vuetify.breakpoint.smAndDown ? 5 : 8" circle :length="Math.ceil($parent.total_results()/20)"></v-pagination> + <span flat color="tertiary" class = "pagination" v-if="!$parent.article && $parent.article_info && (count_bm > $parent.perPage || count_nn > $parent.perPage)"> + <v-pagination @input="$emit('update-page')" v-model="$parent.page" :class="$vuetify.breakpoint.name" :total-visible="$vuetify.breakpoint.smAndDown ? 5 : 8" circle :length="Math.ceil(Math.max(count_bm, count_nn)/$parent.perPage)"></v-pagination> <span class="result-counts"> <span class="total-results">{{$parent.total_results()}} treff </span> <span v-if="$parent.lang=='bm,nn'" class="dict-counts"> | {{$vuetify.breakpoint.mdAndDown? 'bokmål': 'Bokmålsordboka'}}: {{count_bm}} | {{$vuetify.breakpoint.mdAndDown? 'nynorsk': 'Nynorskordboka'}}: {{count_nn}}</span> @@ -81,14 +81,23 @@ export default { return this.results_nn.reduce((hash, hit) => (hash + hit.article_id) % 10000, 0) }, count_bm: function(){ + if (this.$parent.article_info.articles.bm ){ + console.log(this.$parent.article_info.articles.bm.length) return this.$parent.article_info.articles.bm.length } + else { + return 0 + } }, count_nn: function(){ if (this.$parent.article_info.articles.nn ){ + console.log(this.$parent.article_info.articles.nn.length) return this.$parent.article_info.articles.nn.length } + else { + return 0 + } } }, methods: { -- GitLab