Bug 40876 - DT - Exact search not applied on second attribute for column filters
Summary: DT - Exact search not applied on second attribute for column filters
Status: Pushed to stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 40565
  Show dependency treegraph
 
Reported: 2025-09-25 10:30 UTC by Jonathan Druart
Modified: 2025-09-25 17:34 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00,25.05.04
Circulation function:


Attachments
Bug 40876: Apply 'exact' to all attributes when column filtering (6.77 KB, patch)
2025-09-25 10:37 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40876: Apply 'exact' to all attributes when column filtering (6.76 KB, patch)
2025-09-25 11:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40876: Apply 'exact' to all attributes when column filtering (6.82 KB, patch)
2025-09-25 15:45 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 40876: Apply 'exact' to all attributes when column filtering (6.87 KB, patch)
2025-09-25 16:17 UTC, Paul Derscheid
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2025-09-25 10:30:26 UTC
If you select an option in a column filter, the "exact" behaviour will only apply to the first attribute mapped to this column

eg. on the patron search we have "Libraries" mapped to library.name and library.library_id. If you select Centerville/CPL, the generate q parameter will be {name: CPL, id: {like: "%CPL%"}}
Comment 1 Jonathan Druart 2025-09-25 10:37:52 UTC
Created attachment 186910 [details] [review]
Bug 40876: Apply 'exact' to all attributes when column filtering

If you select an option in a column filter, the "exact" behaviour will
only apply to the first attribute mapped to this column

eg. on the patron search we have "Libraries" mapped to library.name and
library.library_id. If you select Centerville/CPL, the generated q
parameter will be {name: CPL, id: {like: "%CPL%"}}

This is caused by:
    if (value.match(/^\^(.*)\$$/)) {
        value = value.replace(/^\^/, "").replace(/\$$/, "");
On the second parameter we have lost the ^$ markers

Moving it out of the loop fixes the problem (and does not impact the
other behaviours: we search the same value for all the attributes

Test plan:
Create a library with code=CPLL and use if for a patron
Go to http://localhost:8081/cgi-bin/koha/members/members-home.pl
Click search
Select "Centerville" in the "Libraries" column filter
=> Without this patch you get the patrons from CPL and CPLL
=> With this patch applied only patrons from CPL are listed
Comment 2 Jonathan Druart 2025-09-25 11:34:16 UTC
Created attachment 186918 [details] [review]
Bug 40876: Apply 'exact' to all attributes when column filtering

If you select an option in a column filter, the "exact" behaviour will
only apply to the first attribute mapped to this column

eg. on the patron search we have "Libraries" mapped to library.name and
library.library_id. If you select Centerville/CPL, the generated q
parameter will be {name: CPL, id: {like: "%CPL%"}}

This is caused by:
    if (value.match(/^\^(.*)\$$/)) {
        value = value.replace(/^\^/, "").replace(/\$$/, "");
On the second parameter we have lost the ^$ markers

Moving it out of the loop fixes the problem (and does not impact the
other behaviours: we search the same value for all the attributes

Test plan:
Create a library with code=CPLL and use if for a patron
Go to http://localhost:8081/cgi-bin/koha/members/members-home.pl
Click search
Select "Centerville" in the "Libraries" column filter
=> Without this patch you get the patrons from CPL and CPLL
=> With this patch applied only patrons from CPL are listed
Comment 3 Lucas Gass (lukeg) 2025-09-25 15:45:03 UTC
Created attachment 186922 [details] [review]
Bug 40876: Apply 'exact' to all attributes when column filtering

If you select an option in a column filter, the "exact" behaviour will
only apply to the first attribute mapped to this column

eg. on the patron search we have "Libraries" mapped to library.name and
library.library_id. If you select Centerville/CPL, the generated q
parameter will be {name: CPL, id: {like: "%CPL%"}}

This is caused by:
    if (value.match(/^\^(.*)\$$/)) {
        value = value.replace(/^\^/, "").replace(/\$$/, "");
On the second parameter we have lost the ^$ markers

Moving it out of the loop fixes the problem (and does not impact the
other behaviours: we search the same value for all the attributes

Test plan:
Create a library with code=CPLL and use if for a patron
Go to http://localhost:8081/cgi-bin/koha/members/members-home.pl
Click search
Select "Centerville" in the "Libraries" column filter
=> Without this patch you get the patrons from CPL and CPLL
=> With this patch applied only patrons from CPL are listed

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Paul Derscheid 2025-09-25 16:17:27 UTC
Created attachment 186923 [details] [review]
Bug 40876: Apply 'exact' to all attributes when column filtering

If you select an option in a column filter, the "exact" behaviour will
only apply to the first attribute mapped to this column

eg. on the patron search we have "Libraries" mapped to library.name and
library.library_id. If you select Centerville/CPL, the generated q
parameter will be {name: CPL, id: {like: "%CPL%"}}

This is caused by:
    if (value.match(/^\^(.*)\$$/)) {
        value = value.replace(/^\^/, "").replace(/\$$/, "");
On the second parameter we have lost the ^$ markers

Moving it out of the loop fixes the problem (and does not impact the
other behaviours: we search the same value for all the attributes

Test plan:
Create a library with code=CPLL and use if for a patron
Go to http://localhost:8081/cgi-bin/koha/members/members-home.pl
Click search
Select "Centerville" in the "Libraries" column filter
=> Without this patch you get the patrons from CPL and CPLL
=> With this patch applied only patrons from CPL are listed

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 5 Lucas Gass (lukeg) 2025-09-25 17:08:47 UTC
Nice work all! 

Pushed to main for 25.11.00!
Comment 6 Paul Derscheid 2025-09-25 17:34:38 UTC
Nice work everyone!

Pushed to 25.05.x