Bug 38116 - Patrons search description should be built from DT's search settings
Summary: Patrons search description should be built from DT's search settings
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords: additional_work_needed
Depends on: 33484 38112
Blocks: 39288
  Show dependency treegraph
 
Reported: 2024-10-08 10:01 UTC by Jonathan Druart
Modified: 2025-03-10 13:49 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement improves the search description (or criteria) shown above the patrons page search results table. It now displays the additional search criteria entered in the global search filter and column filters, for example: Patrons found for: Anywhere: e Standard starting with 'a' Library=Franklin
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 38116: Build patron search descriptions using DT's search settings (13.16 KB, patch)
2024-10-09 12:13 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38116: Build patron search descriptions using DT's search settings (13.28 KB, patch)
2024-10-29 15:35 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38116: Build patron search descriptions using DT's search settings (13.33 KB, patch)
2024-12-17 01:54 UTC, David Nind
Details | Diff | Splinter Review
Bug 38116: Hide the description on 'Clear' (955 bytes, patch)
2024-12-17 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38116: Empty column filters (1.17 KB, patch)
2025-01-01 18:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Screenshot - Search description "magically" reappearing (57.63 KB, image/png)
2025-01-01 21:34 UTC, David Nind
Details
Bug 38116: Build patron search descriptions using DT's search settings (13.40 KB, patch)
2025-01-28 08:12 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38116: Hide the description on 'Clear' (1020 bytes, patch)
2025-01-28 08:12 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38116: Empty column filters (1.23 KB, patch)
2025-01-28 08:12 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38116: Build patron search descriptions using DT's search settings (14.55 KB, patch)
2025-02-12 14:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38116: Hide the description on 'Clear' (1.02 KB, patch)
2025-02-12 14:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38116: Empty column filters (1.26 KB, patch)
2025-02-12 14:36 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2024-10-08 10:01:00 UTC
We are building a description of the search on top of the patrons search table. But this is not accurate and does not reflect the exact search result that is displayed in the table. This is because column filters can used after we submitted the form (on the left).

We could try to build it using DT's search settings, and it would then even be possible to have it for all tables.
Comment 1 Jonathan Druart 2024-10-09 12:13:18 UTC
Created attachment 172569 [details] [review]
Bug 38116: Build patron search descriptions using DT's search settings

The goal of this patch is to move the construction of the patron search description
to datatables.js in order to make it generic and reusable.

With bug 33484 and the restoration of the state from localStorage or the
URL could lead to confusion when the table is displayed. It could also
be problematic when an hidden column has a search pattern.

Note that if a column has a dropdown list with an option selected AND is hidden,
the description won't display the value but the code (eg. ^CPL$ if
library Centerville is selected)
Comment 2 David Nind 2024-10-27 19:46:00 UTC
Could we get a test plan for this?

I'm not sure what has changed or what to look for.

Thanks!
Comment 3 Jonathan Druart 2024-10-28 10:12:09 UTC
Currently there is a description of the search displayed. It is adjusted when you use the filters on the left or when you click on the the "start with" letters that is on top of the table.

However it's not updated when a filter on the table is used (general search of column filters).

It can lead to confusion, especially with bug 33484 where you can use a link to restore specific state of a table.

A test plan would be:
Use the filter on the left
Use a "start with" letter
=> No change in behaviour
Use the global search filter and the column filters
=> They are appended to the description
Hide columns where you have filter
=> Still in the description. But notice a tiny problem if an option of a dropdown list is selected, code is displayed instead of description. Could be fixed I think, but on a separate bug.
Comment 4 Jonathan Druart 2024-10-29 15:35:43 UTC
Created attachment 173663 [details] [review]
Bug 38116: Build patron search descriptions using DT's search settings

The goal of this patch is to move the construction of the patron search description
to datatables.js in order to make it generic and reusable.

With bug 33484 and the restoration of the state from localStorage or the
URL could lead to confusion when the table is displayed. It could also
be problematic when an hidden column has a search pattern.

Note that if a column has a dropdown list with an option selected AND is hidden,
the description won't display the value but the code (eg. ^CPL$ if
library Centerville is selected)
Comment 5 David Nind 2024-12-17 01:54:48 UTC
Created attachment 175585 [details] [review]
Bug 38116: Build patron search descriptions using DT's search settings

The goal of this patch is to move the construction of the patron search description
to datatables.js in order to make it generic and reusable.

With bug 33484 and the restoration of the state from localStorage or the
URL could lead to confusion when the table is displayed. It could also
be problematic when an hidden column has a search pattern.

Note that if a column has a dropdown list with an option selected AND is hidden,
the description won't display the value but the code (eg. ^CPL$ if
library Centerville is selected)

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2024-12-17 02:17:31 UTC
I've signed off, as I finally figured out what was meant by "Search description".

However, one issue I noted is clearing the search.

If you use the "Clear" button in the left-hand sidebar, it doesn't clear the search description.

For example:
1. For the 'Search' field enter: a
2. For the 'Search type' field: Starts with
3. Click the 'Search' button
4. In the "Global search filter" field above the table: e
5. In the card column filter: 0000
6. The search description:
     Patrons found for: Anywhere: e
     Standard starting with 'a'
     Card=0000
7. Click "Clear" in the left-hand sidebar
8. The search description is still displayed on the page (as per step 6), with no search results.
9. To make the search description disappear, either start a new search or click the "Patrons" top menu item to reload the patrons page. 
10. If you just do a search using the search filters on the left-hand side (steps 1-3), the clear doesn't work for that either.


Testing notes (using KTD)
=========================

"search description" means and what is searched for, for example if you search for 'a', then above the table of search results the search criteria are shown "Patrons found for: Standard starting with 'a'".

The search filters (in the left sidebar)
----------------------------------------

Before the patch:

1. Filters on the left:
   1.1 For the 'Search' field enter: a
   1.2 For the 'Search type' field: Starts with
   1.3 Click 'Search'
   1.4 In the search results it says (under the 'Browse by last name'):
       "Patrons found for: Standard starting with 'a'"

After the patch, there should be no change:
"Patrons found for: Standard starting with 'a'"

Global search filter and column filters
---------------------------------------

- Global search filter = above the table column headings (Show XX entries First Previous X Next Last Search_____ x Clear filter)
- Column filters = in the search results table, under the table column headings

1. Enter e in the global search filter:
   1.1 Before the patch - no change to the search description:
       "Patrons found for: Standard starting with 'a'"
   1.2 After the patch - now shows in the search description:
       "Patrons found for: Anywhere: e
        Standard starting with 'a'"

2. In the column filter for the Card, enter 0000
   2.1 No change to the search description:
       Patrons found for: Standard starting with 'a'
   2.2 After the patch - now shows in the search description:
       "Patrons found for: Anywhere: e
        Standard starting with 'a'
        Card=0000"
   2.3 Note: If the card column is hidden, the results don't change and the "Card=0000" still shows in the search description
   2.4 Note: If a column filter has a dropdown list, the description is now displayed in the search description, for example:
        Patrons found for: Standard starting with 'a'
        Library=Midway, Category=Staff
Comment 7 Jonathan Druart 2024-12-17 10:08:10 UTC
Created attachment 175600 [details] [review]
Bug 38116: Hide the description on 'Clear'
Comment 8 Jonathan Druart 2024-12-17 10:08:20 UTC
(In reply to David Nind from comment #6)
> I've signed off, as I finally figured out what was meant by "Search
> description".
> 
> However, one issue I noted is clearing the search.
> 
> If you use the "Clear" button in the left-hand sidebar, it doesn't clear the
> search description.
> 
> For example:
> 1. For the 'Search' field enter: a
> 2. For the 'Search type' field: Starts with
> 3. Click the 'Search' button
> 4. In the "Global search filter" field above the table: e
> 5. In the card column filter: 0000
> 6. The search description:
>      Patrons found for: Anywhere: e
>      Standard starting with 'a'
>      Card=0000
> 7. Click "Clear" in the left-hand sidebar
> 8. The search description is still displayed on the page (as per step 6),
> with no search results.
> 9. To make the search description disappear, either start a new search or
> click the "Patrons" top menu item to reload the patrons page. 
> 10. If you just do a search using the search filters on the left-hand side
> (steps 1-3), the clear doesn't work for that either.

Definitely a regression, fixed with the last patch. Thanks!
Comment 9 David Nind 2024-12-17 20:06:38 UTC
(In reply to Jonathan Druart from comment #8)

> Definitely a regression, fixed with the last patch. Thanks!

Thanks Jonathan!

I retested - I had to click "Clear" twice to fully clear the search description, even then it didn't clear the column filter.
- Search box: a
- Click "Search"
- Table filter: e
- Card column filter: 0000
- Search description:
   Patrons found for: Anywhere: e
   Standard starting with 'a'
   Card=0000
- Click "Clear" - no search description
- Do another search, say: p
- Card column still has the 0000 filter, even though it is not using it
Comment 10 Jonathan Druart 2025-01-01 18:28:07 UTC
Created attachment 176043 [details] [review]
Bug 38116: Empty column filters
Comment 11 Jonathan Druart 2025-01-01 18:28:17 UTC
(In reply to David Nind from comment #9)
> (In reply to Jonathan Druart from comment #8)
> 
> > Definitely a regression, fixed with the last patch. Thanks!
> 
> Thanks Jonathan!
> 
> I retested - I had to click "Clear" twice to fully clear the search
> description, even then it didn't clear the column filter.
> - Search box: a
> - Click "Search"
> - Table filter: e
> - Card column filter: 0000
> - Search description:
>    Patrons found for: Anywhere: e
>    Standard starting with 'a'
>    Card=0000
> - Click "Clear" - no search description
> - Do another search, say: p
> - Card column still has the 0000 filter, even though it is not using it

Good catch, thanks!
What you describe is fixed in the last patch. I don't need to click twice on the "Clear" button however. Let me know if you find something else!
Comment 12 David Nind 2025-01-01 19:29:50 UTC
(In reply to Jonathan Druart from comment #11)
> (In reply to David Nind from comment #9)
> > (In reply to Jonathan Druart from comment #8)
> > 
> > > Definitely a regression, fixed with the last patch. Thanks!
> > 
> > Thanks Jonathan!
> > 
> > I retested - I had to click "Clear" twice to fully clear the search
> > description, even then it didn't clear the column filter.
> > - Search box: a
> > - Click "Search"
> > - Table filter: e
> > - Card column filter: 0000
> > - Search description:
> >    Patrons found for: Anywhere: e
> >    Standard starting with 'a'
> >    Card=0000
> > - Click "Clear" - no search description
> > - Do another search, say: p
> > - Card column still has the 0000 filter, even though it is not using it
> 
> Good catch, thanks!
> What you describe is fixed in the last patch. I don't need to click twice on
> the "Clear" button however. Let me know if you find something else!

Thanks Jonathan!

I retested, and that fixes the column filter.

However, now, if you click "Clear" the search description clears, but if you wait a moment, the search description is displayed again:
  Patrons found for: Anywhere: e
  Card=0000

If you then search again, say 'p', then you get the right results and the search description changes (as expected) to: 
  Patrons found for: Standard starting with 'p'
(The results are correct as well.)
Comment 13 Jonathan Druart 2025-01-01 19:51:47 UTC
(In reply to David Nind from comment #12)
> However, now, if you click "Clear" the search description clears, but if you
> wait a moment, the search description is displayed again:
>   Patrons found for: Anywhere: e
>   Card=0000

"Wait a moment"? What do you mean?

You click "Clear", the description is hidden, as well as the table, then?
You wait like... 10 seconds doing nothing and the description appears, without the table? Like... black magic? :)

Can you provide the detailed steps please?
Comment 14 David Nind 2025-01-01 21:34:17 UTC
Created attachment 176051 [details]
Screenshot - Search description "magically" reappearing

(In reply to Jonathan Druart from comment #13)
> (In reply to David Nind from comment #12)

> "Wait a moment"? What do you mean?
> 
> You click "Clear", the description is hidden, as well as the table, then?
> You wait like... 10 seconds doing nothing and the description appears,
> without the table? Like... black magic? :)
> 
> Can you provide the detailed steps please?

By "Wait a moment" I mean:
1. Don't do anything for a few seconds after clicking "Clear". 
2. After clicking "Clear" I left the mouse hovering above the clear button.
3. Then the search description "magically" reappears (almost instantly):
     Patrons found for: Anywhere: e
     Card=0000

I've attached a screenshot.

I used both Chromium and Firefox, with cleared browser caches.

No errors or anything is displayed in the web developer tools console.

Here are the steps to reproduce:
1. Apply the patches.
2. Go to Patrons in the staff interface.
3. In the "Search for patron" in the left sidebar:
   - Search box: a
   - Click "Search"
   --> Search description is:
         Patrons found for: Standard starting with 'a'
4. For the table filter (Search:_____ x Clear filter): e
   --> Search description is:
         Patrons found for: Anywhere: e
         Standard starting with 'a'
5. For the column filters - Card column: 0000
   --> Search description is:
         Patrons found for: Anywhere: e
         Standard starting with 'a'
         Card=0000
6. Click "Clear"
   --> There is no text displayed for the search description
7. Leave your mouse hovering above the "Clear" button.
8. Almost immediately, the search description "magically" reappears under the "Browse by last name: A B C...:
     Patrons found for: Anywhere: e
     Card=0000
9. Do another search, say: p
   --> Correct results returned
   --> Search description (as expected):
         Patrons found for: Standard starting with 'p'
Comment 15 Jonathan Druart 2025-01-02 15:27:57 UTC
(In reply to David Nind from comment #14)
> Created attachment 176051 [details]
> Screenshot - Search description "magically" reappearing
> 
> (In reply to Jonathan Druart from comment #13)
> > (In reply to David Nind from comment #12)
> 
> > "Wait a moment"? What do you mean?
> > 
> > You click "Clear", the description is hidden, as well as the table, then?
> > You wait like... 10 seconds doing nothing and the description appears,
> > without the table? Like... black magic? :)
> > 
> > Can you provide the detailed steps please?
> 
> By "Wait a moment" I mean:
> 1. Don't do anything for a few seconds after clicking "Clear". 
> 2. After clicking "Clear" I left the mouse hovering above the clear button.
> 3. Then the search description "magically" reappears (almost instantly):
>      Patrons found for: Anywhere: e
>      Card=0000
> 
> I've attached a screenshot.

Can you try on a sandbox please? I don't recreate this problem.

https://staff-bug38116.sandboxes.biblibre.eu/cgi-bin/koha/members/members-home.pl
Comment 16 David Nind 2025-01-02 18:35:40 UTC
(In reply to Jonathan Druart from comment #15)
> 
> Can you try on a sandbox please? I don't recreate this problem.
> 
> https://staff-bug38116.sandboxes.biblibre.eu/cgi-bin/koha/members/members-
> home.pl

Thanks Jonathan.

I created a quick video (not the greatest quality) that demonstrates the issue - I attached to a direct message on chat.

David
Comment 17 Jonathan Druart 2025-01-06 09:47:47 UTC
Thanks, it was very helpful.

It happens because a search a triggered when the column filter lose the focus.
I didn't recreate it as I was clicking outside of the filter before hitting the "Clear" button.

I think it's a separate problem, I have opened bug 38827.
Comment 18 David Nind 2025-01-08 10:32:40 UTC
(In reply to Jonathan Druart from comment #17)
> Thanks, it was very helpful.
> 
> It happens because a search a triggered when the column filter lose the
> focus.
> I didn't recreate it as I was clicking outside of the filter before hitting
> the "Clear" button.
> 
> I think it's a separate problem, I have opened bug 38827.

Thanks Jonathan!

I can confirm that after applying the patch for 38827, that this no longer happens.

David
Comment 19 Martin Renvoize (ashimema) 2025-01-28 08:12:16 UTC
Created attachment 177211 [details] [review]
Bug 38116: Build patron search descriptions using DT's search settings

The goal of this patch is to move the construction of the patron search description
to datatables.js in order to make it generic and reusable.

With bug 33484 and the restoration of the state from localStorage or the
URL could lead to confusion when the table is displayed. It could also
be problematic when an hidden column has a search pattern.

Note that if a column has a dropdown list with an option selected AND is hidden,
the description won't display the value but the code (eg. ^CPL$ if
library Centerville is selected)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 20 Martin Renvoize (ashimema) 2025-01-28 08:12:19 UTC
Created attachment 177212 [details] [review]
Bug 38116: Hide the description on 'Clear'

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Martin Renvoize (ashimema) 2025-01-28 08:12:22 UTC
Created attachment 177213 [details] [review]
Bug 38116: Empty column filters

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 22 Jonathan Druart 2025-02-12 14:36:39 UTC
Created attachment 177920 [details] [review]
Bug 38116: Build patron search descriptions using DT's search settings

The goal of this patch is to move the construction of the patron search description
to datatables.js in order to make it generic and reusable.

With bug 33484 and the restoration of the state from localStorage or the
URL could lead to confusion when the table is displayed. It could also
be problematic when an hidden column has a search pattern.

Note that if a column has a dropdown list with an option selected AND is hidden,
the description won't display the value but the code (eg. ^CPL$ if
library Centerville is selected)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 23 Jonathan Druart 2025-02-12 14:36:42 UTC
Created attachment 177921 [details] [review]
Bug 38116: Hide the description on 'Clear'

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Jonathan Druart 2025-02-12 14:36:45 UTC
Created attachment 177922 [details] [review]
Bug 38116: Empty column filters

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 25 Katrin Fischer 2025-02-20 16:19:29 UTC
I am not going to block this, but I feel the display could be a little nicer for the additional search criteria. Also not sure about capitalization here and itching to change the upper cases...

Patrons found for: Card number starting with 't'
Library=Riverside, Category=School

What do you think?
Comment 26 Katrin Fischer 2025-02-20 16:42:28 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 27 Jonathan Druart 2025-03-10 13:45:23 UTC
(In reply to Katrin Fischer from comment #25)
> I am not going to block this, but I feel the display could be a little nicer
> for the additional search criteria. Also not sure about capitalization here
> and itching to change the upper cases...
> 
> Patrons found for: Card number starting with 't'
> Library=Riverside, Category=School
> 
> What do you think?

I have opened bug 39288.