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
This commit is contained in:
Abhishek Balam 2020-05-30 01:02:06 +05:30 committed by GitHub
parent 7544160374
commit 40694c98aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -67,6 +67,13 @@ frappe.ui.form.on("Leave Application", {
}) })
); );
frm.dashboard.show(); frm.dashboard.show();
frm.set_query('leave_type', function(){
return {
filters : [
['leave_type_name', 'in', Object.keys(leave_details)]
]
}
});
} }
}, },

View File

@ -1,5 +1,5 @@
{% if data %} {% if not jQuery.isEmptyObject(data) %}
<h5 style="margin-top: 20px;"> {{ __("Allocated Leaves") }} </h5> <h5 style="margin-top: 20px;"> {{ __("Allocated Leaves") }} </h5>
<table class="table table-bordered small"> <table class="table table-bordered small">
<thead> <thead>
@ -11,7 +11,6 @@
<th style="width: 16%" class="text-right">{{ __("Pending Leaves") }}</th> <th style="width: 16%" class="text-right">{{ __("Pending Leaves") }}</th>
<th style="width: 16%" class="text-right">{{ __("Available Leaves") }}</th> <th style="width: 16%" class="text-right">{{ __("Available Leaves") }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for(const [key, value] of Object.entries(data)) { %} {% for(const [key, value] of Object.entries(data)) { %}
@ -26,6 +25,6 @@
{% } %} {% } %}
</tbody> </tbody>
</table> </table>
{% } else { %} {% else %}
<p style="margin-top: 30px;"> No Leaves have been allocated. </p> <p style="margin-top: 30px;"> No Leaves have been allocated. </p>
{% } %} {% endif %}