Bug 39473

Summary: Drop-down filters on item holdings table should match codes exactly
Product: Koha Reporter: Emily Lamancusa (emlam) <emily.lamancusa>
Component: TemplatesAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to main --- QA Contact: Lucas Gass (lukeg) <lucas>
Severity: normal    
Priority: P5 - low CC: david, jonathan.druart, lucas, pedro.amorim
Version: MainKeywords: rel_24_11_candidate
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
This fixes the dropdown filters for the holdings table in the staff interface. The filters now use an exact match. Example: Items with an item type of BK (Books) and BKA (Other type of book) would both be shown if either was selected in the dropdown list, instead of just the items for the specific item type.
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on: 33568    
Bug Blocks: 40118    
Attachments: Bug 39473: Add Cypress tests
Bug 39473: Use exact search for column filtering with dropdown
Bug 39473: Add Cypress tests
Bug 39473: Use exact search for column filtering with dropdown
Bug 39473: Add Cypress tests
Bug 39473: Use exact search for column filtering with dropdown
Bug 39473: Add Cypress tests

Description Emily Lamancusa (emlam) 2025-03-27 16:15:30 UTC
To reproduce:
0. If not using default KTD data, create an item type with the following settings:
   Item type: BK
   Description: Books
   leave all other values on their defaults

1. Create a new item type with the following settings:
   Item type: BKA
   Description: Other type of book
   leave all other values on their defaults

2. Add or edit items on a bib record so that the record has at least one item of type "Books" and at least one item of type "Another type of book"

3. Go to Normal View for that bib record

4. Click "Show filters" above the item holdings table

5. In the Item type column, filter by "Books"
--> Both "Books" and "Another type of book" items show in the table
--> The drop-down is set to "Other type of book", even though you selected "Books"

The table and drop-down appear matching on item type codes that contain the string "BK", rather than matching on the exact string. I was able to reproduce the bug with branchcodes as well.
Comment 1 Jonathan Druart 2025-04-22 12:44:09 UTC
Created attachment 181258 [details] [review]
Bug 39473: Add Cypress tests
Comment 2 Jonathan Druart 2025-04-22 12:44:12 UTC
Created attachment 181259 [details] [review]
Bug 39473: Use exact search for column filtering with dropdown

We need to use an exact search when using the id of an option.

Test plan:
0. If not using default KTD data, create an item type with the following settings:
   Item type: BK
   Description: Books
   leave all other values on their defaults

1. Create a new item type with the following settings:
   Item type: BKA
   Description: Other type of book
   leave all other values on their defaults

2. Add or edit items on a bib record so that the record has at least one item of type "Books" and at least one item of type "Another type of book"

3. Go to Normal View for that bib record

4. Click "Show filters" above the item holdings table

5. In the Item type column, filter by "Books"
Only "Books" items show in the table
Comment 3 Jonathan Druart 2025-04-22 14:08:12 UTC
Created attachment 181268 [details] [review]
Bug 39473: Add Cypress tests
Comment 4 Jonathan Druart 2025-04-22 14:08:58 UTC
(In reply to Jonathan Druart from comment #3)
> Created attachment 181268 [details] [review] [review]
> Bug 39473: Add Cypress tests

This is not really nice code but I failed to make it pretty.
Comment 5 David Nind 2025-04-26 20:03:47 UTC
Created attachment 181570 [details] [review]
Bug 39473: Use exact search for column filtering with dropdown

We need to use an exact search when using the id of an option.

Test plan:
0. If not using default KTD data, create an item type with the following settings:
   Item type: BK
   Description: Books
   leave all other values on their defaults

1. Create a new item type with the following settings:
   Item type: BKA
   Description: Other type of book
   leave all other values on their defaults

2. Add or edit items on a bib record so that the record has at least one item of type "Books" and at least one item of type "Another type of book"

3. Go to Normal View for that bib record

4. Click "Show filters" above the item holdings table

5. In the Item type column, filter by "Books"
Only "Books" items show in the table

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2025-04-26 20:03:50 UTC
Created attachment 181571 [details] [review]
Bug 39473: Add Cypress tests

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2025-04-26 20:18:05 UTC
Testing notes (using KTD)
1. Tests pass before and after the patch:
   yarn cypress run --spec t/cypress/integration/KohaTable/Holdings_spec.ts
Comment 8 Lucas Gass (lukeg) 2025-05-08 19:28:39 UTC
Created attachment 182109 [details] [review]
Bug 39473: Use exact search for column filtering with dropdown

We need to use an exact search when using the id of an option.

Test plan:
0. If not using default KTD data, create an item type with the following settings:
   Item type: BK
   Description: Books
   leave all other values on their defaults

1. Create a new item type with the following settings:
   Item type: BKA
   Description: Other type of book
   leave all other values on their defaults

2. Add or edit items on a bib record so that the record has at least one item of type "Books" and at least one item of type "Another type of book"

3. Go to Normal View for that bib record

4. Click "Show filters" above the item holdings table

5. In the Item type column, filter by "Books"
Only "Books" items show in the table

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 9 Lucas Gass (lukeg) 2025-05-08 19:28:41 UTC
Created attachment 182110 [details] [review]
Bug 39473: Add Cypress tests

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 10 Katrin Fischer 2025-05-09 07:14:11 UTC
Pushed for 25.05!

Well done everyone, thank you!