From bbd220049b05f1c98d5c5de4f8828c53b30bbd25 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 31 Jul 2025 15:40:40 +0200 Subject: [PATCH] Bug 38311: Do not use ID for column filters --- .../tables/items/catalogue_detail.inc | 29 ++++---- .../prog/en/includes/patron-search.inc | 71 ++++++++++--------- .../prog/en/modules/catalogue/itemsearch.tt | 35 +++++---- .../prog/en/modules/circ/pendingbookings.tt | 5 +- .../prog/en/modules/circ/pendingreserves.tt | 27 +++++-- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 17 +++-- 6 files changed, 101 insertions(+), 83 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index b5a93b4a945..04509626bb9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -205,15 +205,13 @@ }); }); - const all_libraries = [% To.json(Branches.all) | $raw %]; - const libraries_filters = all_libraries.map(e => { + const all_libraries = [% To.json(Branches.all) | $raw %].map(e => { e["_id"] = e["branchcode"]; e["_str"] = e["branchname"]; return e; }); const libraries_names = new Map(all_libraries.map( l => [l.branchcode, l.branchname] )); - const all_item_types = [% To.json(ItemTypes.Get) | $raw %]; - const item_types_filters = all_item_types.map(e => { + const all_item_types = [% To.json(ItemTypes.Get) | $raw %].map(e => { e["_id"] = e["itemtype"]; e["_str"] = e["translated_description"]; return e; @@ -241,6 +239,13 @@ collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])), }; + let filters_options = { + item_types: all_item_types, + libraries: all_libraries, + libraries: all_libraries, + statuses: all_statuses, + }; + [% IF Koha.Preference('URLLinkText') %] const url_link_text = "[% Koha.Preference('URLLinkText') | html %]"; [% ELSE %] @@ -326,18 +331,6 @@ return $("#" + tab_id + "_status select").val(); }; - 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 }, order: [], @@ -390,6 +383,7 @@ { data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype datatype: "coded_value:item_type", + dataFilter: "item_types", className: "itype", searchable: true, orderable: true, @@ -410,6 +404,7 @@ { data: "me.holding_library_id", datatype: "coded_value:library", + dataFilter: "libraries", className: "location", searchable: true, orderable: true, @@ -420,6 +415,7 @@ { data: "me.home_library_id", datatype: "coded_value:library", + dataFilter: "libraries", className: "homebranch", searchable: true, orderable: true, @@ -510,6 +506,7 @@ { data: "", className: "status", + dataFilter: "statuses", searchable: false, orderable: false, render: function (data, type, row, meta) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index a4f76e8e116..a5ef1af0d2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -175,9 +175,9 @@ [% CASE 'address-library' %] Address [% CASE 'branch' %] - Library + Library [% CASE 'category' %] - Category + Category [% CASE 'dateexpiry' %] Expires on [% CASE 'borrowernotes' %] @@ -189,17 +189,9 @@ [% CASE 'account_balance' %] Fines [% CASE 'sort1' %] - [% IF av_bsort1.size %] - Sort 1 - [% ELSE %] - Sort 1 - [% END %] + Sort 1 [% CASE 'sort2' %] - [% IF av_bsort2.size %] - Sort 2 - [% ELSE %] - Sort 2 - [% END %] + Sort 2 [% CASE 'action' %]   [% END %] @@ -244,9 +236,7 @@ [% END %]