From fb14ea41e8fa5d0eb4706ee3dccf2dc2fa44305a Mon Sep 17 00:00:00 2001 From: ci2014 Date: Sun, 30 Jul 2017 21:31:28 +0200 Subject: [PATCH] Update quick_entry.js Add init_callback, for having a callback, when the dialog is rendered and having the ability to use client side scripting for quick entry forms. --- frappe/public/js/frappe/form/quick_entry.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/form/quick_entry.js b/frappe/public/js/frappe/form/quick_entry.js index 299f14176d..d80cbb9cb2 100644 --- a/frappe/public/js/frappe/form/quick_entry.js +++ b/frappe/public/js/frappe/form/quick_entry.js @@ -1,6 +1,6 @@ frappe.provide('frappe.ui.form'); -frappe.ui.form.make_quick_entry = (doctype, after_insert) => { +frappe.ui.form.make_quick_entry = (doctype, after_insert, init_callback) => { var trimmed_doctype = doctype.replace(/ /g, ''); var controller_name = "QuickEntryForm"; @@ -8,7 +8,7 @@ frappe.ui.form.make_quick_entry = (doctype, after_insert) => { controller_name = trimmed_doctype + "QuickEntryForm"; } - frappe.quick_entry = new frappe.ui.form[controller_name](doctype, after_insert); + frappe.quick_entry = new frappe.ui.form[controller_name](doctype, after_insert, init_callback); return frappe.quick_entry.setup(); }; @@ -16,6 +16,7 @@ frappe.ui.form.QuickEntryForm = Class.extend({ init: function(doctype, after_insert){ this.doctype = doctype; this.after_insert = after_insert; + this.init_callback = init_callback; }, setup: function() { @@ -106,6 +107,10 @@ frappe.ui.form.QuickEntryForm = Class.extend({ this.dialog.onhide = () => frappe.quick_entry = null; this.dialog.show(); this.set_defaults(); + + if (this.init_callback) { + this.init_callback(this.dialog); + } }, register_primary_action: function(){ @@ -141,7 +146,7 @@ frappe.ui.form.QuickEntryForm = Class.extend({ frappe.ui.form.update_calling_link(me.dialog.doc); } else { if(me.after_insert) { - me.after_insert(me.dialig.doc); + me.after_insert(me.dialog.doc); } else { me.open_from_if_not_list(); }