fix pagination buttons for admin/user and notifications

This commit is contained in:
Moriz Wahl 2020-09-21 19:07:04 +02:00
parent 08aaf9c7a6
commit e7c76c1622
2 changed files with 17 additions and 11 deletions

View File

@ -21,8 +21,9 @@
<template>
<pagination-buttons
v-if="activeResourceCount > pageSize"
:hasMoreResults="hasMoreResults"
:hasPreviousResult="hasPreviousResult"
:hasNext="hasNext"
:showPageCounter="true"
:hasPrevious="hasPrevious"
:activePage="activePage"
:activeResourceCount="activeResourceCount"
@back="previousResults"
@ -53,9 +54,10 @@
<pagination-buttons
v-if="activeResourceCount > pageSize"
:hasMoreResults="hasMoreResults"
:hasPreviousResult="hasPreviousResult"
:hasNext="hasNext"
:hasPrevious="hasPrevious"
:activePage="activePage"
:showPageCounter="true"
:activeResourceCount="activeResourceCount"
@back="previousResults"
@next="nextResults"
@ -161,13 +163,13 @@ export default {
},
]
},
hasPreviousResult() {
hasPrevious() {
if (this.activeTab === 'Post') return this.postsOffset > 0
if (this.activeTab === 'User') return this.usersOffset > 0
if (this.activeTab === 'Hashtag') return this.hashtagsOffset > 0
return false
},
hasMoreResults() {
hasNext() {
if (this.activeTab === 'Post') return (this.postPage + 1) * this.pageSize < this.postCount
if (this.activeTab === 'User') return (this.userPage + 1) * this.pageSize < this.userCount
if (this.activeTab === 'Hashtag')

View File

@ -1,20 +1,20 @@
<template>
<div class="pagination-buttons">
<base-button
v-if="hasPreviousResult"
v-if="hasPrevious"
@click="$emit('back')"
icon="arrow-left"
circle
class="previous-button"
/>
<span class="pagination-pageCount">
<span v-if="showPageCounter" class="pagination-pageCount">
{{ $t('search.page') }} {{ activePage + 1 }} /
{{ Math.floor((activeResourceCount - 1) / pageSize) + 1 }}
</span>
<base-button
v-if="hasMoreResults"
v-if="hasNext"
@click="$emit('next')"
icon="arrow-right"
circle
@ -31,11 +31,11 @@ export default {
type: Number,
default: 24,
},
hasMoreResults: {
hasNext: {
type: Boolean,
default: false,
},
hasPreviousResult: {
hasPrevious: {
type: Boolean,
},
activePage: {
@ -50,6 +50,10 @@ export default {
type: Number,
default: 0,
},
showPageCounter: {
type: Boolean,
default: false,
},
},
}
</script>