Bug 40565: Fix column filters on item search
The item search table is different from the other tables.
It is using server-side but its own way (not using the REST API).
Test plan:
Search items and filter using the column filters: collections, library,
item types, AVs, etc.
QA: I am not very happy with this patch but, feel free to suggest a
better fix!
Note that "results" was too generic and it felt better to adjust it.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 825172c9f2)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
f49b6dde10
commit
01d94090c7
|
|
@ -466,7 +466,7 @@
|
|||
let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || [];
|
||||
if( item_search_selections.length > 0 ){
|
||||
showItemSelections( item_search_selections.length );
|
||||
$("#results input[type='checkbox']").each(function(){
|
||||
$("#item_search input[type='checkbox']").each(function(){
|
||||
var itemnumber = $(this).val();
|
||||
if( item_search_selections.indexOf( itemnumber ) >= 0 ){
|
||||
$(this).prop("checked", true );
|
||||
|
|
@ -554,7 +554,7 @@
|
|||
+ ' <a href="#" id="clear-row-selection"><i class="fa fa-times"></i> ' + _("Clear") + '</a>'
|
||||
+ ' </div>'
|
||||
+ ' </div>'
|
||||
+ ' <table id="results">'
|
||||
+ ' <table id="item_search">'
|
||||
+ ' <thead>' + tr + '</thead>'
|
||||
+ ' <tbody></tbody>'
|
||||
+ ' </table>'
|
||||
|
|
@ -664,7 +664,7 @@
|
|||
};
|
||||
|
||||
var table_settings = [% TablesSettings.GetTableSettings( 'catalogue', 'itemsearch', 'results', 'json' ) | $raw %];
|
||||
$('#results').kohaTable( {
|
||||
$('#item_search').kohaTable( {
|
||||
"bKohaColumnsUseNames": true,
|
||||
"destroy": true,
|
||||
"serverSide": true,
|
||||
|
|
@ -719,7 +719,7 @@
|
|||
fixedHeader: false // There is a bug on this view
|
||||
}, table_settings, true, null, filters_options );
|
||||
|
||||
$('#results').on('draw.dt', function (e, settings) {
|
||||
$('#item_search').on('draw.dt', function (e, settings) {
|
||||
prepSelections();
|
||||
$('[data-bs-toggle="tooltip"]').tooltip();
|
||||
});
|
||||
|
|
@ -767,7 +767,7 @@
|
|||
|
||||
$("body").on("click", "#select_all", function(e) {
|
||||
e.preventDefault();
|
||||
$("#results input[type='checkbox']").each(function(){
|
||||
$("#item_search input[type='checkbox']").each(function(){
|
||||
if( $(this).prop("checked") == false ){
|
||||
$(this).prop( "checked", true ).change();
|
||||
}
|
||||
|
|
@ -776,7 +776,7 @@
|
|||
|
||||
$("body").on("click", "#clear_all", function(e) {
|
||||
e.preventDefault();
|
||||
$("#results input[type='checkbox']").each(function(){
|
||||
$("#item_search input[type='checkbox']").each(function(){
|
||||
if( $(this).prop("checked") == true ){
|
||||
$(this).prop( "checked", false ).change();
|
||||
}
|
||||
|
|
@ -785,12 +785,12 @@
|
|||
|
||||
$("body").on("click", "#clear-row-selection", function(e){
|
||||
e.preventDefault();
|
||||
$("#results input[type='checkbox']").prop("checked" ,false ).change();
|
||||
$("#item_search input[type='checkbox']").prop("checked" ,false ).change();
|
||||
localStorage.removeItem("item_search_selections");
|
||||
showItemSelections( 0 );
|
||||
});
|
||||
|
||||
$("body").on('change', '#results input[type="checkbox"]', function() {
|
||||
$("body").on('change', '#item_search input[type="checkbox"]', function() {
|
||||
let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || [];
|
||||
var itemnumber = $(this).val();
|
||||
if( $(this).prop("checked") ){
|
||||
|
|
@ -860,7 +860,7 @@
|
|||
batch_mod_form.submit();
|
||||
});
|
||||
|
||||
$("body").on('click','#results tbody td',function(e){
|
||||
$("body").on('click','#item_search tbody td',function(e){
|
||||
var checkbox = $(this).find("input[type=checkbox]");
|
||||
if (e.target.type != "checkbox") {
|
||||
checkbox.prop('checked', !checkbox.prop("checked"));
|
||||
|
|
|
|||
|
|
@ -1034,10 +1034,15 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) {
|
|||
return this._id !== "" && this._str !== "";
|
||||
})
|
||||
.each(function () {
|
||||
let optionValue =
|
||||
table_dt.settings()[0].ajax !== null
|
||||
? `^${this._id}$`
|
||||
: this._id;
|
||||
let optionValue = this._id;
|
||||
|
||||
if (
|
||||
table_dt.settings()[0].ajax !== null &&
|
||||
table_node.attr("id") !== "item_search"
|
||||
) {
|
||||
optionValue = `^${this._id}$`;
|
||||
}
|
||||
|
||||
let o = $(
|
||||
`<option value="${optionValue}">${this._str}</option>`
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue