Merge pull request #9923 from gavindsouza/dirty-form

feat: don't save document if not updated
This commit is contained in:
mergify[bot] 2020-04-14 09:42:20 +00:00 committed by GitHub
commit aef809d67a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -1052,7 +1052,7 @@ frappe.ui.form.Form = class FrappeForm {
}
is_dirty() {
return this.doc.__unsaved;
return !!this.doc.__unsaved;
}
is_new() {

View file

@ -21,7 +21,7 @@ frappe.ui.form.save = function (frm, action, callback, btn) {
remove_empty_rows();
$(frm.wrapper).addClass('validated-form');
if (check_mandatory()) {
if (frm.is_dirty() && check_mandatory()) {
_call({
method: "frappe.desk.form.save.savedocs",
args: { doc: frm.doc, action: action },
@ -36,6 +36,7 @@ frappe.ui.form.save = function (frm, action, callback, btn) {
freeze_message: freeze_message
});
} else {
frappe.show_alert({message: __("Document not updated"), indicator: "yellow"});
$(btn).prop("disabled", false);
}
};