Merge pull request #31723 from gavindsouza/ux-workflow-read_only-2
fix(UX): Show reason for read only form in headline
This commit is contained in:
commit
b2f7248d0b
1 changed files with 21 additions and 10 deletions
|
|
@ -428,7 +428,6 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
this.read_only = frappe.workflow.is_read_only(this.doctype, this.docname);
|
||||
if (this.read_only) {
|
||||
this.set_read_only();
|
||||
frappe.show_alert(__("This form is not editable due to a Workflow."));
|
||||
}
|
||||
|
||||
// check if doctype is already open
|
||||
|
|
@ -448,11 +447,6 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
// load the record for the first time, if not loaded (call 'onload')
|
||||
this.trigger_onload(switched);
|
||||
|
||||
// if print format is shown, refresh the format
|
||||
// if(this.print_preview.wrapper.is(":visible")) {
|
||||
// this.print_preview.preview();
|
||||
// }
|
||||
|
||||
if (switched) {
|
||||
if (this.show_print_first && this.doc.docstatus === 1) {
|
||||
// show print view
|
||||
|
|
@ -749,6 +743,7 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
this.show_submit_message();
|
||||
this.clear_custom_buttons();
|
||||
this.show_web_link();
|
||||
this.show_workflow_read_only_banner();
|
||||
}
|
||||
|
||||
// SAVE
|
||||
|
|
@ -1262,8 +1257,6 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
} else if (this.doctype == "DocType") {
|
||||
if (frappe.views.formview[docname] || frappe.pages["List/" + docname]) {
|
||||
window.location.reload();
|
||||
// frappe.msgprint(__("Cannot open {0} when its instance is open", ['DocType']))
|
||||
// throw 'doctype open conflict'
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
|
|
@ -1271,8 +1264,6 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
frappe.views.formview.DocType.frm.opendocs[this.doctype]
|
||||
) {
|
||||
window.location.reload();
|
||||
// frappe.msgprint(__("Cannot open instance when its {0} is open", ['DocType']))
|
||||
// throw 'doctype open conflict'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2260,6 +2251,26 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
show_workflow_read_only_banner() {
|
||||
if (!this.read_only) {
|
||||
return;
|
||||
}
|
||||
|
||||
const _show_read_only_banner = () => {
|
||||
this.dashboard.set_headline(
|
||||
__("This form is not editable due to a Workflow."),
|
||||
"blue",
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
if (this.dashboard) {
|
||||
_show_read_only_banner();
|
||||
} else {
|
||||
frappe.after_ajax(_show_read_only_banner);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
frappe.validated = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue