Bug 40709: Use data-colname for adding filters

To test:
1. Set the 'item-level_itypes' system preference to 'Bibliographic record'
2. Go to any record that contains items and look at the holdings table.
3. Click 'Show filters'.
4. Notice that the Status column doesn't appear to have a filter.
5. APPLY PATCH
6. Try again, the Status filter should appear correctly. Make sure all other filters appear correct.
7. Set 'item-level_itypes' back to 'specific item'.
8. Make sure the filter still appears correctly. Make sure all other filters appear correct.

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d5adba9101)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Lucas Gass 2025-08-26 20:17:42 +00:00 committed by Paul Derscheid
parent 8e6e70cd35
commit 58fb7cd002
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 11 additions and 8 deletions

View File

@ -326,14 +326,17 @@
return $("#" + tab_id + "_status select").val();
};
let offset = 2;
[% UNLESS Koha.Preference('LocalCoverImages') %]offset--;[% END %]
let filters_options = {
[offset] : () => all_item_types,
[offset+1] : () => all_libraries,
[offset+2] : () => all_libraries,
[offset+7] : () => all_statuses,
};
let filters_options = {};
let itype_col = $("#" + tab_id + "_table thead th[data-colname='itype']").index();
let holdingbranch_col = $("#" + tab_id + "_table thead th[data-colname='holdingbranch']").index();
let homebranch_col = $("#" + tab_id + "_table thead th[data-colname='homebranch']").index();
let status_col = $("#" + tab_id + "_table thead th[data-colname='status']").index();
if ( itype_col >= 0 ) filters_options[itype_col] = () => all_item_types;
if ( holdingbranch_col >= 0 ) filters_options[holdingbranch_col] = () => all_libraries;
if ( homebranch_col >= 0 ) filters_options[homebranch_col] = () => all_libraries;
if ( status_col >= 0 ) filters_options[status_col] = () => all_statuses;
var items_table = $("#" + tab_id + '_table').kohaTable({
ajax: { url: item_table_url },