fix: missing pagination on search results (#942)
This commit is contained in:
parent
9f16d3e3fa
commit
9c40975aeb
@ -16,14 +16,14 @@
|
|||||||
.subheading {{$t('common:header.searchNoResult')}}
|
.subheading {{$t('common:header.searchNoResult')}}
|
||||||
template(v-if='results && results.length > 0')
|
template(v-if='results && results.length > 0')
|
||||||
v-subheader.white--text {{$t('common:header.searchResultsCount', { total: response.totalHits })}}
|
v-subheader.white--text {{$t('common:header.searchResultsCount', { total: response.totalHits })}}
|
||||||
v-list.search-results-items.radius-7.py-0(two-line)
|
v-list.search-results-items.radius-7.py-0(two-line, dense)
|
||||||
template(v-for='(item, idx) of results')
|
template(v-for='(item, idx) of results')
|
||||||
v-list-item(@click='goToPage(item)', :key='item.id', :class='idx === cursor ? `highlighted` : ``')
|
v-list-item(@click='goToPage(item)', :key='item.id', :class='idx === cursor ? `highlighted` : ``')
|
||||||
v-list-item-avatar(tile)
|
v-list-item-avatar(tile)
|
||||||
img(src='/svg/icon-selective-highlighting.svg')
|
img(src='/svg/icon-selective-highlighting.svg')
|
||||||
v-list-item-content
|
v-list-item-content
|
||||||
v-list-item-title(v-html='item.title')
|
v-list-item-title(v-html='item.title')
|
||||||
v-list-item-subtitle(v-html='item.description')
|
v-list-item-subtitle.caption(v-html='item.description')
|
||||||
.caption.grey--text(v-html='item.path')
|
.caption.grey--text(v-html='item.path')
|
||||||
v-list-item-action
|
v-list-item-action
|
||||||
v-chip(label, outlined) {{item.locale.toUpperCase()}}
|
v-chip(label, outlined) {{item.locale.toUpperCase()}}
|
||||||
@ -33,6 +33,7 @@
|
|||||||
dark
|
dark
|
||||||
v-model='pagination'
|
v-model='pagination'
|
||||||
:length='paginationLength'
|
:length='paginationLength'
|
||||||
|
circle
|
||||||
)
|
)
|
||||||
template(v-if='suggestions && suggestions.length > 0')
|
template(v-if='suggestions && suggestions.length > 0')
|
||||||
v-subheader.white--text.mt-3 {{$t('common:header.searchDidYouMean')}}
|
v-subheader.white--text.mt-3 {{$t('common:header.searchDidYouMean')}}
|
||||||
@ -68,6 +69,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
cursor: 0,
|
cursor: 0,
|
||||||
pagination: 1,
|
pagination: 1,
|
||||||
|
perPage: 10,
|
||||||
response: {
|
response: {
|
||||||
results: [],
|
results: [],
|
||||||
suggestions: [],
|
suggestions: [],
|
||||||
@ -82,7 +84,8 @@ export default {
|
|||||||
searchRestrictLocale: sync('site/searchRestrictLocale'),
|
searchRestrictLocale: sync('site/searchRestrictLocale'),
|
||||||
searchRestrictPath: sync('site/searchRestrictPath'),
|
searchRestrictPath: sync('site/searchRestrictPath'),
|
||||||
results() {
|
results() {
|
||||||
return this.response.results ? this.response.results : []
|
const currentIndex = (this.pagination - 1) * this.perPage
|
||||||
|
return this.response.results ? _.slice(this.response.results, currentIndex, currentIndex + this.perPage) : []
|
||||||
},
|
},
|
||||||
hits() {
|
hits() {
|
||||||
return this.response.totalHits ? this.response.totalHits : 0
|
return this.response.totalHits ? this.response.totalHits : 0
|
||||||
@ -91,7 +94,7 @@ export default {
|
|||||||
return this.response.suggestions ? this.response.suggestions : []
|
return this.response.suggestions ? this.response.suggestions : []
|
||||||
},
|
},
|
||||||
paginationLength() {
|
paginationLength() {
|
||||||
return (this.response.totalHits > 0) ? 0 : Math.ceil(this.response.totalHits / 10)
|
return (this.response.totalHits > 0) ? Math.ceil(this.response.totalHits / this.perPage) : 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
Loading…
Reference in New Issue
Block a user