Bug 38412

Summary: Koha should warn when hold on bibliographic record requires hold policy override
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: Hold requestsAssignee: Thibaud Guillot (thibaud_g) <thibaud.guillot>
Status: Pushed to main --- QA Contact: Nick Clemens (kidclamp) <nick>
Severity: normal    
Priority: P5 - low CC: Chip.Halvorsen, cj.lynce, david, emily.lamancusa, gmcharlt, kebliss, lisette, lucas, mteal
Version: MainKeywords: rel_25_05_candidate
Hardware: All   
OS: All   
GIT URL: Change sponsored?: Sponsored
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:
Bug Depends on: 35573    
Bug Blocks:    
Attachments: Bug 38412: Display warning on biblio level
Bug 38412: Display warning on biblio level
Bug 38412: Display warning on biblio level
Bug 38412: Display warning on biblio level
Bug 38412: Display warning on biblio level

Description Andrew Fuerste-Henry 2024-11-08 18:18:03 UTC
When AllowHoldPolicyOverride is set to Allow, Koha will specifically mark items for which an item-level hold will require an override. However, nothing in the interface indicates when the bibliographic level hold will require an override. 

To recreate:
 - Have AllowHoldPolicyOverride set to Don't Allow
 - Have a bib record with just one item
 - confirm you can place a hold on either the biblio or the item
 - edit your item such that it become unholdable (mark it Not For Loan or something)
 - confirm that you cannot place a hold on either the biblio or the item
 - set AllowHoldPolicyOverride to Allow
 - confirm that Koha shows an alert on the item indicating that the hold will require an override
 - confirm that Koha does not indicate the bibliographic level hold will require an override

Bug 33573 restored these alerts for items. I don't recall if we've ever had these alerts for biblios.
Comment 1 Thibaud Guillot (thibaud_g) 2025-05-14 14:10:45 UTC
Created attachment 182450 [details] [review]
Bug 38412: Display warning on biblio level

When no element is available, with AllowHoldPolicyOverride, a triangle appears on each element to be forced, but if you choose “next item available” without having any item available, you won't see anything.
I think there's a small correction to be made in request.pl because there's no incrementation of $num_override when the item is to be forced...

So I added it and logic did the rest.

Test plan:
1) Set circulations rules for specific category and/or itemtype (for example 0 hold allowed for staff on books). Set AllowHoldPolicyOverride on "Allow".
2) For testing go on biblio with books itemtype, and place a hold for a staff category patron
3) Normally you will see triangles on each item on specific section but you can force it. When you just select the next item available none triangle and none alert showing.
4) Apply this patch and restart_all
5) Refresh your browser page
6) Normally now there is a triangle into 'Place hold' submit button and an alert pops up after click on it.

Sponsored by: BibLibre
Comment 2 David Nind 2025-05-22 22:57:32 UTC
Added assignee.
Comment 3 Andrew Fuerste-Henry 2025-05-23 12:41:11 UTC
Created attachment 182767 [details] [review]
Bug 38412: Display warning on biblio level

When no element is available, with AllowHoldPolicyOverride, a triangle appears on each element to be forced, but if you choose “next item available” without having any item available, you won't see anything.
I think there's a small correction to be made in request.pl because there's no incrementation of $num_override when the item is to be forced...

So I added it and logic did the rest.

Test plan:
1) Set circulations rules for specific category and/or itemtype (for example 0 hold allowed for staff on books). Set AllowHoldPolicyOverride on "Allow".
2) For testing go on biblio with books itemtype, and place a hold for a staff category patron
3) Normally you will see triangles on each item on specific section but you can force it. When you just select the next item available none triangle and none alert showing.
4) Apply this patch and restart_all
5) Refresh your browser page
6) Normally now there is a triangle into 'Place hold' submit button and an alert pops up after click on it.

Sponsored by: BibLibre

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 4 Andrew Fuerste-Henry 2025-05-23 12:42:48 UTC
The new little triangle alert icon might be more visible if it were next to the button rather than within it, since it's a yellow icon and an orange button. But that's a minor quibble with a nice improvement. thanks!
Comment 5 Lisette Scheer 2025-07-07 20:10:33 UTC
*** Bug 40323 has been marked as a duplicate of this bug. ***
Comment 6 Lisette Scheer 2025-07-07 20:11:36 UTC
(In reply to Andrew Fuerste-Henry from comment #4)
> The new little triangle alert icon might be more visible if it were next to
> the button rather than within it, since it's a yellow icon and an orange
> button. But that's a minor quibble with a nice improvement. thanks!

I agree that it's not very visible and easy to miss.
Comment 7 CJ Lynce 2025-07-07 20:38:24 UTC
Good step towards resolving this. I too agree that the current triangle on the button is hard to see, and not accessible. Next to the button would make it more visible (though even then I'm unsure if its accessible enough.)

Additionally, it should display the same warning message at the top that displays when AllowHoldPolicyOverride is set to 'Dont Allow'.

  *Cannot place hold*
  No items are available to be placed on hold.

This is similar in behavior to what happens when you try to place too many holds on a bib (more than circ rules allow) and AllowHoldPolicyOverride is set to Allow.  

Having the warning display with AllowHoldPolicyOverride set to Allow also explains the issue to staff, who hopefully read it before proceeding to override the hold. And it probably increases overall accessibility (with the warning icon.)
Comment 8 CJ Lynce 2025-07-11 20:05:36 UTC
Created attachment 184021 [details] [review]
Bug 38412: Display warning on biblio level

When no item is available, with AllowHoldPolicyOverride, a triangle appears on
    each item to be forced, but if you choose “next item available” without
    having  any item available, you won't see anything. Additionally, the top
    warning message about "No items are available" does not show when
    'AllowHoldPolicyOverride' is set to allow and no items are available
    (e.g. withdrawn, lost, damanged, depending on settings)

This patch corrects an error in request.pl where no incrementation of
    $num_override happens when an item is forced. This causes the warning
    triangle to appear on the 'Place hold' button on the bib level. The top
    warning message is restored as well.

 Finally, this patch changes the display of the fa-warning-triangle icon on the
    'Place hold' buttons to increase contrast with the button color, making it
    easier to see and increasing accessibility.

Test plan:
1) Set circulations rules for specific category and/or itemtype (for example 1
    hold allowed for staff on books). Set AllowHoldPolicyOverride on "Allow".
2) Search for a book biblio with multiple items, and set each item to a
    non-circulating status (withdrawn, lost, etc.)
3) Place a hold for a staff category patron for this bib record.
4) Normally you will see triangles on each item on specific section but you can
    force it. When you just select the next item available none triangle and
    none alert showing.
5) Apply this patch and restart_all.
6) Refresh your browser page.
7) Normally now there is a triangle into 'Place hold' submit button and an
    alert message appears on the top of the page. The triangle is also more
    visible.
8) Test other hold limits, such as max holds per record, to ensure the
    appropriate top alert message appears and the triangle alert appears on
    the 'Place hold' button.

Co-authored-by: Thibaud Guillot <thibaud.guillot@biblibre.com>
Sponsored-by: BibLibre
Sponsored-by: Westlake Porter Public Library <https://westlakelibrary.org>
Comment 9 CJ Lynce 2025-07-11 20:08:26 UTC
Submitted a patch that builds up Thibaud's work, adds back the top warning message with explanation, and helps the contrast with the triangle warning on the buttons. 

I'm not entirely sure if this is the right way to submit a patch that adds on to someone else's in the same bug, so if not, I welcome feedback on how do this in the future. Thx!
Comment 10 Emily Lamancusa (emlam) 2025-07-23 15:34:07 UTC
Created attachment 184564 [details] [review]
Bug 38412: Display warning on biblio level

When no item is available, with AllowHoldPolicyOverride, a triangle appears on
    each item to be forced, but if you choose “next item available” without
    having  any item available, you won't see anything. Additionally, the top
    warning message about "No items are available" does not show when
    'AllowHoldPolicyOverride' is set to allow and no items are available
    (e.g. withdrawn, lost, damanged, depending on settings)

This patch corrects an error in request.pl where no incrementation of
    $num_override happens when an item is forced. This causes the warning
    triangle to appear on the 'Place hold' button on the bib level. The top
    warning message is restored as well.

 Finally, this patch changes the display of the fa-warning-triangle icon on the
    'Place hold' buttons to increase contrast with the button color, making it
    easier to see and increasing accessibility.

Test plan:
1) Set circulations rules for specific category and/or itemtype (for example 1
    hold allowed for staff on books). Set AllowHoldPolicyOverride on "Allow".
2) Search for a book biblio with multiple items, and set each item to a
    non-circulating status (withdrawn, lost, etc.)
3) Place a hold for a staff category patron for this bib record.
4) Normally you will see triangles on each item on specific section but you can
    force it. When you just select the next item available none triangle and
    none alert showing.
5) Apply this patch and restart_all.
6) Refresh your browser page.
7) Normally now there is a triangle into 'Place hold' submit button and an
    alert message appears on the top of the page. The triangle is also more
    visible.
8) Test other hold limits, such as max holds per record, to ensure the
    appropriate top alert message appears and the triangle alert appears on
    the 'Place hold' button.

Co-authored-by: Thibaud Guillot <thibaud.guillot@biblibre.com>
Sponsored-by: BibLibre
Sponsored-by: Westlake Porter Public Library <https://westlakelibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 11 Emily Lamancusa (emlam) 2025-07-23 15:44:32 UTC
The UI improvements look great, and this is a small but much-needed bugfix!

To answer your question about building upon someone else's work, usually we submit a separate patch on top of the existing patch(es), rather than amending the original patch. I don't think we need to go back and redo the commits on this one (unless Thibaud or the RM feel otherwise) since it's not a big patch and the coauthor line gives credit, but that's the usual convention for future reference!
Comment 12 Nick Clemens (kidclamp) 2025-08-01 13:12:01 UTC
Created attachment 185005 [details] [review]
Bug 38412: Display warning on biblio level

When no item is available, with AllowHoldPolicyOverride, a triangle appears on
    each item to be forced, but if you choose “next item available” without
    having  any item available, you won't see anything. Additionally, the top
    warning message about "No items are available" does not show when
    'AllowHoldPolicyOverride' is set to allow and no items are available
    (e.g. withdrawn, lost, damanged, depending on settings)

This patch corrects an error in request.pl where no incrementation of
    $num_override happens when an item is forced. This causes the warning
    triangle to appear on the 'Place hold' button on the bib level. The top
    warning message is restored as well.

 Finally, this patch changes the display of the fa-warning-triangle icon on the
    'Place hold' buttons to increase contrast with the button color, making it
    easier to see and increasing accessibility.

Test plan:
1) Set circulations rules for specific category and/or itemtype (for example 1
    hold allowed for staff on books). Set AllowHoldPolicyOverride on "Allow".
2) Search for a book biblio with multiple items, and set each item to a
    non-circulating status (withdrawn, lost, etc.)
3) Place a hold for a staff category patron for this bib record.
4) Normally you will see triangles on each item on specific section but you can
    force it. When you just select the next item available none triangle and
    none alert showing.
5) Apply this patch and restart_all.
6) Refresh your browser page.
7) Normally now there is a triangle into 'Place hold' submit button and an
    alert message appears on the top of the page. The triangle is also more
    visible.
8) Test other hold limits, such as max holds per record, to ensure the
    appropriate top alert message appears and the triangle alert appears on
    the 'Place hold' button.

Co-authored-by: Thibaud Guillot <thibaud.guillot@biblibre.com>
Sponsored-by: BibLibre
Sponsored-by: Westlake Porter Public Library <https://westlakelibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 13 Lucas Gass (lukeg) 2025-08-01 19:24:33 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 14 CJ Lynce 2025-08-07 15:25:11 UTC
Can this be backported to 25.05?