From b840ba4407c3b0cf124b8bb9f3b32267f04ed821 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Thu, 6 Jun 2019 20:38:23 +0530 Subject: [PATCH] feat: show dashboard on submit --- .../leave_application/leave_application.js | 24 ++++++++------ .../leave_application/leave_application.json | 33 ++++++++++++++++++- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js index cb1042c5ef..2076ccd22a 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.js +++ b/erpnext/hr/doctype/leave_application/leave_application.js @@ -53,24 +53,27 @@ frappe.ui.form.on("Leave Application", { }, callback: function(r) { if (!r.exc && r.message['leave_allocation']) { - leave_details = r.message['leave_allocation']; + frm.set_value('leave_details', JSON.stringify(r.message['leave_allocation'])); } if (!r.exc && r.message['leave_approver']) { frm.set_value('leave_approver', r.message['leave_approver']); } } }); - - $("div").remove(".form-dashboard-section"); - let section = frm.dashboard.add_section( - frappe.render_template('leave_application_dashboard', { - data: leave_details - }) - ); - frm.dashboard.show(); + frm.trigger("create_dashboard") } }, + create_dashboard: function(frm) { + $("div").remove(".form-dashboard-section"); + let section = frm.dashboard.add_section( + frappe.render_template('leave_application_dashboard', { + data: JSON.parse(frm.doc.leave_details) + }) + ); + frm.dashboard.show(); + }, + refresh: function(frm) { if (frm.is_new()) { frm.trigger("calculate_total_days"); @@ -95,6 +98,7 @@ frappe.ui.form.on("Leave Application", { }; frappe.set_route("query-report", "Employee Leave Balance"); }); + frm.trigger("create_dashboard"); } }, @@ -148,7 +152,7 @@ frappe.ui.form.on("Leave Application", { }, get_leave_balance: function(frm) { - if(frm.doc.docstatus==0 && frm.doc.employee && frm.doc.leave_type && frm.doc.from_date) { + if(frm.doc.docstatus==0 && frm.doc.employee && frm.doc.leave_type && frm.doc.from_date && frm.doc.to_date) { return frappe.call({ method: "erpnext.hr.doctype.leave_application.leave_application.get_leave_balance_on", args: { diff --git a/erpnext/hr/doctype/leave_application/leave_application.json b/erpnext/hr/doctype/leave_application/leave_application.json index 812494c1c0..c59449f850 100644 --- a/erpnext/hr/doctype/leave_application/leave_application.json +++ b/erpnext/hr/doctype/leave_application/leave_application.json @@ -653,6 +653,37 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "leave_details", + "fieldtype": "Small Text", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Leave Details", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -951,7 +982,7 @@ "issingle": 0, "istable": 0, "max_attachments": 3, - "modified": "2019-05-30 11:28:14.745572", + "modified": "2019-05-31 11:30:14.745572", "modified_by": "Administrator", "module": "HR", "name": "Leave Application",