@@ -, +, @@
place
for the 'Barcode' column
column successfully
many search variations as possible -- it should all now
work without any glitches!
---
.../plugins/jquery.dataTables.columnFilter.js | 68 +++++++++++--------
.../prog/en/includes/columns_settings.inc | 2 +-
.../prog/en/modules/catalogue/detail.tt | 4 ++
.../intranet-tmpl/prog/js/table_filters.js | 32 ++++++---
4 files changed, 65 insertions(+), 41 deletions(-)
--- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js
+++ a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js
@@ -523,17 +523,20 @@
var sFilterRow = "tr"; //Before fix for ColVis
if (properties.sPlaceHolder == "head:after") {
- var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
- //tr.appendTo($(oTable.fnSettings().nTHead));
- if (oTable.fnSettings().bSortCellsTop) {
- tr.prependTo($(oTable.fnSettings().nTHead));
- //tr.appendTo($("thead", oTable));
- aoFilterCells = oTable.fnSettings().aoHeader[1];
- }
- else {
- tr.appendTo($(oTable.fnSettings().nTHead));
- //tr.prependTo($("thead", oTable));
- aoFilterCells = oTable.fnSettings().aoHeader[0];
+
+ if (!properties.bFiltersAlreadyActivated) {
+ var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
+ //tr.appendTo($(oTable.fnSettings().nTHead));
+ if (oTable.fnSettings().bSortCellsTop) {
+ tr.prependTo($(oTable.fnSettings().nTHead));
+ //tr.appendTo($("thead", oTable));
+ aoFilterCells = oTable.fnSettings().aoHeader[1];
+ }
+ else {
+ tr.appendTo($(oTable.fnSettings().nTHead));
+ //tr.prependTo($("thead", oTable));
+ aoFilterCells = oTable.fnSettings().aoHeader[0];
+ }
}
sFilterRow = "tr:last";
@@ -541,27 +544,30 @@
} else if (properties.sPlaceHolder == "head:before") {
- if (oTable.fnSettings().bSortCellsTop) {
- var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
- tr.appendTo($(oTable.fnSettings().nTHead));
- aoFilterCells = oTable.fnSettings().aoHeader[1];
- } else {
- aoFilterCells = oTable.fnSettings().aoHeader[0];
+ if (!properties.bFiltersAlreadyActivated) {
+ if (oTable.fnSettings().bSortCellsTop) {
+ var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
+ tr.appendTo($(oTable.fnSettings().nTHead));
+ aoFilterCells = oTable.fnSettings().aoHeader[1];
+ } else {
+ aoFilterCells = oTable.fnSettings().aoHeader[0];
+ }
+ /*else {
+ //tr.prependTo($("thead", oTable));
+ sFilterRow = "tr:first";
+ }*/
}
- /*else {
- //tr.prependTo($("thead", oTable));
- sFilterRow = "tr:first";
- }*/
sFilterRow = "tr:first";
-
oHost = oTable.fnSettings().nTHead;
-
}
- //$(sFilterRow + " th", oHost).each(function (index) {//bug with ColVis
- $(aoFilterCells).each(function (index) {//fix for ColVis
+ $(sFilterRow + " th", oHost).each(function (index) {
+ //$(aoFilterCells).each(function (index) {//fix for ColVis
+
+ var bHeaderHasInput = $(this).find('input').length;
+
i = index;
var aoColumn = { type: "text",
bRegex: false,
@@ -569,16 +575,20 @@
iMaxLenght: -1,
iFilterLength: 0
};
+
if (properties.aoColumns != null) {
if (properties.aoColumns.length < i || properties.aoColumns[i] == null)
return;
aoColumn = properties.aoColumns[i];
}
- //label = $(this).text(); //Before fix for ColVis
- label = $($(this)[0].cell).text(); //Fix for ColVis
+ if (bHeaderHasInput)
+ label = $(this).find('input').val();
+ else
+ label = $(this).text();
+ //label = $($(this)[0].cell).text(); //Fix for ColVis
if (aoColumn.sSelector == null) {
- //th = $($(this)[0]);//Before fix for ColVis
- th = $($(this)[0].cell); //Fix for ColVis
+ th = $($(this)[0]);
+ //th = $($(this)[0].cell); //Fix for ColVis
}
else {
th = $(aoColumn.sSelector);
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
@@ -216,7 +216,7 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) {
// This function can be created separately and used to trigger
// an event after the DataTable has loaded AND column visibility
// has been updated according to the table's configuration
- columnsInit();
+ columnsInit(this);
}
}).columns( hidden_ids ).visible( false );
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -1990,6 +1990,10 @@ Note that permanent location is a code, and location may be an authval.
});
+ function columnsInit(table) {
+ activate_filters(table.id, false);
+ }
+
[% IF found1 && Koha.Preference('RetainCatalogSearchTerms') %]
$(document).ready(function() {
var search_index = localStorage.getItem("cat_search_pulldown_selection");
--- a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js
+++ a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js
@@ -1,4 +1,4 @@
-function activate_filters(id) {
+function activate_filters(id, bShowFilters) {
var table = $("#" + id );
if (table.length == 1) {
filters_row = table.find('thead tr.filters_row');
@@ -16,19 +16,29 @@ function activate_filters(id) {
table.dataTable().columnFilter({
'sPlaceHolder': 'head:after'
, 'aoColumns': aoColumns
+ ,'bFiltersAlreadyActivated': false
});
filters_row.addClass('columnFilter');
+ } else {
+ table.dataTable().columnFilter({
+ 'sPlaceHolder': 'head:after'
+ , 'aoColumns': aoColumns
+ ,'bFiltersAlreadyActivated': true
+ });
}
- filters_row.show();
- }
- $('#' + id + '_activate_filters')
- .html(' ' + __('Deactivate filters') )
- .unbind('click')
- .click(function() {
- deactivate_filters(id);
- return false;
- });
+ if (bShowFilters) {
+ filters_row.show();
+
+ $('#' + id + '_activate_filters')
+ .html(' ' + __('Deactivate filters') )
+ .unbind('click')
+ .click(function() {
+ deactivate_filters(id);
+ return false;
+ });
+ }
+ }
}
function deactivate_filters(id) {
@@ -44,7 +54,7 @@ function deactivate_filters(id) {
.html(' ' + __('Activate filters') )
.unbind('click')
.click(function() {
- activate_filters(id);
+ activate_filters(id, true);
return false;
});
}
--