fix(ux): Disable button while executing script
- page.set_action will now pass the btn in the handler callback
This commit is contained in:
parent
d3f3df2ce1
commit
399629da45
3 changed files with 9 additions and 6 deletions
|
|
@ -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'));
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue