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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d0a5428a
Commit
d0a5428a
authored
Nov 18, 2016
by
Regis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
constant variable hardcoding
parent
758cdf54
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
20 deletions
+39
-20
app/assets/javascripts/vue_pagination/index.js.es6
app/assets/javascripts/vue_pagination/index.js.es6
+21
-11
app/assets/javascripts/vue_pipelines_index/index.js.es6
app/assets/javascripts/vue_pipelines_index/index.js.es6
+1
-1
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
+12
-6
app/assets/javascripts/vue_pipelines_index/store.js.es6
app/assets/javascripts/vue_pipelines_index/store.js.es6
+5
-2
No files found.
app/assets/javascripts/vue_pagination/index.js.es6
View file @
d0a5428a
...
@@ -2,6 +2,14 @@
...
@@ -2,6 +2,14 @@
/* eslint-disable no-param-reassign, no-plusplus */
/* eslint-disable no-param-reassign, no-plusplus */
((gl) => {
((gl) => {
const PAGINATION_SIZE = 30;
const PAGINATION_UI_BUTTON_LIMIT = 4;
const SPREAD = '...';
const PREV = 'Prev';
const NEXT = 'Next';
const FIRST = '<< First';
const LAST = 'Last >>';
gl.VueGlPagination = Vue.extend({
gl.VueGlPagination = Vue.extend({
props: [
props: [
'changepage',
'changepage',
...
@@ -10,40 +18,42 @@
...
@@ -10,40 +18,42 @@
],
],
computed: {
computed: {
last() {
last() {
return Math.ceil(+this.count /
30
);
return Math.ceil(+this.count /
PAGINATION_SIZE
);
},
},
getItems() {
getItems() {
const total = +this.last;
const total = +this.last;
const page = +this.pagenum;
const page = +this.pagenum;
const items = [];
const items = [];
if (page > 1) items.push({ title:
'<< First'
, where: 1 });
if (page > 1) items.push({ title:
FIRST
, where: 1 });
if (page > 1) {
if (page > 1) {
items.push({ title:
'Prev'
, where: page - 1 });
items.push({ title:
PREV
, where: page - 1 });
} else {
} else {
items.push({ title:
'Prev'
, where: page - 1, disabled: true });
items.push({ title:
PREV
, where: page - 1, disabled: true });
}
}
if (page > 6) items.push({ title:
'...'
, separator: true });
if (page > 6) items.push({ title:
SPREAD
, separator: true });
const start = Math.max(page -
4
, 1);
const start = Math.max(page -
PAGINATION_UI_BUTTON_LIMIT
, 1);
const end = Math.min(page +
4
, total);
const end = Math.min(page +
PAGINATION_UI_BUTTON_LIMIT
, total);
for (let i = start; i <= end; i++) {
for (let i = start; i <= end; i++) {
const isActive = i === page;
const isActive = i === page;
items.push({ title: i, active: isActive, where: i });
items.push({ title: i, active: isActive, where: i });
}
}
if (total - page > 4) items.push({ title: '...', separator: true });
if (total - page > PAGINATION_UI_BUTTON_LIMIT) {
items.push({ title: SPREAD, separator: true });
}
if (page === total) {
if (page === total) {
items.push({ title:
'Next'
, where: page + 1, disabled: true });
items.push({ title:
NEXT
, where: page + 1, disabled: true });
} else if (total - page >= 1) {
} else if (total - page >= 1) {
items.push({ title:
'Next'
, where: page + 1 });
items.push({ title:
NEXT
, where: page + 1 });
}
}
if (total - page >= 1) items.push({ title:
'Last >>'
, where: total });
if (total - page >= 1) items.push({ title:
LAST
, where: total });
return items;
return items;
},
},
...
...
app/assets/javascripts/vue_pipelines_index/index.js.es6
View file @
d0a5428a
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
store: new gl.PipelineStore(),
store: new gl.PipelineStore(),
},
},
components: {
components: {
'vue-pipelines': gl.VuePipe
L
ines,
'vue-pipelines': gl.VuePipe
l
ines,
},
},
template: `
template: `
<div>
<div>
...
...
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
View file @
d0a5428a
...
@@ -2,7 +2,13 @@
...
@@ -2,7 +2,13 @@
/* eslint-disable no-param-reassign, no-bitwise*/
/* eslint-disable no-param-reassign, no-bitwise*/
((gl) => {
((gl) => {
gl.VuePipeLines = Vue.extend({
const SPREAD = '...';
const PREV = 'Prev';
const NEXT = 'Next';
const FIRST = '<< First';
const LAST = 'Last >>';
gl.VuePipelines = Vue.extend({
components: {
components: {
runningPipeline: gl.VueRunningPipeline,
runningPipeline: gl.VueRunningPipeline,
pipelineActions: gl.VuePipelineActions,
pipelineActions: gl.VuePipelineActions,
...
@@ -41,12 +47,12 @@
...
@@ -41,12 +47,12 @@
methods: {
methods: {
changepage(e, last) {
changepage(e, last) {
const text = e.target.innerText;
const text = e.target.innerText;
if (text ===
'...'
) return;
if (text ===
SPREAD
) return;
if (/^-?[\d.]+(?:e-?\d+)?$/.test(text)) this.pagenum = +text;
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 ===
NEXT
) this.pagenum = +this.pagenum + 1;
if (text ===
'Prev'
) 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}`);
window.history.pushState({}, null, `?p=${this.pagenum}`);
clearInterval(this.intervalId);
clearInterval(this.intervalId);
...
...
app/assets/javascripts/vue_pipelines_index/store.js.es6
View file @
d0a5428a
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign */
((gl) => {
((gl) => {
const PAGINATION_LIMIT = 31;
const SLICE_LIMIT = 29;
class PipelineUpdater {
class PipelineUpdater {
constructor(pipelines) {
constructor(pipelines) {
this.pipelines = pipelines;
this.pipelines = pipelines;
...
@@ -11,8 +14,8 @@
...
@@ -11,8 +14,8 @@
});
});
};
};
this.currentPageSlicer = (update) => {
this.currentPageSlicer = (update) => {
if (update.length <
= 30
) return update;
if (update.length <
PAGINATION_LIMIT
) return update;
return update.slice(0,
29
);
return update.slice(0,
SLICE_LIMIT
);
};
};
}
}
...
...
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