From d09ad5350a6a2bd41729efb5c23375f5fc71f8a5 Mon Sep 17 00:00:00 2001 From: ManikanthDindigala <dindigala@sub.uni-goettingen.de> Date: Mon, 6 Sep 2021 13:07:33 +0200 Subject: [PATCH] feat: returning from tido to the respective search hit list page --- src/.vuepress/components/SearchPage.vue | 25 +++++++++---------- src/.vuepress/components/SearchResultList.vue | 6 ++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/.vuepress/components/SearchPage.vue b/src/.vuepress/components/SearchPage.vue index a073840..f8b8d72 100644 --- a/src/.vuepress/components/SearchPage.vue +++ b/src/.vuepress/components/SearchPage.vue @@ -42,6 +42,7 @@ :items="items" :message="message" :query="query" + :page="page" /> <div @@ -82,19 +83,25 @@ export default { total: 0, showPlaceholder: false, showNoResult: false, + page: 1, }; }, watch:{ - page: function() { + page: function(page) { this.loading = true; - const from = this.size * (this.page - 1); + const from = this.size * (page - 1); + this.$router.push({ query: { ...this.$route.query, searchTerm:this.query.trim(),page } }); this.search(this.query.trim(), from, this.size); }, }, mounted(){ + const page = this.$route.query?.page; + if(page){ + this.page = parseInt(page); + } if(this.$route.query?.searchTerm) { - this.onSearchInput(this.$route.query.searchTerm); + this.onSearchInput(this.$route.query.searchTerm,this.page); } else { this.showPlaceholder = true; } @@ -117,9 +124,8 @@ export default { }, }, methods: { - onSearchInput(query) { + onSearchInput(query,page) { this.query = query; - this.page = 1; this.resetList(); this.showPlaceholder = false; @@ -128,7 +134,7 @@ export default { this.search(this.query.trim(), 0, this.size); if (this.$route.query.searchTerm !== query) { - this.$router.push({ query: { ...this.$route.query, searchTerm:query } }); + this.$router.push({ query: { ...this.$route.query, searchTerm:query,page:page || this.page } }); } }, async search(value, from, size) { @@ -162,13 +168,6 @@ export default { this.loading = false; } }, - scrollUp() { - window.scrollTo({ - top: 0, - left: 0, - behavior: 'smooth', - }); - }, resetList() { this.items = []; this.distinctSheets = 0; diff --git a/src/.vuepress/components/SearchResultList.vue b/src/.vuepress/components/SearchResultList.vue index e662293..69f712d 100644 --- a/src/.vuepress/components/SearchResultList.vue +++ b/src/.vuepress/components/SearchResultList.vue @@ -54,6 +54,10 @@ export default { type: Array, default: () => [], }, + page: { + type: Number, + default: () => 1, + }, }, computed: { viewerBaseUrl() { @@ -72,7 +76,7 @@ export default { } else if (item.lang === 'syc') { language = 'syriac'; } - return `${this.viewerBaseUrl}/${language}/#/?itemurl=${item.item}&source=external&searchTerm=${item.searchTerm}&redirectUrl=${this.getPath}`; + return `${this.viewerBaseUrl}/${language}/#/?itemurl=${item.item}&source=external&searchTerm=${item.searchTerm}&redirectUrl=${this.getPath}&page=${this.page}`; }, }, watch: { -- GitLab