Commit af7aab3a authored by Ad Schellevis's avatar Ad Schellevis

(bootgrid) return to current page after action, for https://github.com/opnsense/core/issues/1303

parent feb11e59
...@@ -80,6 +80,19 @@ function stdBootgridUI(obj, sourceUrl, options) { ...@@ -80,6 +80,19 @@ function stdBootgridUI(obj, sourceUrl, options) {
return grid; return grid;
} }
/**
* reload bootgrid, return to current selected page
*/
function std_bootgrid_reload(gridId) {
var currentpage = $("#"+gridId).bootgrid("getCurrentPage");
$("#"+gridId).bootgrid("reload");
// absolutely not perfect, bootgrid.reload doesn't seem to support when().done()
setTimeout(function(){
$('#'+gridId+'-footer a[data-page="'+currentpage+'"]').click();
}, 400);
}
/** /**
* creates new bootgrid object and links actions to our standard templates * creates new bootgrid object and links actions to our standard templates
* uses the following data properties to define functionality: * uses the following data properties to define functionality:
...@@ -135,7 +148,7 @@ $.fn.UIBootgrid = function (params) { ...@@ -135,7 +148,7 @@ $.fn.UIBootgrid = function (params) {
saveFormToEndpoint(url=gridParams['set']+uuid, saveFormToEndpoint(url=gridParams['set']+uuid,
formid='frm_' + editDlg, callback_ok=function(){ formid='frm_' + editDlg, callback_ok=function(){
$("#"+editDlg).modal('hide'); $("#"+editDlg).modal('hide');
$("#"+gridId).bootgrid("reload"); std_bootgrid_reload(gridId);
}, true); }, true);
} else { } else {
console.log("[grid] action set missing") console.log("[grid] action set missing")
...@@ -169,7 +182,7 @@ $.fn.UIBootgrid = function (params) { ...@@ -169,7 +182,7 @@ $.fn.UIBootgrid = function (params) {
saveFormToEndpoint(url=gridParams['add'], saveFormToEndpoint(url=gridParams['add'],
formid='frm_' + editDlg, callback_ok=function(){ formid='frm_' + editDlg, callback_ok=function(){
$("#"+editDlg).modal('hide'); $("#"+editDlg).modal('hide');
$("#"+gridId).bootgrid("reload"); std_bootgrid_reload(gridId);
}, true); }, true);
} else { } else {
console.log("[grid] action add missing") console.log("[grid] action add missing")
...@@ -207,7 +220,7 @@ $.fn.UIBootgrid = function (params) { ...@@ -207,7 +220,7 @@ $.fn.UIBootgrid = function (params) {
ajaxCall(url=gridParams['toggle'] + uuid, ajaxCall(url=gridParams['toggle'] + uuid,
sendData={},callback=function(data,status){ sendData={},callback=function(data,status){
// reload grid after delete // reload grid after delete
$("#"+gridId).bootgrid("reload"); std_bootgrid_reload(gridId);
}); });
} else { } else {
console.log("[grid] action toggle missing") console.log("[grid] action toggle missing")
...@@ -255,7 +268,7 @@ $.fn.UIBootgrid = function (params) { ...@@ -255,7 +268,7 @@ $.fn.UIBootgrid = function (params) {
}); });
// refresh after load // refresh after load
$.when.apply(null, deferreds).done(function(){ $.when.apply(null, deferreds).done(function(){
$("#"+gridId).bootgrid("reload"); std_bootgrid_reload(gridId);
}); });
} }
}); });
......
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