diff options
author | Regis <boudinot.regis@yahoo.com> | 2017-01-06 15:27:56 -0700 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2017-01-06 15:27:56 -0700 |
commit | ce996962d6bec0d29664ac3dbe62dcd18630230e (patch) | |
tree | abdf0040eae1959db3781da44cc25e3ec0c071a5 | |
parent | 45b51e712b3848818515cccb1341afce3815fbd6 (diff) | |
download | gitlab-ce-ce996962d6bec0d29664ac3dbe62dcd18630230e.tar.gz |
add param_helper to utils - fix switch statement in pagination
-rw-r--r-- | app/assets/javascripts/lib/utils/param_helper.js.es6 (renamed from app/assets/javascripts/vue_pagination/param_helper.js.es6) | 5 | ||||
-rw-r--r-- | app/assets/javascripts/vue_pagination/index.js.es6 | 15 |
2 files changed, 11 insertions, 9 deletions
diff --git a/app/assets/javascripts/vue_pagination/param_helper.js.es6 b/app/assets/javascripts/lib/utils/param_helper.js.es6 index 4c684f96e9e..2b150c415c8 100644 --- a/app/assets/javascripts/vue_pagination/param_helper.js.es6 +++ b/app/assets/javascripts/lib/utils/param_helper.js.es6 @@ -1,6 +1,11 @@ /* eslint-disable no-param-reassign */ ((w) => { + /** + this will take in the `name` of the param you want to parse in the url + if the name does not exist this function will return `null` + otherwise it will return the value of the param key provided + */ w.getParameterByName = (name) => { const url = window.location.href; name = name.replace(/[[\]]/g, '\\$&'); diff --git a/app/assets/javascripts/vue_pagination/index.js.es6 b/app/assets/javascripts/vue_pagination/index.js.es6 index 24d3e222679..b69062e0849 100644 --- a/app/assets/javascripts/vue_pagination/index.js.es6 +++ b/app/assets/javascripts/vue_pagination/index.js.es6 @@ -1,7 +1,7 @@ /* global Vue, gl */ /* eslint-disable no-param-reassign, no-plusplus */ -//= require ./param_helper.js.es6 +/*= require lib/utils/param_helper.js.es6 */ ((gl) => { const PAGINATION_UI_BUTTON_LIMIT = 4; @@ -58,7 +58,6 @@ }, methods: { changePage(e) { - let pageNum = this.pageInfo.page; let apiScope = gl.getParameterByName('scope'); if (!apiScope) apiScope = 'all'; @@ -70,23 +69,21 @@ case SPREAD: break; case LAST: - pageNum = totalPages; + this.change(totalPages, apiScope); break; case NEXT: - pageNum = nextPage; + this.change(nextPage, apiScope); break; case PREV: - pageNum = previousPage; + this.change(previousPage, apiScope); break; case FIRST: - pageNum = 1; + this.change(1, apiScope); break; default: - pageNum = +text; + this.change(+text, apiScope); break; } - - this.change(pageNum, apiScope); }, }, computed: { |