UI: Device Table hide/show decommissioned devices

This commit is contained in:
Gary Sharp
2017-03-29 12:18:37 +11:00
parent d6ee70b860
commit 82183f6508
6 changed files with 108 additions and 6 deletions
@@ -101,7 +101,32 @@
}
};
$table.dataTable(dataTableOptions);
var $dataTable = $table.dataTable(dataTableOptions);
// Contains Decommissioned Devces?
var $tbody = $table.children('tbody');
var $decommissionedDevices = $tbody.children('tr.decommissioned');
if ($decommissionedDevices.length > 0) {
var wrapper = $(this).closest('.dataTables_wrapper');
var $host = $('<div class="dataTables_decommissioned"><label><input type="checkbox" /><span></span></label></div>').prependTo(wrapper);
var $span = $host.find('span').text('Hide Decommissioned (' + $decommissionedDevices.length + ')');
wrapper.on('change', '.dataTables_decommissioned input', function () {
var $this = $(this);
if ($this.is(':checked')) {
$table.addClass('hideDecommissioned');
} else {
$table.removeClass('hideDecommissioned');
}
scrollCheck.apply($table[0]);
return false;
});
}
dataTables.push(this);
});