Bugzilla – Attachment 174806 Details for
Bug 38484
Filters on the "Holds to pull" page is broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38484: (bug 36640 follow-up) Fix filters on "Holds to pull"
Bug-38484-bug-36640-follow-up-Fix-filters-on-Holds.patch (text/plain), 6.08 KB, created by
Emily Lamancusa (emlam)
on 2024-11-19 18:49:53 UTC
(
hide
)
Description:
Bug 38484: (bug 36640 follow-up) Fix filters on "Holds to pull"
Filename:
MIME Type:
Creator:
Emily Lamancusa (emlam)
Created:
2024-11-19 18:49:53 UTC
Size:
6.08 KB
patch
obsolete
>From 1a1efe2635a188d33ae883d9d282e25cb2198dc6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Nov 2024 13:38:45 +0100 >Subject: [PATCH] Bug 38484: (bug 36640 follow-up) Fix filters on "Holds to > pull" > >On "Bug 36640: Remove fnAddFilters" I assume that it was only used for >debounce. But actually it was used on this table to add filtering. > >This patch adjusts how we deal with the filters on this table, reusing >the standard "add_filters" and "filters_options" parameters of >KohaTable. > >It also passes the DT object allowing to use DT's api. Here it is >useful to retrieve the data in the column. > >Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >--- > .../prog/en/modules/circ/pendingreserves.tt | 82 +++++-------------- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 2 +- > 2 files changed, 21 insertions(+), 63 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt >index 2a53dbaac1..5c0a190a79 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt >@@ -1,4 +1,5 @@ > [% USE raw %] >+[% USE To %] > [% USE Asset %] > [% USE Koha %] > [% USE KohaDates %] >@@ -251,27 +252,6 @@ > </tr> > [% END %] > </tbody> >- <tfoot> >- <tr> >- <td><input type="text" class="filter" data-column_num="0" placeholder="Pull this many items" style="width:95%"/></td> >- <td><input type="text" class="filter" data-column_num="1" placeholder="Items available" style="width:95%"/></td> >- <td><input type="text" class="filter" data-column_num="2" placeholder="Patron holds" style="width:95%"/></td> >- <td><input type="text" class="filter" data-column_num="3" placeholder="Patron name" style="width:95%"/></td> >- <td><input type="text" class="filter" data-column_num="4" placeholder="Title" style="width:95%"/></td> >- <td id="homebranchfilter"></td> >- <td></td> >- <td><input type="text" class="filter" data-column_num="7" placeholder="Call number" style="width:95%"/></td> >- <td><input type="text" class="filter" data-column_num="8" placeholder="Available copy" style="width:95%"/></td> >- <td><input type="text" class="filter" data-column_num="9" placeholder="Available enumeration" style="width:95%"/></td> >- <td id="itemtype-filter"></td> >- <td id="locationfilter"></td> >- <td></td> >- <td></td> >- <td></td> >- <td id="pickup-location"></td> >- <td></td> >- </tr> >- </tfoot> > </table> > [% ELSE %] > <strong>No items found.</strong> >@@ -326,57 +306,35 @@ > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'columns_settings.inc' %] > <script> >- function add_select(column){ >- // Create select element >- let select = document.createElement('select'); >- select.add(new Option('')); >- column.footer().replaceChildren(select); >- >- // Apply listener for user change in value >- select.addEventListener('change', function () { >- column >- .search(select.value, {exact: false}) >- .draw(); >- }); >- >+ function get_options(column){ > let regex = /(<([^>]+)>)/ig; // Remove html tags >- // Add list of options >- column >+ let options = [... new Set(column > .data() >+ .toArray() > .map(d => d.replace(regex, '').trim().split(/\n/gi).flat()) >- .unique() >- .sort() >- .each(function (d, j) { >- select.add(new Option(d)); >+ .flat() >+ .sort())]; >+ >+ return options >+ .map(e => { >+ return {_id: e, _str: e} > }); > } > > $(document).ready(function() { >+ [% SET libraries = Branches.all %] >+ let filters_options = { >+ [5] : (table_dt) => get_options(table_dt.column(5)), >+ [10] : (table_dt) => get_options(table_dt.column(10)), >+ [11] : (table_dt) => get_options(table_dt.column(11)), >+ [15] : (table_dt) => get_options(table_dt.column(15)), >+ }; >+ >+ > var table_settings = [% TablesSettings.GetTableSettings('circ', 'holds', 'holds-to-pull', 'json') | $raw %]; > var holdst = KohaTable("holdst", { > "pagingType": "full_numbers", >- initComplete: function () { >- // homebranch >- add_select( >- this.api() >- .column(5)); >- >- // itemtype >- add_select( >- this.api() >- .column(10)); >- >- // location >- add_select( >- this.api() >- .column(11)); >- >- // pickup-location >- add_select( >- this.api() >- .column(15)); >- }, >- }, table_settings); >+ }, table_settings, true, null, filters_options); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 9813505421..b46784e1cb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -808,7 +808,7 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { > if ( !filters_options.hasOwnProperty(i) ) { > filters_options[i] = eval(filter_type) > } else if ( typeof filters_options[i] === "function" ) { >- filters_options[i] = filters_options[i]() >+ filters_options[i] = filters_options[i](table_dt) > } > $(filters_options[i]).each(function(){ > let o = $('<option value="%s">%s</option>'.format(this._id, this._str)); >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38484
:
174788
|
174806
|
174907
|
174908
|
174909