From f6f54d7027e1394337b0e2b01a9bc9e08f213dd9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 29 Jul 2013 19:30:37 +0530 Subject: [PATCH 1/4] [fix] [client script] call cur_frm.cscript.custom_ type functions in the callback of standard functions --- core/doctype/communication/communication.js | 2 +- core/doctype/custom_field/custom_field.js | 2 +- core/doctype/customize_form/customize_form.js | 6 ++--- .../documentation_tool/documentation_tool.js | 4 +-- core/doctype/profile/profile.js | 4 +-- .../page/data_import_tool/data_import_tool.js | 4 +-- core/page/messages/messages.js | 6 ++--- core/page/modules_setup/modules_setup.js | 2 +- .../permission_manager/permission_manager.js | 16 ++++++------ core/page/todo/todo.js | 6 ++--- core/page/update_manager/update_manager.js | 2 +- core/page/user_properties/user_properties.js | 8 +++--- public/js/legacy/clientscriptAPI.js | 26 +++---------------- public/js/legacy/form.js | 2 +- public/js/legacy/handler.js | 6 ++--- public/js/wn/app.js | 6 ++--- public/js/wn/defaults.js | 2 +- public/js/wn/form/assign_to.js | 2 +- public/js/wn/form/attachments.js | 2 +- public/js/wn/form/comments.js | 4 +-- public/js/wn/form/control.js | 9 +++++-- public/js/wn/form/infobar.js | 2 +- public/js/wn/form/link_selector.js | 2 +- public/js/wn/form/script_manager.js | 14 ++++++---- public/js/wn/misc/tools.js | 2 +- public/js/wn/model/create_new.js | 4 +-- public/js/wn/model/doclist.js | 2 +- public/js/wn/model/model.js | 8 +++--- public/js/wn/request.js | 4 +-- public/js/wn/ui/listing.js | 2 +- public/js/wn/ui/tags.js | 4 +-- public/js/wn/ui/toolbar/toolbar.js | 2 +- public/js/wn/ui/tree.js | 2 +- public/js/wn/upload.js | 2 +- public/js/wn/views/calendar.js | 4 +-- public/js/wn/views/communication.js | 4 +-- public/js/wn/views/doclistview.js | 2 +- public/js/wn/views/ganttview.js | 2 +- public/js/wn/views/grid_report.js | 2 +- public/js/wn/views/moduleview.js | 2 +- public/js/wn/views/pageview.js | 2 +- public/js/wn/views/query_report.js | 4 +-- public/js/wn/views/reportview.js | 4 +-- public/js/wn/views/sidebar_stats.js | 2 +- 44 files changed, 94 insertions(+), 105 deletions(-) diff --git a/core/doctype/communication/communication.js b/core/doctype/communication/communication.js index f418333a87..638ed87653 100644 --- a/core/doctype/communication/communication.js +++ b/core/doctype/communication/communication.js @@ -36,7 +36,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.cscript.contact = function(doc, dt, dn) { if (doc.contact) { - wn.call({ + return wn.call({ method: 'support.doctype.communication.communication.get_customer_supplier', args: { contact: doc.contact diff --git a/core/doctype/custom_field/custom_field.js b/core/doctype/custom_field/custom_field.js index e27a4480ce..f54c140269 100644 --- a/core/doctype/custom_field/custom_field.js +++ b/core/doctype/custom_field/custom_field.js @@ -75,7 +75,7 @@ cur_frm.cscript.dt = function(doc, dt, dn) { set_field_options('insert_after', ''); return; } - wn.call({ + return wn.call({ method: 'core.doctype.custom_field.custom_field.get_fields_label', args: { doctype: doc.dt, fieldname: doc.fieldname }, callback: function(r, rt) { diff --git a/core/doctype/customize_form/customize_form.js b/core/doctype/customize_form/customize_form.js index 8ac191ee7b..235d9418ee 100644 --- a/core/doctype/customize_form/customize_form.js +++ b/core/doctype/customize_form/customize_form.js @@ -27,7 +27,7 @@ $(cur_frm.wrapper).on("grid-row-render", function(e, grid_row) { }) cur_frm.cscript.doc_type = function(doc, dt, dn) { - cur_frm.call({ + return cur_frm.call({ method: "get", doc: cur_frm.doc, callback: function(r) { @@ -58,7 +58,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.add_custom_button('Update', function() { if(cur_frm.doc.doc_type) { - cur_frm.call({ + return cur_frm.call({ doc: cur_frm.doc, method: "post", callback: function(r) { @@ -129,7 +129,7 @@ cur_frm.confirm = function(msg, doc, dt, dn) { $y(button_wrapper, {paddingTop: '15px'}); var proceed_btn = $btn(button_wrapper, 'Proceed', function() { - cur_frm.call({ + return cur_frm.call({ doc: cur_frm.doc, method: "delete", callback: function(r) { diff --git a/core/doctype/documentation_tool/documentation_tool.js b/core/doctype/documentation_tool/documentation_tool.js index f6dcde4ca2..b3ea721b5c 100644 --- a/core/doctype/documentation_tool/documentation_tool.js +++ b/core/doctype/documentation_tool/documentation_tool.js @@ -64,7 +64,7 @@ wn.docs.generate_all = function(logarea) { logarea.empty().append("Downloading server docs...
"); - wn.call({ + return wn.call({ "method": "core.doctype.documentation_tool.documentation_tool.get_docs", args: {options: cur_frm.doc}, callback: function(r) { @@ -86,7 +86,7 @@ wn.docs.generate_all = function(logarea) { make_page("docs"); logarea.append("Writing...
"); - wn.call({ + return wn.call({ method: "core.doctype.documentation_tool.documentation_tool.write_docs", args: { data: JSON.stringify(wn.docs.to_write), diff --git a/core/doctype/profile/profile.js b/core/doctype/profile/profile.js index 977ebba616..1f1d8264f2 100644 --- a/core/doctype/profile/profile.js +++ b/core/doctype/profile/profile.js @@ -68,7 +68,7 @@ wn.RoleEditor = Class.extend({ var me = this; this.wrapper = wrapper; $(wrapper).html('
Loading...
') - wn.call({ + return wn.call({ method:'core.doctype.profile.profile.get_all_roles', callback: function(r) { me.roles = r.message; @@ -174,7 +174,7 @@ wn.RoleEditor = Class.extend({ if(!this.perm_dialog) this.make_perm_dialog() $(this.perm_dialog.body).empty(); - wn.call({ + return wn.call({ method:'core.doctype.profile.profile.get_perm_info', args: {role: role}, callback: function(r) { diff --git a/core/page/data_import_tool/data_import_tool.js b/core/page/data_import_tool/data_import_tool.js index a9e66537dd..8b20a2b831 100644 --- a/core/page/data_import_tool/data_import_tool.js +++ b/core/page/data_import_tool/data_import_tool.js @@ -46,7 +46,7 @@ wn.pages['data-import-tool'].onload = function(wrapper) { "Performing hardcore import process....", 100); // load doctypes - wn.call({ + return wn.call({ method:'core.page.data_import_tool.data_import_tool.get_doctypes', callback: function(r) { $select.add_options(['Select...'].concat(r.message)); @@ -71,7 +71,7 @@ wn.pages['data-import-tool'].onload = function(wrapper) { $('#dit-download').empty(); // get options - wn.call({ + return wn.call({ method:'core.page.data_import_tool.data_import_tool.get_doctype_options', args: {doctype: val}, callback: function(r) { diff --git a/core/page/messages/messages.js b/core/page/messages/messages.js index 07135eccec..e8e49f91aa 100644 --- a/core/page/messages/messages.js +++ b/core/page/messages/messages.js @@ -61,7 +61,7 @@ erpnext.Messages = Class.extend({ $('#post-message .btn').click(function() { var txt = $('#post-message textarea').val(); if(txt) { - wn.call({ + return wn.call({ module:'core', page:'messages', method:'post', @@ -163,7 +163,7 @@ erpnext.Messages = Class.extend({ }, delete: function(ele) { $(ele).parent().css('opacity', 0.6); - wn.call({ + return wn.call({ method:'core.page.messages.messages.delete', args: {name : $(ele).attr('data-name')}, callback: function() { @@ -173,7 +173,7 @@ erpnext.Messages = Class.extend({ }, show_active_users: function() { var me = this; - wn.call({ + return wn.call({ module:'core', page:'messages', method:'get_active_users', diff --git a/core/page/modules_setup/modules_setup.js b/core/page/modules_setup/modules_setup.js index b8766cdeef..1ffdd47711 100644 --- a/core/page/modules_setup/modules_setup.js +++ b/core/page/modules_setup/modules_setup.js @@ -36,7 +36,7 @@ wn.modules_setup = { ml.push($(this).attr('data-module')); }); - wn.call({ + return wn.call({ method: 'core.page.modules_setup.modules_setup.update', args: { ml: ml diff --git a/core/page/permission_manager/permission_manager.js b/core/page/permission_manager/permission_manager.js index 6bd0d804ab..e5f668e7fa 100644 --- a/core/page/permission_manager/permission_manager.js +++ b/core/page/permission_manager/permission_manager.js @@ -84,7 +84,7 @@ wn.PermissionEngine = Class.extend({ var me = this; me.make_reset_button(); - wn.call({ + return wn.call({ module:"core", page:"permission_manager", method: "get_roles_and_doctypes", @@ -120,7 +120,7 @@ wn.PermissionEngine = Class.extend({ var me = this; me.reset_button = me.wrapper.appframe.add_button("Reset Permissions", function() { if(wn.confirm("Reset Permissions for " + me.get_doctype() + "?", function() { - wn.call({ + return wn.call({ module:"core", page:"permission_manager", method:"reset", @@ -151,7 +151,7 @@ wn.PermissionEngine = Class.extend({ return; } // get permissions - wn.call({ + return wn.call({ module: "core", page: "permission_manager", method: "get_permissions", @@ -239,7 +239,7 @@ wn.PermissionEngine = Class.extend({ .attr("data-role", role) .click(function() { var role = $(this).attr("data-role"); - wn.call({ + return wn.call({ module: "core", page: "permission_manager", method: "get_users_with_role", @@ -279,7 +279,7 @@ wn.PermissionEngine = Class.extend({ .attr("data-name", d.name) .attr("data-doctype", d.parent) .click(function() { - wn.call({ + return wn.call({ module: "core", page: "permission_manager", method: "remove", @@ -307,7 +307,7 @@ wn.PermissionEngine = Class.extend({ ptype: chk.attr("data-ptype"), value: chk.prop("checked") ? 1 : 0 } - wn.call({ + return wn.call({ module: "core", page: "permission_manager", method: "update", @@ -355,7 +355,7 @@ wn.PermissionEngine = Class.extend({ if(!args) { return; } - wn.call({ + return wn.call({ module: "core", page: "permission_manager", method: "add", @@ -416,7 +416,7 @@ wn.PermissionEngine = Class.extend({ .click(function() { var match_value = $(dialog.wrapper).find(":radio:checked").val(); var perm = me.get_perm($(this).attr('data-name')) - wn.call({ + return wn.call({ module: "core", page: "permission_manager", method: "update_match", diff --git a/core/page/todo/todo.js b/core/page/todo/todo.js index edd443c05f..9adfc62ca4 100644 --- a/core/page/todo/todo.js +++ b/core/page/todo/todo.js @@ -18,7 +18,7 @@ wn.provide('erpnext.todo'); erpnext.todo.refresh = function() { - wn.call({ + return wn.call({ method: 'core.page.todo.todo.get', callback: function(r,rt) { var todo_list = $('#todo-list div.todo-content'); @@ -117,7 +117,7 @@ erpnext.todo.ToDoItem = Class.extend({ .data('name', todo.name) .click(function() { $(this).parent().css('opacity', 0.5); - wn.call({ + return wn.call({ method:'core.page.todo.todo.delete', args: {name: $(this).data('name')}, callback: function() { @@ -172,7 +172,7 @@ erpnext.todo.save = function(btn) { } det.name = d.det.name || ''; - wn.call({ + return wn.call({ method:'core.page.todo.todo.edit', args: det, btn: btn, diff --git a/core/page/update_manager/update_manager.js b/core/page/update_manager/update_manager.js index 3df1c6c0fe..e11a4d78e0 100644 --- a/core/page/update_manager/update_manager.js +++ b/core/page/update_manager/update_manager.js @@ -50,7 +50,7 @@ wn.UpdateThisApp = Class.extend({ \
' + wn._("Update is in progress. This may take some time.") + '
'); - wn.call({ + return wn.call({ module: "core", page: "update_manager", method: "update_this_app", diff --git a/core/page/user_properties/user_properties.js b/core/page/user_properties/user_properties.js index b04232ea7c..cbb3014ce2 100644 --- a/core/page/user_properties/user_properties.js +++ b/core/page/user_properties/user_properties.js @@ -33,7 +33,7 @@ wn.UserProperties = Class.extend({ }, make: function() { var me = this; - wn.call({ + return wn.call({ module:"core", page:"user_properties", method: "get_users_and_links", @@ -101,7 +101,7 @@ wn.UserProperties = Class.extend({ return; } // get permissions - wn.call({ + return wn.call({ module: "core", page: "user_properties", method: "get_properties", @@ -147,7 +147,7 @@ wn.UserProperties = Class.extend({ .attr("data-name", d.name) .attr("data-user", d.parent) .click(function() { - wn.call({ + return wn.call({ module: "core", page: "user_properties", method: "remove", @@ -212,7 +212,7 @@ wn.UserProperties = Class.extend({ if(!args) { return; } - wn.call({ + return wn.call({ module: "core", page: "user_properties", method: "add", diff --git a/public/js/legacy/clientscriptAPI.js b/public/js/legacy/clientscriptAPI.js index c528963ae3..482afc93b4 100644 --- a/public/js/legacy/clientscriptAPI.js +++ b/public/js/legacy/clientscriptAPI.js @@ -20,29 +20,9 @@ // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -// Client Side Scripting API -// ====================================================================================== - -$c_get_values = function(args, doc, dt, dn, user_callback) { - var call_back = function(r,rt) { - if(!r.message)return; - if(user_callback) user_callback(r.message); - - var fl = args.fields.split(','); - for(var i in fl) { - locals[dt][dn][fl[i]] = r.message[fl[i]]; // set value - if(args.table_field) - refresh_field(fl[i], dn, args.table_field); - else - refresh_field(fl[i]); - } - } - $c('webnotes.widgets.form.utils.get_fields',args,call_back); -} - get_server_fields = function(method, arg, table_field, doc, dt, dn, allow_edit, call_back) { wn.dom.freeze(); - $c('runserverobj', + return $c('runserverobj', args={'method':method, 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name)), 'arg':arg @@ -205,7 +185,7 @@ _f.Frm.prototype.toggle_display = function(fnames, show) { } _f.Frm.prototype.call_server = function(method, args, callback) { - $c_obj(cur_frm.get_doclist(), method, args, callback); + return $c_obj(cur_frm.get_doclist(), method, args, callback); } _f.Frm.prototype.get_files = function() { @@ -270,7 +250,7 @@ _f.Frm.prototype.call = function(opts) { } } - wn.call(opts); + return wn.call(opts); } _f.Frm.prototype.get_field = function(field) { diff --git a/public/js/legacy/form.js b/public/js/legacy/form.js index 373a0416ac..0dcb82d156 100644 --- a/public/js/legacy/form.js +++ b/public/js/legacy/form.js @@ -611,7 +611,7 @@ _f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) { if(callingfield) $(callingfield.input).set_working(); - $c('runserverobj', {'docs':doclist, 'method':scriptname }, + return $c('runserverobj', {'docs':doclist, 'method':scriptname }, function(r, rtxt) { // run refresh if(onrefresh) diff --git a/public/js/legacy/handler.js b/public/js/legacy/handler.js index 867601e243..a571be224b 100644 --- a/public/js/legacy/handler.js +++ b/public/js/legacy/handler.js @@ -21,7 +21,7 @@ // function $c(command, args, callback, error, no_spinner, freeze_msg, btn) { - wn.request.call({ + return wn.request.call({ args: $.extend(args, {cmd: command}), success: callback, error: error, @@ -46,7 +46,7 @@ function $c_obj(doclist, method, arg, callback, no_spinner, freeze_msg, btn) { else args.docs = wn.model.compress(doclist) - wn.request.call({ + return wn.request.call({ args: args, success: callback, btn: btn, @@ -58,7 +58,7 @@ function $c_obj(doclist, method, arg, callback, no_spinner, freeze_msg, btn) { // For call a page metho function $c_page(module, page, method, arg, callback, no_spinner, freeze_msg, btn) { if(arg && typeof arg!='string') arg = JSON.stringify(arg); - wn.request.call({ + return wn.request.call({ args: { cmd: module+'.page.'+page+'.'+page+'.'+method, arg: arg, diff --git a/public/js/wn/app.js b/public/js/wn/app.js index 0567d09fbd..754f3da22c 100644 --- a/public/js/wn/app.js +++ b/public/js/wn/app.js @@ -23,7 +23,7 @@ wn.Application = Class.extend({ load_startup: function() { var me = this; if(window.app) { - wn.call({ + return wn.call({ method: 'startup', callback: function(r, rt) { wn.provide('wn.boot'); @@ -109,7 +109,7 @@ wn.Application = Class.extend({ refresh_notifications: function() { if(wn.session_alive) { - wn.call({ + return wn.call({ method: "webnotes.widgets.notification.get", callback: function(r) { if(r.message) { @@ -175,7 +175,7 @@ wn.Application = Class.extend({ logout: function() { var me = this; me.logged_out = true; - wn.call({ + return wn.call({ method:'logout', callback: function(r) { if(r.exc) { diff --git a/public/js/wn/defaults.js b/public/js/wn/defaults.js index 30c920bf79..9acab9e318 100644 --- a/public/js/wn/defaults.js +++ b/public/js/wn/defaults.js @@ -24,7 +24,7 @@ wn.defaults = { value = JSON.stringify(value); wn.boot.profile.defaults[key] = value; - wn.call({ + return wn.call({ method: "webnotes.client.set_default", args: { key: key, diff --git a/public/js/wn/form/assign_to.js b/public/js/wn/form/assign_to.js index 4ea9b01fe4..b297ebda27 100644 --- a/public/js/wn/form/assign_to.js +++ b/public/js/wn/form/assign_to.js @@ -118,7 +118,7 @@ wn.ui.form.AssignTo = Class.extend({ var assign_to = me.dialog.fields_dict.assign_to.get_value(); var args = me.dialog.get_values(); if(assign_to) { - wn.call({ + return wn.call({ method:'webnotes.widgets.form.assign_to.add', args: $.extend(args, { doctype: me.frm.doctype, diff --git a/public/js/wn/form/attachments.js b/public/js/wn/form/attachments.js index 7985fc2e7c..d712e3dc29 100644 --- a/public/js/wn/form/attachments.js +++ b/public/js/wn/form/attachments.js @@ -100,7 +100,7 @@ wn.ui.form.Attachments = Class.extend({ wn.confirm(wn._("Are you sure you want to delete the attachment?"), function() { var data = $(remove_btn).data("fileid"); - wn.call({ + return wn.call({ method: 'webnotes.widgets.form.utils.remove_attach', args: { fid: data, diff --git a/public/js/wn/form/comments.js b/public/js/wn/form/comments.js index 196860a1b5..593bbc2caf 100644 --- a/public/js/wn/form/comments.js +++ b/public/js/wn/form/comments.js @@ -78,7 +78,7 @@ wn.ui.form.Comments = Class.extend({ comment_by: user }; - wn.call({ + return wn.call({ method: "webnotes.widgets.form.utils.add_comment", args: { doclist:[comment] @@ -97,7 +97,7 @@ wn.ui.form.Comments = Class.extend({ }, delete_comment: function(name) { var me = this; - wn.call({ + return wn.call({ method: "webnotes.client.delete", args: { doctype: "Comment", diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index 87fcd0cdb4..6f7e5d7dcb 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -619,7 +619,11 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ //this.bind_change_event(); var me = this; this.$input.on("blur", function() { - if(me.doctype && me.docname && !me.autocomplete_open) { + if(me.selected) { + me.selected = false; + return; + } + if(me.doctype && me.docname) { var value = me.get_value(); if(value!==me.last_value) { me.parse_validate_and_set_in_model(value); @@ -671,7 +675,7 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ me.set_custom_query(args); - wn.call({ + return wn.call({ type: "GET", method:'webnotes.widgets.search.search_link', args: args, @@ -693,6 +697,7 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ select: function(event, ui) { me.autocomplete_open = false; if(me.frm && me.frm.doc) { + me.selected = true; me.parse_validate_and_set_in_model(ui.item.value); } else { me.$input.val(ui.item.value); diff --git a/public/js/wn/form/infobar.js b/public/js/wn/form/infobar.js index f83d364e2f..a7ac702d6e 100644 --- a/public/js/wn/form/infobar.js +++ b/public/js/wn/form/infobar.js @@ -110,7 +110,7 @@ wn.ui.form.InfoBar = Class.extend({ }, go_prev_next: function(prev) { var me = this; - wn.call({ + return wn.call({ method: "webnotes.widgets.form.utils.get_next", args: { doctype: me.frm.doctype, diff --git a/public/js/wn/form/link_selector.js b/public/js/wn/form/link_selector.js index 93f4670db5..c775a9e5d9 100644 --- a/public/js/wn/form/link_selector.js +++ b/public/js/wn/form/link_selector.js @@ -67,7 +67,7 @@ wn.ui.form.LinkSelector = Class.extend({ this.target.set_custom_query(args); - wn.call({ + return wn.call({ method: "webnotes.widgets.search.search_widget", type: "GET", args: args, diff --git a/public/js/wn/form/script_manager.js b/public/js/wn/form/script_manager.js index 46fb1a54cb..6f1b0de6f3 100644 --- a/public/js/wn/form/script_manager.js +++ b/public/js/wn/form/script_manager.js @@ -6,13 +6,17 @@ wn.ui.form.ScriptManager = Class.extend({ this.frm.cscript = $.extend(this.frm.cscript, new ControllerClass({frm: this.frm})); }, trigger: function(event_name, doctype, name) { + var me = this; doctype = doctype || this.frm.doctype; name = name || this.frm.docname; - if(this.frm.cscript[event_name]) - this.frm.cscript[event_name](this.frm.doc, doctype, name); - - if(this.frm.cscript["custom_" + event_name]) + if(this.frm.cscript[event_name]) { + $.when(this.frm.cscript[event_name](this.frm.doc, doctype, name)).then(function() { + if(me.frm.cscript["custom_" + event_name]) + me.frm.cscript["custom_" + event_name](me.frm.doc, doctype, name); + }); + } else if(this.frm.cscript["custom_" + event_name]) { this.frm.cscript["custom_" + event_name](this.frm.doc, doctype, name); + } }, setup: function() { var doctype = this.frm.meta; @@ -46,7 +50,7 @@ wn.ui.form.ScriptManager = Class.extend({ if(this.frm && this.frm.fetch_dict[df.fieldname]) fetch = this.frm.fetch_dict[df.fieldname].columns.join(', '); - wn.call({ + return wn.call({ method:'webnotes.widgets.form.utils.validate_link', type: "GET", args: { diff --git a/public/js/wn/misc/tools.js b/public/js/wn/misc/tools.js index cccc5f6cd9..18220e7bfd 100644 --- a/public/js/wn/misc/tools.js +++ b/public/js/wn/misc/tools.js @@ -111,7 +111,7 @@ wn.slickgrid_tools = { $.each(grid.getColumns(), function(i, col) { if(col.docfield && col.previousWidth != col.width && !in_list(wn.model.std_fields_list, col.docfield.fieldname) ) { - wn.call({ + return wn.call({ method:"webnotes.client.make_width_property_setter", args: { doclist: [{ diff --git a/public/js/wn/model/create_new.js b/public/js/wn/model/create_new.js index e4d25c269a..008ffbd7c0 100644 --- a/public/js/wn/model/create_new.js +++ b/public/js/wn/model/create_new.js @@ -129,7 +129,7 @@ $.extend(wn.model, { }, open_mapped_doc: function(opts) { - wn.call({ + return wn.call({ type: "GET", method: opts.method, args: { @@ -151,7 +151,7 @@ $.extend(wn.model, { } } var _map = function() { - wn.call({ + return wn.call({ type: "GET", method: opts.method, args: { diff --git a/public/js/wn/model/doclist.js b/public/js/wn/model/doclist.js index dcc53f1c05..e0f44d74ef 100644 --- a/public/js/wn/model/doclist.js +++ b/public/js/wn/model/doclist.js @@ -124,7 +124,7 @@ wn.model.DocList = Class.extend({ // btn: btn // } $(opts.btn).attr("disabled", true); - wn.call({ + return wn.call({ freeze: true, method: opts.method, args: opts.args, diff --git a/public/js/wn/model/model.js b/public/js/wn/model/model.js index b93b11002f..b2f8f2a8bd 100644 --- a/public/js/wn/model/model.js +++ b/public/js/wn/model/model.js @@ -67,7 +67,7 @@ $.extend(wn.model, { var cached_doclist = JSON.parse(localStorage["_doctype:" + doctype]); cached_timestamp = cached_doclist[0].modified; } - wn.call({ + return wn.call({ method:'webnotes.widgets.form.load.getdoctype', type: "GET", args: { @@ -106,7 +106,7 @@ $.extend(wn.model, { if(locals[doctype] && locals[doctype][name] && wn.model.get_docinfo(doctype, name)) { callback(name); } else { - wn.call({ + return wn.call({ method: 'webnotes.widgets.form.load.getdoc', type: "GET", args: { @@ -410,7 +410,7 @@ $.extend(wn.model, { delete_doc: function(doctype, docname, callback) { wn.confirm("Permanently delete "+ docname + "?", function() { - wn.call({ + return wn.call({ method: 'webnotes.model.delete_doc', args: { dt:doctype, @@ -441,7 +441,7 @@ $.extend(wn.model, { var args = d.get_values(); if(!args) return; d.get_input("rename").set_working(); - wn.call({ + return wn.call({ method:"webnotes.model.rename_doc.rename_doc", args: { doctype: doctype, diff --git a/public/js/wn/request.js b/public/js/wn/request.js index e53aebf174..de65d6f086 100644 --- a/public/js/wn/request.js +++ b/public/js/wn/request.js @@ -51,7 +51,7 @@ wn.call = function(opts) { } } - wn.request.call({ + return wn.request.call({ type: opts.type || "POST", args: args, success: opts.callback, @@ -110,7 +110,7 @@ wn.request.call = function(opts) { }) } - $.ajax(ajax_args); + return $.ajax(ajax_args); } // call execute serverside request diff --git a/public/js/wn/ui/listing.js b/public/js/wn/ui/listing.js index 5370281dde..52ace08264 100644 --- a/public/js/wn/ui/listing.js +++ b/public/js/wn/ui/listing.js @@ -229,7 +229,7 @@ wn.ui.Listing = Class.extend({ if(!me.opts.no_loading) me.set_working(true); - wn.call({ + return wn.call({ method: this.opts.method || 'webnotes.widgets.query_builder.runquery', type: "GET", args: this.get_call_args(), diff --git a/public/js/wn/ui/tags.js b/public/js/wn/ui/tags.js index 4dfd37b2d3..86eacf96a6 100644 --- a/public/js/wn/ui/tags.js +++ b/public/js/wn/ui/tags.js @@ -17,14 +17,14 @@ wn.ui.TagEditor = Class.extend({ placeholderText: 'Add Tag', onTagAdded: function(ev, tag) { if(me.initialized) { - wn.call({ + return wn.call({ method: 'webnotes.widgets.tags.add_tag', args: me.get_args(tag.find('.tagit-label').text()) }); } }, onTagRemoved: function(ev, tag) { - wn.call({ + return wn.call({ method: 'webnotes.widgets.tags.remove_tag', args: me.get_args(tag.find('.tagit-label').text()) }); diff --git a/public/js/wn/ui/toolbar/toolbar.js b/public/js/wn/ui/toolbar/toolbar.js index 773b52c712..804ea9900a 100644 --- a/public/js/wn/ui/toolbar/toolbar.js +++ b/public/js/wn/ui/toolbar/toolbar.js @@ -260,7 +260,7 @@ wn.ui.toolbar.clear_cache = function() { wn.ui.toolbar.download_backup = function() { msgprint(wn._("Your download is being built, this may take a few moments...")); - $c('webnotes.utils.backups.get_backup',{},function(r,rt) {}); + return $c('webnotes.utils.backups.get_backup',{},function(r,rt) {}); return false; } diff --git a/public/js/wn/ui/tree.js b/public/js/wn/ui/tree.js index 8729238d69..c7b25effc6 100644 --- a/public/js/wn/ui/tree.js +++ b/public/js/wn/ui/tree.js @@ -104,7 +104,7 @@ wn.ui.TreeNode = Class.extend({ $(me.$a).set_working(); - wn.call({ + return wn.call({ method: this.tree.method, args: args, callback: function(r) { diff --git a/public/js/wn/upload.js b/public/js/wn/upload.js index f51352bca7..0013ea8b8a 100644 --- a/public/js/wn/upload.js +++ b/public/js/wn/upload.js @@ -54,7 +54,7 @@ wn.upload = { var _upload_file = function() { var msgbox = msgprint(wn._("Uploading...")); - wn.call({ + return wn.call({ "method": "uploadfile", args: args, callback: function(r) { diff --git a/public/js/wn/views/calendar.js b/public/js/wn/views/calendar.js index 031ac3bba5..b17f3d0e2c 100644 --- a/public/js/wn/views/calendar.js +++ b/public/js/wn/views/calendar.js @@ -92,7 +92,7 @@ wn.views.Calendar = Class.extend({ selectable: true, selectHelper: true, events: function(start, end, callback) { - wn.call({ + return wn.call({ method: me.get_events_method || "webnotes.widgets.calendar.get_events", type: "GET", args: me.get_args(start, end), @@ -180,7 +180,7 @@ wn.views.Calendar = Class.extend({ update_event: function(event, revertFunc) { var me = this; wn.model.remove_from_locals(me.doctype, event.name); - wn.call({ + return wn.call({ method: me.update_event_method || "webnotes.widgets.calendar.update_event", args: me.get_update_args(event), callback: function(r) { diff --git a/public/js/wn/views/communication.js b/public/js/wn/views/communication.js index b96cb40708..fba9bf9f7f 100644 --- a/public/js/wn/views/communication.js +++ b/public/js/wn/views/communication.js @@ -254,7 +254,7 @@ wn.views.CommunicationComposer = Class.extend({ var print_html = ""; } - wn.call({ + return wn.call({ method:"core.doctype.communication.communication.make", args: { sender: [wn.user_info(user).fullname, wn.boot.profile.email], @@ -331,7 +331,7 @@ wn.views.CommunicationComposer = Class.extend({ }) .autocomplete({ source: function(request, response) { - wn.call({ + return wn.call({ method:'webnotes.utils.email_lib.get_contact_list', args: { 'select': "email_id", diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index 009a5eefcf..a8a43aee3a 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -267,7 +267,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ wn.confirm(wn._('This is permanent action and you cannot undo. Continue?'), function() { me.set_working(true); - wn.call({ + return wn.call({ method: 'webnotes.widgets.reportview.delete_items', args: { items: $.map(dl, function(d, i) { return d.name }), diff --git a/public/js/wn/views/ganttview.js b/public/js/wn/views/ganttview.js index f5c47b749e..9f41f760f9 100644 --- a/public/js/wn/views/ganttview.js +++ b/public/js/wn/views/ganttview.js @@ -65,7 +65,7 @@ wn.views.Gantt = Class.extend({ .html('
Loading...
'); var me = this; - wn.call({ + return wn.call({ method: this.get_events_method, type: "GET", args: { diff --git a/public/js/wn/views/grid_report.js b/public/js/wn/views/grid_report.js index 4617561753..99fa1bb4c0 100644 --- a/public/js/wn/views/grid_report.js +++ b/public/js/wn/views/grid_report.js @@ -8,7 +8,7 @@ $.extend(wn.report_dump, { last_modified: {}, with_data: function(doctypes, callback, progress_bar) { var pre_loaded = keys(wn.report_dump.last_modified); - wn.call({ + return wn.call({ method: "webnotes.widgets.report_dump.get_data", type: "GET", args: { diff --git a/public/js/wn/views/moduleview.js b/public/js/wn/views/moduleview.js index 9d21022096..97a0041524 100644 --- a/public/js/wn/views/moduleview.js +++ b/public/js/wn/views/moduleview.js @@ -194,7 +194,7 @@ wn.views.moduleview.ModuleView = Class.extend({ render_dynamic: function() { // render reports var me = this; - wn.call({ + return wn.call({ method: "webnotes.widgets.moduleview.get_data", args: { module: me.module, diff --git a/public/js/wn/views/pageview.js b/public/js/wn/views/pageview.js index a7da3ccb21..1acebc3fe9 100644 --- a/public/js/wn/views/pageview.js +++ b/public/js/wn/views/pageview.js @@ -23,7 +23,7 @@ wn.views.pageview = { callback(); } else { // get fresh - wn.call({ + return wn.call({ method: 'webnotes.widgets.page.getpage', args: {'name':name }, callback: function(r) { diff --git a/public/js/wn/views/query_report.js b/public/js/wn/views/query_report.js index fc1b92475a..eb90f43fe7 100644 --- a/public/js/wn/views/query_report.js +++ b/public/js/wn/views/query_report.js @@ -86,7 +86,7 @@ wn.views.QueryReport = Class.extend({ me.appframe.set_title(wn._("Query Report")+": " + me.report_name); if(!wn.query_reports[me.report_name]) { - wn.call({ + return wn.call({ method:"webnotes.widgets.query_report.get_script", args: { report_name: me.report_name @@ -142,7 +142,7 @@ wn.views.QueryReport = Class.extend({ $.each(this.filters || [], function(i, f) { filters[f.df.fieldname] = f.get_parsed_value(); }) - wn.call({ + return wn.call({ method: "webnotes.widgets.query_report.run", args: { "report_name": me.report_name, diff --git a/public/js/wn/views/reportview.js b/public/js/wn/views/reportview.js index 92f5f894b1..fa102afa89 100644 --- a/public/js/wn/views/reportview.js +++ b/public/js/wn/views/reportview.js @@ -368,7 +368,7 @@ wn.views.ReportView = wn.ui.Listing.extend({ } // callback - wn.call({ + return wn.call({ method: 'webnotes.widgets.reportview.save_report', args: { name: name, @@ -416,7 +416,7 @@ wn.views.ReportView = wn.ui.Listing.extend({ return; if(wn.confirm(wn._("This is PERMANENT action and you cannot undo. Continue?"), function() { - wn.call({ + return wn.call({ method: 'webnotes.widgets.reportview.delete_items', args: { items: delete_list, diff --git a/public/js/wn/views/sidebar_stats.js b/public/js/wn/views/sidebar_stats.js index 3d2f51f6b7..645e5b80e3 100644 --- a/public/js/wn/views/sidebar_stats.js +++ b/public/js/wn/views/sidebar_stats.js @@ -17,7 +17,7 @@ wn.views.SidebarStats = Class.extend({ }, get_stats: function() { var me = this - wn.call({ + return wn.call({ type: "GET", method: 'webnotes.widgets.reportview.get_stats', args: { From 94db64c112e5eb5b1a0420edf8394bd37fa39970 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 30 Jul 2013 14:39:10 +0530 Subject: [PATCH 2/4] [minor] reportview - extract table if fields exist --- webnotes/widgets/reportview.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py index 88ad14e807..182cecf703 100644 --- a/webnotes/widgets/reportview.py +++ b/webnotes/widgets/reportview.py @@ -248,18 +248,20 @@ def get_tables(doctype, fields): tables = ['`tab' + doctype + '`'] # add tables from fields - for f in fields or []: - if "." not in f: continue + if fields: + for f in fields: + if "." not in f: continue - table_name = f.split('.')[0] - if table_name.lower().startswith('group_concat('): - table_name = table_name[13:] - if table_name.lower().startswith('ifnull('): - table_name = table_name[7:] - if not table_name[0]=='`': - table_name = '`' + table_name + '`' - if not table_name in tables: - tables.append(table_name) + table_name = f.split('.')[0] + if table_name.lower().startswith('group_concat('): + table_name = table_name[13:] + if table_name.lower().startswith('ifnull('): + table_name = table_name[7:] + if not table_name[0]=='`': + table_name = '`' + table_name + '`' + if not table_name in tables: + tables.append(table_name) + return tables @webnotes.whitelist() From 513a78bded8449df02a77f590a104e2d55bde979 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 30 Jul 2013 14:42:14 +0530 Subject: [PATCH 3/4] [fix] [minor] fixes post changes in script manager trigger [issue] webnotes/wnframework#228 --- core/page/data_import_tool/data_import_tool.js | 2 +- core/page/permission_manager/permission_manager.js | 6 +++--- core/page/todo/todo.js | 2 +- core/page/user_properties/user_properties.js | 2 +- public/js/wn/misc/tools.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/page/data_import_tool/data_import_tool.js b/core/page/data_import_tool/data_import_tool.js index 8b20a2b831..be4d494bb8 100644 --- a/core/page/data_import_tool/data_import_tool.js +++ b/core/page/data_import_tool/data_import_tool.js @@ -46,7 +46,7 @@ wn.pages['data-import-tool'].onload = function(wrapper) { "Performing hardcore import process....", 100); // load doctypes - return wn.call({ + wn.call({ method:'core.page.data_import_tool.data_import_tool.get_doctypes', callback: function(r) { $select.add_options(['Select...'].concat(r.message)); diff --git a/core/page/permission_manager/permission_manager.js b/core/page/permission_manager/permission_manager.js index e5f668e7fa..11ddc27e85 100644 --- a/core/page/permission_manager/permission_manager.js +++ b/core/page/permission_manager/permission_manager.js @@ -151,7 +151,7 @@ wn.PermissionEngine = Class.extend({ return; } // get permissions - return wn.call({ + wn.call({ module: "core", page: "permission_manager", method: "get_permissions", @@ -239,7 +239,7 @@ wn.PermissionEngine = Class.extend({ .attr("data-role", role) .click(function() { var role = $(this).attr("data-role"); - return wn.call({ + wn.call({ module: "core", page: "permission_manager", method: "get_users_with_role", @@ -355,7 +355,7 @@ wn.PermissionEngine = Class.extend({ if(!args) { return; } - return wn.call({ + wn.call({ module: "core", page: "permission_manager", method: "add", diff --git a/core/page/todo/todo.js b/core/page/todo/todo.js index 9adfc62ca4..818288fa93 100644 --- a/core/page/todo/todo.js +++ b/core/page/todo/todo.js @@ -117,7 +117,7 @@ erpnext.todo.ToDoItem = Class.extend({ .data('name', todo.name) .click(function() { $(this).parent().css('opacity', 0.5); - return wn.call({ + wn.call({ method:'core.page.todo.todo.delete', args: {name: $(this).data('name')}, callback: function() { diff --git a/core/page/user_properties/user_properties.js b/core/page/user_properties/user_properties.js index cbb3014ce2..11398bf072 100644 --- a/core/page/user_properties/user_properties.js +++ b/core/page/user_properties/user_properties.js @@ -212,7 +212,7 @@ wn.UserProperties = Class.extend({ if(!args) { return; } - return wn.call({ + wn.call({ module: "core", page: "user_properties", method: "add", diff --git a/public/js/wn/misc/tools.js b/public/js/wn/misc/tools.js index 18220e7bfd..cccc5f6cd9 100644 --- a/public/js/wn/misc/tools.js +++ b/public/js/wn/misc/tools.js @@ -111,7 +111,7 @@ wn.slickgrid_tools = { $.each(grid.getColumns(), function(i, col) { if(col.docfield && col.previousWidth != col.width && !in_list(wn.model.std_fields_list, col.docfield.fieldname) ) { - return wn.call({ + wn.call({ method:"webnotes.client.make_width_property_setter", args: { doclist: [{ From 23e2a5103fc65741b66250b5be9cb751b45439e2 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 30 Jul 2013 16:09:17 +0530 Subject: [PATCH 4/4] [fix] error while installing erpnext --- webnotes/utils/dateutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/utils/dateutils.py b/webnotes/utils/dateutils.py index d352428f9e..bd4e8fdbb6 100644 --- a/webnotes/utils/dateutils.py +++ b/webnotes/utils/dateutils.py @@ -75,8 +75,8 @@ def parse_date(date): return parsed_date def get_user_date_format(): + global user_date_format if not user_date_format: - global user_date_format user_date_format = webnotes.defaults.get_global_default("date_format") return user_date_format