Commit 31af345b authored by Regis's avatar Regis

fix prev button being misplaced

parent fa2f052b
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
((gl) => { ((gl) => {
gl.VueGlPagination = Vue.extend({ gl.VueGlPagination = Vue.extend({
data() {
return {
nslice: +this.pagenum,
};
},
props: [ props: [
'changepage', 'changepage',
'count', 'count',
'pagenum', 'pagenum',
], ],
data() {
return {
nslice: +this.pagenum,
};
},
methods: { methods: {
pagenumberstatus(n) { pagenumberstatus(n) {
if (n - 1 === +this.pagenum) return 'active'; if (n - 1 === +this.pagenum) return 'active';
...@@ -24,17 +24,20 @@ ...@@ -24,17 +24,20 @@
}, },
}, },
computed: { computed: {
dynamicpage() {
const section = [...Array(this.upcount).keys()];
section.shift();
this.nslice = +this.pagenum;
this.endcount = +this.pagenum + 5;
return section.slice(+this.pagenum, +this.pagenum + 5);
},
paginationsection() { paginationsection() {
if (this.last < 6 && this.pagenum < 6) { if (this.last < 6 && this.pagenum < 6) {
const pageArray = [...Array(6).keys()]; const pageArray = [...Array(6).keys()];
pageArray.shift(); pageArray.shift();
return pageArray.slice(0, this.upcount); return pageArray.slice(0, this.upcount);
} }
const section = [...Array(this.upcount).keys()]; return this.dynamicpage;
section.shift();
this.nslice = +this.pagenum;
this.endcount = +this.pagenum + 5;
return section.slice(+this.pagenum, +this.pagenum + 5);
}, },
last() { last() {
return Math.ceil(+this.count / 5); return Math.ceil(+this.count / 5);
...@@ -54,7 +57,7 @@ ...@@ -54,7 +57,7 @@
template: ` template: `
<div class="gl-pagination"> <div class="gl-pagination">
<ul class="pagination clearfix" v-for='n in paginationsection'> <ul class="pagination clearfix" v-for='n in paginationsection'>
<li :class='prevstatus(n)' v-if='n - 1 === nslice'> <li :class='prevstatus(n)' v-if='n - 1 === 1'>
<span @click='changepage($event, {where: pagenum - 1})'>Prev</span> <span @click='changepage($event, {where: pagenum - 1})'>Prev</span>
</li> </li>
<li :class='pagenumberstatus(n)' v-if='n >= 2'> <li :class='pagenumberstatus(n)' v-if='n >= 2'>
...@@ -71,16 +74,14 @@ ...@@ -71,16 +74,14 @@
class="next" class="next"
v-if='(n === upcount || n === endcount) && pagenum !== last' v-if='(n === upcount || n === endcount) && pagenum !== last'
> >
<span @click='changepage($event, {where: +pagenum + 1})'> <span @click='changepage($event,{where: +pagenum+1})'>Next</span>
Next
</span>
</li> </li>
<li v-if='n === upcount && upcount > 4 && endspread'> <li v-if='n === upcount && upcount > 4 && endspread'>
<span class="gap">…</span> <span class="gap">…</span>
</li> </li>
<li <li
class="last" class="last"
v-if='(n === upcount || n === endcount) && pagenum !== last' v-if='(n === upcount || n === endcount) && +pagenum !== last'
> >
<span @click='changepage($event, {where: last})'>Last »</span> <span @click='changepage($event, {where: last})'>Last »</span>
</li> </li>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<vue-pipelines <vue-pipelines
:scope='scope' :scope='scope'
:store='store' :store='store'
:count='90' :count='count'
> >
</vue-pipelines> </vue-pipelines>
</div> </div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment