Commit 7022d96a authored by Son Nguyen's avatar Son Nguyen
Browse files

Remember current page when changing limit (Bug #1017280)



When on another page, and the limit is changed. The page is kept the
same (the number may change, but the same entries are shown)
like the old page: admin/users/search.php

Change-Id: I415327291c1a49534114a5850e5295dd6e450da8
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 57ad8a36
......@@ -65,6 +65,7 @@ var Paginator = function(id, datatable, script, extradata) {
// If there is a form for choosing page size(page limit)
if (setlimitform) {
var setlimitselect = getFirstElementByTagAndClassName('select', 'pagination', setlimitform);
var currentoffset = getFirstElementByTagAndClassName('input', 'currentoffset', setlimitform);
connect (setlimitselect, 'onchange', function(e) {
e.stop();
......@@ -75,7 +76,8 @@ var Paginator = function(id, datatable, script, extradata) {
else {
url += "?";
}
url += this.name + "=" + this.value;
url += setlimitselect.name + "=" + setlimitselect.value;
url += "&" + currentoffset.name + "=" + currentoffset.value;
location.assign(url);
});
}
......@@ -86,6 +88,7 @@ var Paginator = function(id, datatable, script, extradata) {
// If there is a form for choosing page size(page limit)
if (setlimitform) {
var setlimitselect = getFirstElementByTagAndClassName('select', 'pagination', setlimitform);
var currentoffset = getFirstElementByTagAndClassName('input', 'currentoffset', setlimitform);
connect (setlimitselect, 'onchange', function(e) {
e.stop();
......@@ -94,6 +97,7 @@ var Paginator = function(id, datatable, script, extradata) {
var queryData = [];
if (loc != -1) {
queryData = parseQueryString(url.substring(loc + 1, url.length));
queryData.offset = currentoffset.value;
queryData.setlimit = "1";
queryData.limit = setlimitselect.value;
queryData.extradata = serializeJSON(self.extraData);
......
......@@ -3408,6 +3408,7 @@ function build_pagination($params) {
'<select id="setlimitselect" class="pagination" name="limit"> '.
join(' ', $strlimitoptions) .
'</select>
<input class="currentoffset" type="hidden" name="' . $params['offsetname'] . '" value="' . $params['offset'] . '"/>
<input class="pagination js-hidden" type="submit" name="submit" value="' . get_string('change') . '"/>
</form>';
}
......
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