feat: show dashboard on submit

This commit is contained in:
Mangesh-Khairnar 2019-06-06 20:38:23 +05:30
parent 00c607116b
commit b840ba4407
2 changed files with 46 additions and 11 deletions

View File

@ -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: {

View File

@ -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",