Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f4a52de3
Commit
f4a52de3
authored
Nov 08, 2016
by
Regis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pagination works
parent
3d9e368e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
44 deletions
+48
-44
app/assets/javascripts/vue_pagination/index.js.es6
app/assets/javascripts/vue_pagination/index.js.es6
+45
-42
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
+3
-2
No files found.
app/assets/javascripts/vue_pagination/index.js.es6
View file @
f4a52de3
/* global Vue, gl */
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign
, no-plusplus
*/
((gl) => {
gl.VueGlPagination = Vue.extend({
...
...
@@ -26,61 +26,64 @@
computed: {
last() { return Math.ceil(+this.count / 5); },
getItems() {
const total = +this.count;
const page = +this.pagenum;
const items = [];
const pages = this.createSection(+this.last + 1);
pages.shift();
if (+this.pagenum > 1) items.push({ text: 'First', first: true });
if (page > 1) {
items.push({ title: '<< First', where: 1 });
}
if (page > 1) {
items.push({ title: 'Prev', where: page - 1 });
} else {
items.push({ title: 'Prev', where: page - 1, disabled: true });
}
items.push({ text: 'Prev', prev: true, class: this.prevstatus() });
if (page > 6) {
items.push({ title: '...', separator: true });
}
pages.forEach(i => items.push({ text: i, number: true }));
const start = Math.max(page - 4, 1);
const end = Math.min(page + 4, total);
let nextDisabled = false;
if (+this.pagenum === this.last) { nextDisabled = true; }
items.push({ text: 'Next', next: true, disabled: nextDisabled });
for (let i = start; i <= end; i++) {
const isActive = i === page;
items.push({ title: i, active: isActive, where: i });
}
if (+this.pagenum !== this.last) items.push({ text: 'Last »', last: true });
if (total - page > 4) {
items.push({ title: '...', separator: true });
}
if (page === total) {
items.push({ title: 'Next', where: page + 1, disabled: true });
} else if (total - page >= 1) {
items.push({ title: 'Next', where: page + 1 });
}
if (total - page >= 1) {
items.push({ title: 'Last >>', where: total });
}
return items;
},
},
template: `
<div class="gl-pagination">
<ul class="pagination clearfix" v-for='(item, i) in getItems'>
<!-- if defined as the first button, render first -->
<li
v-if='item.first'
>
<span @click='changepage($event)'>{{item.text}}</span>
</li>
<!-- if defined as the prev button, render prev -->
<li
:class="{disabled: prevstatus(i)}"
v-if='item.prev'
>
<span @click='changepage($event)'>{{item.text}}</span>
</li>
<!-- if defined as the next button, render next -->
<li
v-if='item.next'
:class="{disabled: item.disabled}"
>
<span @click='changepage($event)'>{{item.text}}</span>
</li>
<!-- if defined as the last button, render last -->
<li
v-if='item.last'
:class="{disabled: item.disabled}"
>
<span @click='changepage($event, last)'>{{item.text}}</span>
</li>
<!-- if defined as the number button, render number -->
<ul class="pagination clearfix" v-for='item in getItems'>
<li
:class="{active: pagestatus((i))}"
v-if='item.number'
:class='{
separator: item.separator,
active: item.active,
disabled: item.disabled
}'
>
<span @click='changepage($event)'>{{item.text}}</span>
<span
@click="changepage($event, item.where)"
>
{{item.title}}
</span>
</li>
</ul>
</div>
...
...
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
View file @
f4a52de3
...
...
@@ -37,11 +37,12 @@
},
changepage(event, last) {
const text = event.target.innerText;
if (text === '...') return;
if (/^-?[\d.]+(?:e-?\d+)?$/.test(text)) this.pagenum = +text;
if (text === 'Last
»
') this.pagenum = last;
if (text === 'Last
>>
') this.pagenum = last;
if (text === 'Next') this.pagenum = +this.pagenum + 1;
if (text === 'Prev') this.pagenum = +this.pagenum - 1;
if (text === 'First') this.pagenum = 1;
if (text === '
<<
First') this.pagenum = 1;
window.history.pushState({}, null, `?p=${this.pagenum}`);
clearInterval(this.intervalId);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment