Commit be146a4f authored by Regis's avatar Regis

remove svg api call - more progress on pagination

parent fd10ff30
...@@ -3,14 +3,19 @@ ...@@ -3,14 +3,19 @@
((gl) => { ((gl) => {
gl.VueGlPagination = Vue.extend({ gl.VueGlPagination = Vue.extend({
data() {
return {
nslice: +this.pagenum,
};
},
props: [ props: [
'changepage', 'changepage',
'pages',
'count', 'count',
'pagenum', 'pagenum',
], ],
methods: { methods: {
pagenumberstatus(n) { pagenumberstatus(n) {
console.log(n, this.nslice);
if (n - 1 === +this.pagenum) return 'active'; if (n - 1 === +this.pagenum) return 'active';
return ''; return '';
}, },
...@@ -20,35 +25,46 @@ ...@@ -20,35 +25,46 @@
}, },
}, },
computed: { computed: {
paginationsection() {
if (this.last < 6 && this.pagenum < 6) {
const pageArray = [...Array(6).keys()];
pageArray.shift();
return pageArray.slice(0, this.upcount);
}
const section = [...Array(this.upcount).keys()];
section.shift();
this.nslice = +this.pagenum;
return section.slice(+this.pagenum, +this.pagenum + 5);
},
last() { last() {
return Math.ceil(+this.count / 5); return Math.ceil(+this.count / 5);
}, },
lastpage() {
return `pipelines?p=${this.last}`;
},
upcount() { upcount() {
return +this.last + 1; return +this.last + 1;
}, },
prev() { endspread() {
if (this.pagenum === 1) return 1; if (+this.pagenum < this.last && +this.pagenum > 5) return true;
return this.pagenum - 1; return false
},
begspread() {
if (+this.pagenum > 5 && +this.pagenum < this.last) return true;
return false
}, },
}, },
template: ` template: `
<div class="gl-pagination"> <div class="gl-pagination">
<ul class="pagination clearfix" v-for='n in upcount'> <ul class="pagination clearfix" v-for='n in paginationsection'>
<li :class='prevstatus(n)' v-if='n === 1'> <li :class='prevstatus(n)' v-if='n === 1 || n - 1 === nslice'>
<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-else> <li :class='pagenumberstatus(n)' v-if='n >= 2'>
<span @click='changepage($event)'>{{(n - 1)}}</span> <span @click='changepage($event)'>{{(n - 1)}}</span>
</li> </li>
<!-- <!--
take a slice of current array (up to 5)
if at end make dots dissapear if at end make dots dissapear
if in second slice or more make dots appear in the front if in second slice or more make dots appear in the front
--> -->
<li v-if='n === upcount && upcount > 4'> <li v-if='n === upcount && upcount > 4 && begspread'>
<span class="gap">…</span> <span class="gap">…</span>
</li> </li>
<li class="next" v-if='n === upcount && pagenum !== last'> <li class="next" v-if='n === upcount && pagenum !== last'>
...@@ -56,8 +72,11 @@ ...@@ -56,8 +72,11 @@
Next Next
</span> </span>
</li> </li>
<li v-if='n === upcount && upcount > 4 && endspread'>
<span class="gap">…</span>
</li>
<li class="last" v-if='n === upcount && pagenum !== last'> <li class="last" v-if='n === upcount && pagenum !== last'>
<span @click='changepage($event, {last: last})'>Last »</span> <span @click='changepage($event, {where: last})'>Last »</span>
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<vue-pipelines <vue-pipelines
:scope='scope' :scope='scope'
:store='store' :store='store'
:count='count' :count='90'
> >
</vue-pipelines> </vue-pipelines>
</div> </div>
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
}, },
changepage(event, page = {}) { changepage(event, page = {}) {
if (page) this.pagenum = +event.target.innerText; if (page) this.pagenum = +event.target.innerText;
if (page.last) this.pagenum = +page.last; if (page.where) this.pagenum = +page.where;
if (page.where) this.pagenum = +page.next; if (page.where) this.pagenum = +page.where;
// use p instead of page to avoid making an actual request // use p instead of page to avoid making an actual request
window.history.pushState({}, null, `?p=${this.pagenum}`); window.history.pushState({}, null, `?p=${this.pagenum}`);
......
...@@ -23,14 +23,5 @@ ...@@ -23,14 +23,5 @@
goFetch(); goFetch();
}, 60000); }, 60000);
} }
fetchSvg(type, icon) {
this.$http.get(`/shared/icons/${icon}`)
.then((response) => {
this[type] = JSON.parse(response.body);
}, () => new Flash(
'Something went wrong on our end.'
));
}
}; };
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));
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