Bug 9573: Lost items report - add KohaTable to itemlost

Before this patch set, we used KohaTable to display a table with the
column visibility plugin, and an usual dataTable initialisation for the
filters.
For the lost items report table we will need both.
To do so we need to reorganize the code a bit

We cannot pass a selector but the id of the node which represents the
table. Indeed it is how works currently the filters (we may want to
improve that later)

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2017-10-05 14:35:24 -03:00
parent 771de35a2b
commit c2eb7633ca
13 changed files with 26 additions and 23 deletions

View File

@ -2,12 +2,14 @@
<script type="text/javascript">
function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
var id = 0;
var counter = 0;
var hidden_ids = [];
var included_ids = [];
var selector = '#' + id_selector;
$(columns_settings).each( function() {
var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( 'th' );
var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : id;
var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : counter;
if ( used_id == -1 ) return;
if ( this['is_hidden'] == "1" ) {
@ -16,7 +18,7 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
if ( this['cannot_be_toggled'] == "0" ) {
included_ids.push( used_id );
}
id++;
counter++;
});
dt_parameters[ "buttons" ] = [
{
@ -26,7 +28,7 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
}
];
var table = $('#' + id_selector + ' table');
var table = $(selector);
if ( add_filters ) {
// Duplicate the table header row for columnFilter
thead_row = table.find('thead tr');
@ -46,7 +48,7 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
link = $('<a>')
.attr('href', '#')
.attr('id', id_selector + '_activate_filters');
$("." + id_selector + "_table_controls").prepend(link);
$("." + id_selector + "_table_controls").prepend(link);
deactivate_filters(id_selector);
}

View File

@ -216,7 +216,7 @@
var MSG_REMOVE_PATRON = _("Remove");
$(document).ready(function() {
var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'histsearch', 'histsearcht', 'json' ) %];
KohaTable("#histsearcht", {
KohaTable("histsearcht", {
"aoColumnDefs": [
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }

View File

@ -26,7 +26,7 @@ function check_uncheck() {
$(document).ready(function() {
var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) %];
late_orderst = KohaTable("#late_orders", {
late_orderst = KohaTable("late_orders", {
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },

View File

@ -235,7 +235,7 @@
$(document).ready(function() {
columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'currency', 'currencies-table', 'json' ) %]
var issuest = KohaTable("#currencies-table", {
var issuest = KohaTable("currencies-table", {
dom: 'B<"clearfix">t',
"columnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },

View File

@ -310,7 +310,7 @@
[% items_table_block_iter = 0 %]
[% BLOCK items_table %]
[% items_table_block_iter = items_table_block_iter + 1 %]
<div class="[% tab %]_table_controls">
<div class="[% tab %]_table_table_controls">
[% IF (StaffDetailItemSelection) %]
| <a href="#" class="SelectAll" data-tab="[% tab %]"><i class="fa fa-check"></i> Select all</a> |
<a href="#" class="ClearAll" data-tab="[% tab %]"><i class="fa fa-remove"></i> Clear all</a>
@ -325,7 +325,7 @@
</span>
[% END %]
</div>
<table class="items_table">
<table class="items_table" id="[% tab %]_table">
<thead>
<tr>
[% IF (StaffDetailItemSelection) %]<th class="NoSort"></th>[% END %]
@ -1039,7 +1039,7 @@
browser.show();
$(document).ready(function() {
var ids = ['holdings', 'otherholdings'];
var ids = ['holdings_table', 'otherholdings_table'];
for (var i in ids) {
var id = ids[i];

View File

@ -58,7 +58,7 @@ $(document).ready(function(){
// Skip the first column
columns_settings.unshift( { cannot_be_toggled: "1" } );
var itemst = KohaTable("#itemst", {
var itemst = KohaTable("itemst", {
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
],

View File

@ -155,7 +155,7 @@
<script type="text/javascript">
$(document).ready(function() {
var columns_settings = [% ColumnsSettings.GetColumns('circ', 'holds', 'holds-to-pull', 'json') %];
var holdst = KohaTable("#holdst", {
var holdst = KohaTable("holdst", {
"aoColumnDefs": [
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] },

View File

@ -715,7 +715,7 @@
[% END %]
var columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'returns', 'checkedintable', 'json' ) %]
var returns_table = KohaTable("#checkedintable", {
var returns_table = KohaTable("checkedintable", {
"bFilter":false,
"bPaginate":false,
"bInfo":false,

View File

@ -215,7 +215,7 @@
$('#holdst thead input').on('change keyup keydown', filterColumn);
var columns_settings = [% ColumnsSettings.GetColumns('circ', 'view_holdsqueue', 'holds-table', 'json') %];
var holdst = KohaTable("#holdst", {
var holdst = KohaTable("holdst", {
"aaSorting": [[ 3, "asc" ]],
"aoColumns": [
{ "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null

View File

@ -131,7 +131,7 @@
var txtActivefilter = _("Filter paid transactions");
var txtInactivefilter = _("Show all transactions");
var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') %];
var table_account_fines = KohaTable("#table_account_fines", {
var table_account_fines = KohaTable("table_account_fines", {
"sPaginationType": "four_button",
'aaSorting': [[0, 'desc']],
"sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',

View File

@ -5,7 +5,6 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
</head>
@ -382,7 +381,7 @@
[%# Remove the first column if we do not display the checkbox %]
columns_settings.splice(0, 1);
[% END %]
dtMemberResults = KohaTable("#memberresultst", {
dtMemberResults = KohaTable("memberresultst", {
'bServerSide': true,
'sAjaxSource': "/cgi-bin/koha/svc/members/search",
'fnServerData': function(sSource, aoData, fnCallback) {

View File

@ -141,20 +141,22 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
[% INCLUDE 'columns_settings.inc' %]
<script type="text/javascript" src="[% interface %]/[% theme %]/js/table_filters.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'lostitems', 'lostitems-table', 'json' ) %];
var lostitems_table = KohaTable("#lostitems-table", {
var lostitems_table = KohaTable("lostitems-table", {
"dom": 'B<"clearfix">t',
"aaSorting": [],
"aoColumnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
],
'bAutoWidth': false,
"bPaginate": false,
}, columns_settings);
}, columns_settings, 'with_filters');
});
</script>
[% END %]

View File

@ -1,5 +1,5 @@
function activate_filters(id) {
var table = $("#" + id + " table");
var table = $("#" + id );
if (table.length == 1) {
filters_row = table.find('thead tr.filters_row');
@ -32,7 +32,7 @@ function activate_filters(id) {
}
function deactivate_filters(id) {
filters_row = $("#" + id + " table").find('thead tr.filters_row');
filters_row = $("#" + id ).find('thead tr.filters_row');
filters_row.find('input[type="text"]')
.val('') // Empty filter text boxes