mvc/bootgrid edit dialog - lock save button while in progress to prevent duplicate input. closes https://github.com/opnsense/core/issues/7390
This commit is contained in:
parent
4b93d59fd1
commit
6d770f2751
|
@ -328,6 +328,17 @@ $.fn.UIBootgrid = function (params) {
|
|||
return dfObj;
|
||||
};
|
||||
|
||||
/**
|
||||
* init / clear save button
|
||||
*/
|
||||
this.init_save_btn = function() {
|
||||
let editDlg = this_grid.attr('data-editDialog');
|
||||
let saveDlg = $("#btn_"+editDlg+"_save").unbind('click');
|
||||
saveDlg.find('i').removeClass("fa fa-spinner fa-pulse");
|
||||
return saveDlg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add event
|
||||
*/
|
||||
|
@ -335,10 +346,14 @@ $.fn.UIBootgrid = function (params) {
|
|||
event.stopPropagation();
|
||||
let editDlg = this_grid.attr('data-editDialog');
|
||||
if (editDlg !== undefined) {
|
||||
let saveDlg = $("#btn_"+editDlg+"_save").unbind('click');
|
||||
let saveDlg = this_grid.init_save_btn();
|
||||
this_grid.show_edit_dialog(event, params['get']).done(function(){
|
||||
$('#'+editDlg).trigger('opnsense_bootgrid_mapped', ['add']);
|
||||
saveDlg.click(function(){
|
||||
if (saveDlg.find('i').hasClass('fa-spinner')) {
|
||||
return;
|
||||
}
|
||||
saveDlg.find('i').addClass("fa fa-spinner fa-pulse");
|
||||
saveFormToEndpoint(params['add'], 'frm_' + editDlg, function(){
|
||||
if ($('#'+editDlg).hasClass('modal')) {
|
||||
$("#"+editDlg).modal('hide');
|
||||
|
@ -347,7 +362,9 @@ $.fn.UIBootgrid = function (params) {
|
|||
}
|
||||
std_bootgrid_reload(this_grid.attr('id'));
|
||||
this_grid.showSaveAlert(event);
|
||||
}, true);
|
||||
}, true, function(){
|
||||
saveDlg.find('i').removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
@ -369,6 +386,7 @@ $.fn.UIBootgrid = function (params) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* edit event
|
||||
*/
|
||||
|
@ -377,9 +395,13 @@ $.fn.UIBootgrid = function (params) {
|
|||
let editDlg = this_grid.attr('data-editDialog');
|
||||
if (editDlg !== undefined) {
|
||||
let uuid = $(this).data("row-id") !== undefined ? $(this).data("row-id") : '';
|
||||
let saveDlg = $("#btn_"+editDlg+"_save").unbind('click');
|
||||
let saveDlg = this_grid.init_save_btn();
|
||||
this_grid.show_edit_dialog(event, params['get'] + uuid).done(function(){
|
||||
saveDlg.unbind('click').click(function(){
|
||||
if (saveDlg.find('i').hasClass('fa-spinner')) {
|
||||
return;
|
||||
}
|
||||
saveDlg.find('i').addClass("fa fa-spinner fa-pulse");
|
||||
saveFormToEndpoint(params['set']+uuid, 'frm_' + editDlg, function(){
|
||||
if ($('#'+editDlg).hasClass('modal')) {
|
||||
$("#"+editDlg).modal('hide');
|
||||
|
@ -388,7 +410,9 @@ $.fn.UIBootgrid = function (params) {
|
|||
}
|
||||
std_bootgrid_reload(this_grid.attr('id'));
|
||||
this_grid.showSaveAlert(event);
|
||||
}, true);
|
||||
}, true, function(){
|
||||
saveDlg.find('i').removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
$('#'+editDlg).trigger('opnsense_bootgrid_mapped', ['edit']);
|
||||
});
|
||||
|
@ -458,7 +482,12 @@ $.fn.UIBootgrid = function (params) {
|
|||
$('#'+editDlg).click();
|
||||
}
|
||||
// define save action
|
||||
$("#btn_"+editDlg+"_save").unbind('click').click(function(){
|
||||
let saveDlg = this_grid.init_save_btn();
|
||||
saveDlg.click(function(){
|
||||
if (saveDlg.find('i').hasClass('fa-spinner')) {
|
||||
return;
|
||||
}
|
||||
saveDlg.find('i').addClass("fa fa-spinner fa-pulse");
|
||||
saveFormToEndpoint(params['add'], 'frm_' + editDlg, function(){
|
||||
if ($('#'+editDlg).hasClass('modal')) {
|
||||
$("#"+editDlg).modal('hide');
|
||||
|
@ -467,7 +496,9 @@ $.fn.UIBootgrid = function (params) {
|
|||
}
|
||||
std_bootgrid_reload(this_grid.attr('id'));
|
||||
this_grid.showSaveAlert(event);
|
||||
}, true);
|
||||
}, true, function(){
|
||||
saveDlg.find('i').removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
$('#'+editDlg).trigger('opnsense_bootgrid_mapped', ['copy']);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue