fix(HR) : Filter Leave Type based on allocation for a particular employee (#22050)
* table was showing empty with just headers when no leaves allocated, fixed template code
* added filters on Leave Type based on leave allocation for a particular employee and to/from dates
diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index 1f50e27..473aae6 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -67,6 +67,13 @@
})
);
frm.dashboard.show();
+ frm.set_query('leave_type', function(){
+ return {
+ filters : [
+ ['leave_type_name', 'in', Object.keys(leave_details)]
+ ]
+ }
+ });
}
},
diff --git a/erpnext/hr/doctype/leave_application/leave_application_dashboard.html b/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
index 295f3b4..d30e3b9 100644
--- a/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
+++ b/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
@@ -1,5 +1,5 @@
-{% if data %}
+{% if not jQuery.isEmptyObject(data) %}
<h5 style="margin-top: 20px;"> {{ __("Allocated Leaves") }} </h5>
<table class="table table-bordered small">
<thead>
@@ -11,7 +11,6 @@
<th style="width: 16%" class="text-right">{{ __("Pending Leaves") }}</th>
<th style="width: 16%" class="text-right">{{ __("Available Leaves") }}</th>
</tr>
-
</thead>
<tbody>
{% for(const [key, value] of Object.entries(data)) { %}
@@ -26,6 +25,6 @@
{% } %}
</tbody>
</table>
-{% } else { %}
+{% else %}
<p style="margin-top: 30px;"> No Leaves have been allocated. </p>
-{% } %}
\ No newline at end of file
+{% endif %}
\ No newline at end of file