From 3c06919abe455c2c3a51338d8d367d0f09e6f97f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 5 Dec 2012 14:27:48 +0530 Subject: [PATCH 1/9] refactored leave and expense --- public/js/legacy/widgets/form/clientscriptAPI.js | 13 ++++++++----- public/js/legacy/widgets/form/form.js | 15 ++++++++------- public/js/wn/perm.js | 16 ++++++++++++---- webnotes/model/doc.py | 13 ++++++++----- webnotes/model/wrapper.py | 3 ++- webnotes/profile.py | 2 +- webnotes/widgets/reportview.py | 12 +++++++++--- 7 files changed, 48 insertions(+), 26 deletions(-) diff --git a/public/js/legacy/widgets/form/clientscriptAPI.js b/public/js/legacy/widgets/form/clientscriptAPI.js index f4cba203b6..6cb86a3a04 100644 --- a/public/js/legacy/widgets/form/clientscriptAPI.js +++ b/public/js/legacy/widgets/form/clientscriptAPI.js @@ -234,12 +234,14 @@ _f.Frm.prototype.set_query = function(fieldname, opt1, opt2) { _f.Frm.prototype.set_value = function(field, value) { var me = this; var _set = function(f, v) { - me.doc[f] = v; - me.fields_dict[f].refresh(); + if(me.fields_dict[f]) { + me.doc[f] = v; + me.fields_dict[f].refresh(); + } } if(typeof field=="string") { _set(field, value) - } else { + } else if($.isPlainObject(field)) { $.each(field, function(f, v) { _set(f, v); }) @@ -249,10 +251,11 @@ _f.Frm.prototype.set_value = function(field, value) { _f.Frm.prototype.call = function(opts) { var me = this; if(!opts.doc) { - opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method; + if(opts.method.indexOf(".")==-1) + opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method; opts.original_callback = opts.callback; opts.callback = function(r) { - if(typeof (r.message || "")=="object") { + if($.isPlainObject(r.message)) { me.set_value(r.message); } opts.original_callback && opts.original_callback(r); diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index e9c907b138..701cbe265b 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -298,7 +298,7 @@ _f.Frm.prototype.setup_footer = function() { _f.Frm.prototype.set_intro = function(txt) { if(!this.intro_area) { - this.intro_area = $('
') + this.intro_area = $('
') .insertBefore(this.page_layout.body.firstChild); } if(txt) { @@ -1005,20 +1005,21 @@ _f.Frm.prototype.reload_doc = function() { } _f.Frm.prototype.savesubmit = function(btn) { - var answer = confirm("Permanently Submit "+this.docname+"?"); var me = this; - if(answer) { + wn.confirm("Permanently Submit "+this.docname+"?", function() { this.save('Submit', function(r) { if(!r.exc && me.cscript.on_submit) { me.runclientscript('on_submit', me.doctype, me.docname); } - }, btn); - } + }, btn); + }); } _f.Frm.prototype.savecancel = function(btn) { - var answer = confirm("Permanently Cancel "+this.docname+"?"); - if(answer) this.save('Cancel', null, btn); + var me = this; + wn.confirm("Permanently Submit "+this.docname+"?", function() { + this.save('Cancel', null, btn); + }); } // delete the record diff --git a/public/js/wn/perm.js b/public/js/wn/perm.js index 5178e4593f..5e79296680 100644 --- a/public/js/wn/perm.js +++ b/public/js/wn/perm.js @@ -84,16 +84,24 @@ $.extend(wn.perm, { if(!name) return true; var out =false; if(p.match) { - if(user_defaults[p.match]) { - for(var i=0;i Date: Wed, 5 Dec 2012 15:45:48 +0530 Subject: [PATCH 2/9] added patch for expense and leave --- .../page/data_import_tool/data_import_tool.py | 4 +- public/js/legacy/widgets/form/print_format.js | 191 +----------------- 2 files changed, 3 insertions(+), 192 deletions(-) diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index 375e6ce23e..72d3854a2d 100644 --- a/core/page/data_import_tool/data_import_tool.py +++ b/core/page/data_import_tool/data_import_tool.py @@ -153,13 +153,13 @@ def upload(): def get_start_row(): for i, row in enumerate(rows): - if row[0]==data_keys.data_separator: + if row and row[0]==data_keys.data_separator: return i+1 bad_template() def get_header_row(key): for i, row in enumerate(header): - if row[0]==key: + if row and row[0]==key: return row return [] diff --git a/public/js/legacy/widgets/form/print_format.js b/public/js/legacy/widgets/form/print_format.js index abfd9f7a98..13cb39b1ba 100644 --- a/public/js/legacy/widgets/form/print_format.js +++ b/public/js/legacy/widgets/form/print_format.js @@ -640,193 +640,4 @@ $.extend(_p, { row.cells[1].className = 'datainputcell'; return row; } -}); - - -// print_table = function(dt, dn, fieldname, tabletype, cols, head_labels, widths, condition, cssClass, modifier, hide_empty) { -// var me = this; -// $.extend(this, { -// flist: (function() { -// var f_list = []; -// var fl = wn.meta.docfield_list[tabletype]; -// if(fl) { -// for(var i=0; i