Newer
Older
<div
v-if="maxPage > 1"
class="ui pagination menu component-pagination"
role="navigation"
:aria-label="labels.pagination"
>
<a
href
role="button"
:aria-label="labels.previousPage"
Eliot Berriot
committed
@click.prevent.stop="selectPage(current - 1)"
href
:class="[{'active': page === current}, {'disabled': page === 'skip'}, 'item']"
Eliot Berriot
committed
@click.prevent.stop="selectPage(page)"
<span v-if="page !== 'skip'">{{ page }}</span>
<span v-else>…</span>
role="button"
:aria-label="labels.nextPage"
:class="[{'disabled': current + 1 > maxPage}, 'item']"
Eliot Berriot
committed
@click.prevent.stop="selectPage(current + 1)"
import { range as lodashRange, sortBy, uniq } from 'lodash-es'
current: { type: Number, default: 1 },
paginateBy: { type: Number, default: 25 },
compact: { type: Boolean, default: false }
return {
pagination: this.$pgettext('Content/*/Hidden text/Noun', 'Pagination'),
previousPage: this.$pgettext('Content/*/Link', 'Previous Page'),
nextPage: this.$pgettext('Content/*/Link', 'Next Page')
}
},
pages: function () {
const range = 2
const current = this.current
const beginning = lodashRange(1, Math.min(this.maxPage, 1 + range))
const middle = lodashRange(
Math.max(1, current - range + 1),
Math.min(this.maxPage, current + range)
)
const end = lodashRange(this.maxPage, Math.max(1, this.maxPage - range))
let allowed = beginning.concat(middle, end)
allowed = uniq(allowed)
allowed = sortBy(allowed, [
e => {
return e
}
])
consecutive = false
} else {
if (!last) {
consecutive = true
} else {
consecutive = last + 1 === p
}
}
if (consecutive) {
final.push(p)
} else {
final.push(p)
}
}
})
return final
return Math.ceil(this.total / this.paginateBy)
}
},
methods: {
if (page > this.maxPage || page < 1) {
return
}