extract param helper to pagination dir
This commit is contained in:
parent
bff8e5bad9
commit
2ecb65b8c4
3 changed files with 18 additions and 23 deletions
|
@ -1,6 +1,8 @@
|
|||
/* global Vue, gl */
|
||||
/* eslint-disable no-param-reassign, no-plusplus */
|
||||
|
||||
//= require ./param_helper.js.es6
|
||||
|
||||
((gl) => {
|
||||
const PAGINATION_UI_BUTTON_LIMIT = 4;
|
||||
const SPREAD = '...';
|
||||
|
@ -9,16 +11,6 @@
|
|||
const FIRST = '<< First';
|
||||
const LAST = 'Last >>';
|
||||
|
||||
const getParameterByName = (name) => {
|
||||
const url = window.location.href;
|
||||
name = name.replace(/[[\]]/g, '\\$&');
|
||||
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
||||
const results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
gl.VueGlPagination = Vue.extend({
|
||||
props: [
|
||||
'change',
|
||||
|
@ -27,7 +19,7 @@
|
|||
methods: {
|
||||
changepage(e) {
|
||||
let pagenum = this.pageInfo.page;
|
||||
let apiScope = getParameterByName('scope');
|
||||
let apiScope = gl.getParameterByName('scope');
|
||||
|
||||
if (!apiScope) apiScope = 'all';
|
||||
|
||||
|
|
13
app/assets/javascripts/vue_pagination/param_helper.js.es6
Normal file
13
app/assets/javascripts/vue_pagination/param_helper.js.es6
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* eslint-disable no-param-reassign */
|
||||
|
||||
((w) => {
|
||||
w.getParameterByName = (name) => {
|
||||
const url = window.location.href;
|
||||
name = name.replace(/[[\]]/g, '\\$&');
|
||||
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
||||
const results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
||||
};
|
||||
})(window.gl || (window.gl = {}));
|
|
@ -2,16 +2,6 @@
|
|||
/* eslint-disable no-param-reassign, no-bitwise*/
|
||||
|
||||
((gl) => {
|
||||
const getParameterByName = (name) => {
|
||||
const url = window.location.href;
|
||||
name = name.replace(/[[\]]/g, '\\$&');
|
||||
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
||||
const results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
gl.VuePipelines = Vue.extend({
|
||||
components: {
|
||||
runningPipeline: gl.VueRunningPipeline,
|
||||
|
@ -38,8 +28,8 @@
|
|||
},
|
||||
props: ['scope', 'store'],
|
||||
created() {
|
||||
const pagenum = getParameterByName('p');
|
||||
const scope = getParameterByName('scope');
|
||||
const pagenum = gl.getParameterByName('p');
|
||||
const scope = gl.getParameterByName('scope');
|
||||
if (pagenum) this.pagenum = pagenum;
|
||||
if (scope) this.apiScope = scope;
|
||||
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
|
||||
|
|
Loading…
Reference in a new issue