Bug 23049: Filter out system types by default

Test Plan
1) Navigate to the debit types management page added in previous patches
2) Note that system types are now filtered out by default
3) Click on the new unfilter button to include system types
4) Signoff

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-10-10 09:08:55 +01:00
parent 86ece7d2e5
commit 9641b3c8c7
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -151,6 +151,7 @@
[% IF debit_types.count %]
<table id="table_debit_types">
<thead>
<th>System</th>
<th>Code</th>
<th>Description</th>
<th>Default amount</th>
@ -161,6 +162,7 @@
<tbody>
[% FOREACH debit_type IN debit_types %]
<tr>
<td>[% debit_type.is_system | html %]</td>
<td>[% debit_type.code | html %]</td>
<td>[% debit_type.description | html %]</td>
<td>[% debit_type.default_amount | $Price %]</td>
@ -217,14 +219,34 @@
<script>
$(document).ready(function() {
$("#table_debit_types").dataTable($.extend(true, {}, dataTablesDefaults, {
var txtActivefilter = _("Filter system debit types");
var txtInactivefilter = _("Show all debit types");
var table_debit_types = $("#table_debit_types").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
{ "aTargets": [ 0 ], "bSortable": false, "bVisible": false },
],
"aaSorting": [[ 1, "asc" ]],
"iDisplayLength": 10,
"sDom": 'C<"top pager"ilpfB><"#filter_s">tr<"bottom pager"ip>',
"iDisplayLength": 20,
"sPaginationType": "full_numbers"
}));
$("#filter_s").html('<p><a href="#" id="filter_system"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
$('#filter_system').click(function(e) {
e.preventDefault();
if ($(this).hasClass('filtered')) {
var filteredValue = '';
$(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
} else { //Not filtered. Let's do it!
var filteredValue = '0';
$(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
}
table_debit_types.fnFilter(filteredValue, 0, false, false);
$(this).toggleClass('filtered');
});
//Start filtered
$('#filter_system').click();
});
</script>
[% END %]