-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathBulmaPagination.vue
85 lines (84 loc) · 2.26 KB
/
BulmaPagination.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
<nav v-if="tablePagination && tablePagination.last_page > 1" :class="['pagination', location]">
<a @click="loadPage('prev')"
:class="['pagination-previous', isOnFirstPage ? css.disabledClass : '']"
v-html="prevText"
></a>
<a @click="loadPage('next')"
:class="['pagination-next', isOnLastPage ? css.disabledClass : '']"
v-html="nextText"
></a>
<ul :class="[css.listClass]">
<template v-if="totalPagesLessThanWindowSize">
<li v-for="n in totalPage">
<a @click="loadPage(n)"
:class="[css.linkClass, isCurrentPage(n) ? css.activeClass : '']"
v-html="n"
></a>
</li>
</template>
<template v-else>
<li>
<a @click="loadPage(1)"
:class="[css.linkClass, isOnFirstPage ? css.disabledClass : '']"
>1</a>
</li>
<li>
<span :class="css.ellipsisClass">…</span>
</li>
<li v-for="n in windowSize-2">
<a @click="loadPage(windowStart+n)"
:class="[css.linkClass, isCurrentPage(windowStart+n) ? css.activeClass : '']"
v-html="windowStart+n">
</a>
</li>
<li>
<span :class="css.ellipsisClass">…</span>
</li>
<li>
<a @click="loadPage(totalPage)"
:class="[css.linkClass, isOnLastPage ? css.disabledClass : '']"
v-html="totalPage">
</a>
</li>
</template>
</ul>
</nav>
</template>
<script>
import PaginationMixin from 'vuetable-2/src/components/VuetablePaginationMixin'
export default {
mixins: [PaginationMixin],
props: {
location: {
type: String,
default: ''
},
prevText: {
type: String,
default: 'Previous'
},
nextText: {
type: String,
default: 'Next page'
},
css: {
type: Object,
default () {
return {
activeClass: 'is-current',
disabledClass: 'is-disabled',
listClass: 'pagination-list',
linkClass: 'pagination-link',
ellipsisClass: 'pagination-ellipsis'
}
}
}
},
computed: {
totalPagesLessThanWindowSize () {
return this.totalPage < (this.onEachSide * 2) + 4
}
}
}
</script>