Merge pull request #13999 from netchampfaris/fix-system-console-ux

fix(ux): Disable button while executing script
This commit is contained in:
mergify[bot] 2021-08-24 16:39:46 +00:00 committed by GitHub
commit 87dee056fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -5,7 +5,7 @@ frappe.ui.form.on('System Console', {
onload: function(frm) {
frappe.ui.keys.add_shortcut({
shortcut: 'shift+enter',
action: () => frm.execute_action('Execute'),
action: () => frm.page.btn_primary.trigger('click'),
page: frm.page,
description: __('Execute Console script'),
ignore_inputs: true,
@ -14,8 +14,11 @@ frappe.ui.form.on('System Console', {
refresh: function(frm) {
frm.disable_save();
frm.page.set_primary_action(__("Execute"), () => {
frm.execute_action('Execute');
frm.page.set_primary_action(__("Execute"), $btn => {
$btn.text(__('Executing...'));
return frm.execute_action("Execute").then(() => {
$btn.text(__('Execute'));
});
});
}
});

View file

@ -339,7 +339,7 @@ frappe.ui.form.Form = class FrappeForm {
}
}
if (action.action_type==='Server Action') {
frappe.xcall(action.action, {'doc': this.doc}).then((doc) => {
return frappe.xcall(action.action, {'doc': this.doc}).then((doc) => {
if (doc.doctype) {
// document is returned by the method,
// apply the changes locally and refresh
@ -354,7 +354,7 @@ frappe.ui.form.Form = class FrappeForm {
});
});
} else if (action.action_type==='Route') {
frappe.set_route(action.action);
return frappe.set_route(action.action);
}
}

View file

@ -251,7 +251,7 @@ frappe.ui.Page = class Page {
.prop("disabled", false)
.html(opts.label)
.on("click", function() {
let response = opts.click.apply(this);
let response = opts.click.apply(this, [btn]);
me.btn_disable_enable(btn, response);
});