diff --git a/py/core/doctype/doclayer/doclayer.js b/py/core/doctype/doclayer/doclayer.js index 9520f816ed..e58ff999f6 100644 --- a/py/core/doctype/doclayer/doclayer.js +++ b/py/core/doctype/doclayer/doclayer.js @@ -29,8 +29,8 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.frm_head.status_area.innerHTML = 'Saved' - console.log(arguments); + font-size: 11px;">Saved'; + //console.log(arguments); } }); } @@ -42,49 +42,49 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { }, 1); cur_frm.add_custom_button('Reset to defaults', function() { - cur_frm.confirm('This will remove the customizations defined for this form.\n\n' - + 'Are you sure you want to reset to defaults?'); + cur_frm.confirm('This will remove the customizations defined for this form.

' + + 'Are you sure you want to reset to defaults?', doc, dt, dn); }, 1); } -cur_frm.confirm = function(msg) { +cur_frm.confirm = function(msg, doc, dt, dn) { var d = new wn.widgets.Dialog({ title: 'Reset To Defaults', - width: 300, - fields: [ - { - fieldtype: 'HTML', - label: 'Please Confirm', - fieldname: 'msg' - }, - { - fieldtype: 'Button', - label: 'Proceed', - fieldname: 'btn_proceed' - }, - { - fieldtype: 'Button', - label: 'Cancel', - fieldname: 'btn_cancel' - } - ] + width: 500 }); - //d.set_value('msg', msg); - d.fields_dict.btn_proceed.input.onclick = function() { - this.set_working(); + + $y(d.body, {padding: '32px', textAlign: 'center'}); + + $a(d.body, 'div', '', '', msg); + + var button_wrapper = $a(d.body, 'div'); + $y(button_wrapper, {paddingTop: '15px'}); + + var proceed_btn = $btn(button_wrapper, 'Proceed', function() { $c_obj(make_doclist(dt, dn), 'delete', '', function(r, rt) { + //console.log(arguments); if(r.exc) { msgprint(r.exc); } else { - console.log(arguments); + cur_frm.confirm.dialog.hide(); + cur_frm.refresh(); + cur_frm.frm_head.status_area.innerHTML = + 'Saved'; } }); - this.done_working(); - cur_frm.confirm_dialog.hide(); - } - d.fields_dict.btn_cancel.input.onclick = function() { + }); + + $y(proceed_btn, {marginRight: '20px', fontWeight: 'bold'}); + + var cancel_btn = $btn(button_wrapper, 'Cancel', function() { cur_frm.confirm.dialog.hide(); - } + }); + + cancel_btn.className = 'cupid-green'; + $y(cancel_btn, {fontWeight: 'bold'}); cur_frm.confirm.dialog = d; + d.show(); } diff --git a/py/core/doctype/doclayer/doclayer.py b/py/core/doctype/doclayer/doclayer.py index 1c5a234bfa..a11e2cd135 100644 --- a/py/core/doctype/doclayer/doclayer.py +++ b/py/core/doctype/doclayer/doclayer.py @@ -32,7 +32,6 @@ class DocType: 'in_filter', 'hidden', 'print_hide', - 'no_copy', 'report_hide', 'allow_on_submit', 'depends_on', @@ -200,6 +199,7 @@ class DocType: new_d.fields[prop] in [None, ''] \ and ref_d.fields[prop] in [None, ''] \ ): + #webnotes.msgprint("new: " + str(new_d.fields[prop]) + " | old: " + str(ref_d.fields[prop])) # Check if the new property is same as that in original doctype # If yes, we need to delete the property setter entry for dt_d in dt_doclist: @@ -278,3 +278,15 @@ class DocType: # Save the property setter doc if not marked for deletion i.e. delete=0 if not d.delete: d.save(1) + + + def delete(self): + """ + Deletes all property setter entries for the selected doctype + and resets it to standard + """ + if self.doc.doc_type: + webnotes.conn.sql(""" + DELETE FROM `tabProperty Setter` + WHERE doc_type = %s""", self.doc.doc_type) + self.get()