From 489c81054edf73807a516aec8c4ed471c4fdfa4e Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 20 Nov 2015 15:47:47 +0100 Subject: [PATCH] Bug 15235: Add column filters to checkouts table This adds a switch that allow to enable/disable column filters on checkouts table (disabled by default) Depends on bug 15219 --- .../plugins/jquery.dataTables.columnFilter.js | 2 +- koha-tmpl/intranet-tmpl/prog/en/css/datatables.css | 11 ++++ .../prog/en/includes/checkouts-table.inc | 19 +++++++ .../intranet-tmpl/prog/en/includes/strings.inc | 1 + koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js | 63 ++++++++++++++++++++++ .../prog/en/modules/circ/circulation.tt | 1 + .../prog/en/modules/members/moremember.tt | 1 + 7 files changed, 97 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js index 89343f5..342ecd0 100644 --- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js +++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js @@ -250,7 +250,6 @@ //th.html(_fnRangeLabelPart(0)); var sFromId = oTable.attr("id") + '_range_from_' + i; var from = $(''); - from.datepicker(); //th.append(from); //th.append(_fnRangeLabelPart(1)); var sToId = oTable.attr("id") + '_range_to_' + i; @@ -275,6 +274,7 @@ th.wrapInner(''); + from.datepicker(); to.datepicker(); var index = i; aiCustomSearch_Indexes.push(i); diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css b/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css index 1f92947..b4a6ae0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css @@ -243,6 +243,17 @@ span.filter_column > input.text_filter { font-size: 80%; width: 100%; padding: 0; + box-sizing: border-box; +} + +span.filter_column.filter_date_range { + white-space: nowrap; +} + +span.filter_column > input.date_range_filter { + font-size: 80%; + width: 6em; + padding: 0; } /* Row grouping */ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index ce2f0e9..67f53c5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -8,6 +8,25 @@
+ + + + + + + + + + + + + + + + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc index 73a3f60..35e6053 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc @@ -31,5 +31,6 @@ var YES = _("Yes"); var INHOUSE_USE = _("On-site checkout"); var GROUP_TODAYS_CHECKOUTS = _("Group today's checkouts"); + var SHOW_COLUMN_FILTERS = _("Show column filters"); //]]> diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js index ed09beb..8cfbf2e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -21,6 +21,50 @@ function disableGrouping(datatable) { } } +function enableFiltering(datatable) { + var oSettings = datatable.fnSettings(); + var filters_row = $(oSettings.nTable).find('thead tr.filters_row'); + if (!filters_row.hasClass('columnFilter')) { + datatable.columnFilter({ + sPlaceHolder: "head:after", + bUseColVis: true, + sRangeFormat: "From {from}
to {to}", + aoColumns: [ + null, + null, + null, + null, + { type: "date-range" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "date-range" }, + { type: "text" }, + { type: "text" }, + null, + null, + null, + null, + null, + null, + null + ] + }); + filters_row.addClass('columnFilter'); + } + filters_row.show(); +} + +function disableFiltering(datatable) { + var oSettings = datatable.fnSettings(); + var filters_row = $(oSettings.nTable).find('thead tr.filters_row'); + filters_row.find('input[type="text"]') + .val('') // Empty filter text boxes + .trigger('keyup') // Filter (display all rows) + .trigger('blur'); // Reset value to the column name + filters_row.hide(); +} + function loadTableData(datatable, borrowernumbers, offset, count) { offset = offset ? offset : 0; count = count ? count : 100; @@ -522,6 +566,25 @@ $(document).ready(function() { .append('') .appendTo('#issues-table_wrapper .top.pager'); + var filteringSwitch = $('') + .attr('id', 'issues-table-filtering-switch') + .css('vertical-align', 'middle') + .change(function() { + if ($(this).is(':checked')) { + enableFiltering(issuesTable); + } else { + disableFiltering(issuesTable); + } + }); + $('
') + .css('float', 'left') + .css('padding', '0.3em 0.5em') + .css('line-height', '1.9em') + .append(filteringSwitch) + .append(' ') + .append('') + .appendTo('#issues-table_wrapper .top.pager'); + loadTableData(issuesTable, borrowernumber); if ( $("#issues-table").length ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 1c5ceba..1093922 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -25,6 +25,7 @@ [% INCLUDE 'timepicker.inc' %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index b34e666..4e54f52 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -22,6 +22,7 @@ [% INCLUDE 'timepicker.inc' %] + -- 1.9.1