Bug 36454 - Provide indication if a patron is expired or restricted on patron search autocomplete
Summary: Provide indication if a patron is expired or restricted on patron search auto...
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Pedro Amorim
QA Contact: Lucas Gass (lukeg)
URL:
Keywords:
Depends on:
Blocks: 38465 38254 38478
  Show dependency treegraph
 
Reported: 2024-03-28 13:19 UTC by Pedro Amorim
Modified: 2024-11-18 21:44 UTC (History)
12 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement adds "Expired" or "Restricted" information badges to patron autocomplete search suggestions, where these criteria apply.
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 36454: Add 'expired' information on patron auto complete results (1.80 KB, patch)
2024-09-16 08:54 UTC, Pedro Amorim
Details | Diff | Splinter Review
Add restricted status too? (116.66 KB, image/png)
2024-09-17 15:40 UTC, Owen Leonard
Details
Bug 36454: Add 'expired' information on patron auto complete results (1.86 KB, patch)
2024-09-17 15:47 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 36454: (follow-up) Tweak CSS and add restricted status output (3.50 KB, patch)
2024-09-17 15:47 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 36454: (follow-up) Tweak CSS and add restricted status output (3.56 KB, patch)
2024-09-17 16:30 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36454: Add 'expired' information on patron auto complete results (1.91 KB, patch)
2024-09-20 17:13 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36454: (follow-up) Tweak CSS and add restricted status output (3.61 KB, patch)
2024-09-20 17:13 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36454: (QA follow-up) Use native is_expired instead of redundant JS calculation (2.76 KB, patch)
2024-11-18 09:31 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36454: (QA follow-up): Selenium - Add regression tests (3.89 KB, patch)
2024-11-18 12:38 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36454: (QA follow-up) Use native is_expired instead of redundant JS calculation (2.83 KB, patch)
2024-11-18 13:17 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36454: (QA follow-up): Selenium - Add regression tests (3.97 KB, patch)
2024-11-18 13:17 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36454: Fix and add API tests (4.63 KB, patch)
2024-11-18 13:17 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36454: Selenium - test patrons must start with 'test_' (3.92 KB, patch)
2024-11-18 13:17 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 Pedro Amorim 2024-03-28 13:19:02 UTC
Creating an ILL request, when staff adds a patron, there is no indication that the patron is expired, if said patron is indeed expired.
Part of the problem tackling this, I believe, is that the 'create form' is ILL backend specific, so this should be tackled at each ILL backend level.

Having said that, with bug 35570 in the pipeline, we could perhaps consider adding this little enhancement as a follow-up to that.
Comment 1 Pedro Amorim 2024-09-16 08:54:59 UTC
Created attachment 171516 [details] [review]
Bug 36454: Add 'expired' information on patron auto complete results

Test plan:
1) Alter the 'Expiry date' of any patron.
2) Search for that patron on any search input that provides auto complete results (e.g. top 'Search patrons' input)
3) Notice the expired patron has a 'expired' indication. Those who aren't do not.
Comment 2 Pedro Amorim 2024-09-16 08:56:42 UTC
Widening the scope here to provide 'expired' information on the patron search results including, but not limited to, when placing an ILL request.
Do others agree with this?
Comment 3 Owen Leonard 2024-09-17 15:40:33 UTC
Created attachment 171630 [details]
Add restricted status too?
Comment 4 Owen Leonard 2024-09-17 15:47:14 UTC
Created attachment 171631 [details] [review]
Bug 36454: Add 'expired' information on patron auto complete results

Test plan:
1) Alter the 'Expiry date' of any patron.
2) Search for that patron on any search input that provides auto
   complete results (e.g. top 'Search patrons' input)
3) Notice the expired patron has a 'expired' indication. Those who
   aren't do not.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Owen Leonard 2024-09-17 15:47:16 UTC
Created attachment 171632 [details] [review]
Bug 36454: (follow-up) Tweak CSS and add restricted status output

This patch makes some tweaks to the style of the new information: We can
use the Bootstrap 5 "badge" class and "warning" style to get the
appearance we want.

This patch also adds output of the patron's restricted status if
present.

To test, apply the patch and rebuild the staff interface CSS. Perform a
patron search (from the checkout header search form for instance) and
confirm that a "restricted" badge appears alongside the branch and
expired badge.
Comment 6 Pedro Amorim 2024-09-17 16:30:31 UTC
Created attachment 171633 [details] [review]
Bug 36454: (follow-up) Tweak CSS and add restricted status output

This patch makes some tweaks to the style of the new information: We can
use the Bootstrap 5 "badge" class and "warning" style to get the
appearance we want.

This patch also adds output of the patron's restricted status if
present.

To test, apply the patch and rebuild the staff interface CSS. Perform a
patron search (from the checkout header search form for instance) and
confirm that a "restricted" badge appears alongside the branch and
expired badge.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 7 Lucas Gass (lukeg) 2024-09-20 17:13:56 UTC
Created attachment 171839 [details] [review]
Bug 36454: Add 'expired' information on patron auto complete results

Test plan:
1) Alter the 'Expiry date' of any patron.
2) Search for that patron on any search input that provides auto
   complete results (e.g. top 'Search patrons' input)
3) Notice the expired patron has a 'expired' indication. Those who
   aren't do not.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Lucas Gass (lukeg) 2024-09-20 17:13:59 UTC
Created attachment 171840 [details] [review]
Bug 36454: (follow-up) Tweak CSS and add restricted status output

This patch makes some tweaks to the style of the new information: We can
use the Bootstrap 5 "badge" class and "warning" style to get the
appearance we want.

This patch also adds output of the patron's restricted status if
present.

To test, apply the patch and rebuild the staff interface CSS. Perform a
patron search (from the checkout header search form for instance) and
confirm that a "restricted" badge appears alongside the branch and
expired badge.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 9 Katrin Fischer 2024-10-21 10:27:08 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 10 Katrin Fischer 2024-10-21 11:12:31 UTC
Nice idea! 

I wonder if we could think of a way to display this information in patron search as well. For example we could turn the expiration date red if it was in the past. As color alone is not accessible, another visible indicator like an icon might be needed.
Comment 11 Pedro Amorim 2024-10-21 11:38:12 UTC
(In reply to Katrin Fischer from comment #10)
> Nice idea! 
> 
> I wonder if we could think of a way to display this information in patron
> search as well. For example we could turn the expiration date red if it was
> in the past. As color alone is not accessible, another visible indicator
> like an icon might be needed.

The patrons table list results, correct? I think that's a nice idea, we should log a bug to spark discussion / verify interest.
Comment 12 Katrin Fischer 2024-10-21 11:48:07 UTC
(In reply to Pedro Amorim from comment #11)
> (In reply to Katrin Fischer from comment #10)
> > Nice idea! 
> > 
> > I wonder if we could think of a way to display this information in patron
> > search as well. For example we could turn the expiration date red if it was
> > in the past. As color alone is not accessible, another visible indicator
> > like an icon might be needed.
> 
> The patrons table list results, correct? I think that's a nice idea, we
> should log a bug to spark discussion / verify interest.

Yep. Just hard to keep track of all lose ends so wanted to store in a comment at least.
Comment 13 Jonathan Druart 2024-11-18 08:24:08 UTC
This patch breaks curbside pickup, please have a look at bug 38465.
Comment 14 Jonathan Druart 2024-11-18 08:34:22 UTC
A couple of remarks/questions:

1. If we have a Koha::Object's method to calculate the "is expired" status, we should not have a JS counter part (at least in this situation). What if the calculation change?

2. Date.parse($date_to_rfc3339($date(new_date.toString())));
This sounds way too complicated, why is that needed?
Comment 15 Jonathan Druart 2024-11-18 08:41:04 UTC
(In reply to Jonathan Druart from comment #13)
> This patch breaks curbside pickup, please have a look at bug 38465.

Added a patch there.
Comment 16 Jonathan Druart 2024-11-18 08:54:14 UTC
(In reply to Jonathan Druart from comment #14)
> A couple of remarks/questions:
> 
> 1. If we have a Koha::Object's method to calculate the "is expired" status,
> we should not have a JS counter part (at least in this situation). What if
> the calculation change?
> 
> 2. Date.parse($date_to_rfc3339($date(new_date.toString())));
> This sounds way too complicated, why is that needed?

3. From Koha::Patron->is_expired:897     return 0 unless $self->dateexpiry;
This is not taken into account in the JS code. What happens if dateexpiry is NULL in DB?
Comment 17 Katrin Fischer 2024-11-18 09:26:25 UTC
(In reply to Jonathan Druart from comment #16)
> (In reply to Jonathan Druart from comment #14)
> > A couple of remarks/questions:
> > 
> > 1. If we have a Koha::Object's method to calculate the "is expired" status,
> > we should not have a JS counter part (at least in this situation). What if
> > the calculation change?
> > 
> > 2. Date.parse($date_to_rfc3339($date(new_date.toString())));
> > This sounds way too complicated, why is that needed?
> 
> 3. From Koha::Patron->is_expired:897     return 0 unless $self->dateexpiry;
> This is not taken into account in the JS code. What happens if dateexpiry is
> NULL in DB?

The search breaks, see bug 38254
Comment 18 Pedro Amorim 2024-11-18 09:31:15 UTC
Created attachment 174671 [details] [review]
Bug 36454: (QA follow-up) Use native is_expired instead of redundant JS calculation

Test plan:
1) $ yarn api:bundle
2) $ koha-plack --restart kohadev
3) Make a patron expired, search for them. Verify the 'expired' badge still shows
Comment 19 Pedro Amorim 2024-11-18 09:32:00 UTC
(In reply to Jonathan Druart from comment #16)

I agree with everything you said. Code was not great. I've submitted a follow-up.
Comment 20 Pedro Amorim 2024-11-18 12:38:09 UTC
Created attachment 174682 [details] [review]
Bug 36454: (QA follow-up): Selenium - Add regression tests

Test plan:
1) $ ktd --selenium up
2) prove t/db_dependent/selenium/patrons_search_badges.t

Ensure these tests pass before and after the previous 'Use native is_expired instead of redundant JS calculation' patch.
Comment 21 Jonathan Druart 2024-11-18 13:17:10 UTC
Created attachment 174684 [details] [review]
Bug 36454: (QA follow-up) Use native is_expired instead of redundant JS calculation

Test plan:
1) $ yarn api:bundle
2) $ koha-plack --restart kohadev
3) Make a patron expired, search for them. Verify the 'expired' badge still shows

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 22 Jonathan Druart 2024-11-18 13:17:13 UTC
Created attachment 174685 [details] [review]
Bug 36454: (QA follow-up): Selenium - Add regression tests

Test plan:
1) $ ktd --selenium up
2) prove t/db_dependent/selenium/patrons_search_badges.t

Ensure these tests pass before and after the previous 'Use native is_expired instead of redundant JS calculation' patch.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 23 Jonathan Druart 2024-11-18 13:17:17 UTC
Created attachment 174686 [details] [review]
Bug 36454: Fix and add API tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 24 Jonathan Druart 2024-11-18 13:17:20 UTC
Created attachment 174687 [details] [review]
Bug 36454: Selenium - test patrons must start with 'test_'

I usually
 > delete from borrowers where surname like "test_"
So I do not need to reset_all

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 25 Jonathan Druart 2024-11-18 13:19:57 UTC
I think "is_expired" would have been better than "expired". But we already have "restricted", so better to keep the consistency I guess... Could adjust both later if needed.
Comment 26 Katrin Fischer 2024-11-18 15:09:24 UTC
Picked 4 follow-up patches starting with "Use native is_expired..." for push to main.
Comment 27 Katrin Fischer 2024-11-18 16:08:29 UTC
Pushed for 24.11!

Well done everyone, thank you!