Bug 40116 - Extra popup notice when saving a patron with patron guarantor ends in error
Summary: Extra popup notice when saving a patron with patron guarantor ends in error
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Emmi Takkinen
QA Contact: Aleisha Amohia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-11 11:49 UTC by Anneli Österman
Modified: 2025-08-01 09:42 UTC (History)
7 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patch changes existing guarantors elements in the patron add form to use classes "guarantor_id" and "guarantor_relationship" to prevent an unnecessary pop-up if the form throws an error.
Version(s) released in:
25.11.00,25.05.02,24.11.08
Circulation function:


Attachments
Bug 40116: Do not display "Patron is already a guarantor..." pop-up when error occurs (3.30 KB, patch)
2025-06-13 10:35 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 40116: Do not display "Patron is already a guarantor..." pop-up when error occurs (3.35 KB, patch)
2025-06-13 18:36 UTC, David Flater
Details | Diff | Splinter Review
Bug 40116: Do not display "Patron is already a guarantor..." pop-up when error occurs (3.41 KB, patch)
2025-07-02 23:07 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 40116: Change classes for existing guarantors in patron form (4.22 KB, patch)
2025-07-03 11:11 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 40116: Do not display "Patron is already a guarantor..." popup when error occurs (4.73 KB, patch)
2025-07-04 06:20 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 40116: Do not display "Patron is already a guarantor..." popup when error occurs (4.84 KB, patch)
2025-07-14 11:57 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40116: Do not display "Patron is already a guarantor..." popup when error occurs (4.90 KB, patch)
2025-07-15 21:37 UTC, Aleisha Amohia
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Anneli Österman 2025-06-11 11:49:48 UTC
If a yellow error message appears when saving the guaranteed patron, also an extra popup message "Patron is already a guarantor for this patron" will appear on the screen.

How to reproduce:
1. Find a patron with Patron guarantor or add first a Patron guarantor (not a Non-patron guarantor) to a juvenile patron and save.
2. Edit again the same patron with guarantor and modify their age to be greater than the upperage or under the required age of the patron category.
3. Notice that you will get a yellow message "The following fields are wrong. Please fix them. Patron's age is incorrect for their category. Ages allowed are xx-xx."
4. Notice that you will also get a pop up notice that says "Patron is already a guarantor for this patron". It should only appear when you try to add the same patron as a guarantor that already is a guarantor for that patron.
Comment 1 Emmi Takkinen 2025-06-11 12:17:47 UTC
Bug 26558 made changes to restoring guarantor data when error occurs while creating/modifying patron. Now every time error occurs param new_guarantors is send to front-end side which triggers function select_user in member.js.
Comment 2 Emmi Takkinen 2025-06-13 10:35:54 UTC Comment hidden (obsolete)
Comment 3 David Flater 2025-06-13 18:36:33 UTC Comment hidden (obsolete)
Comment 4 Emmi Takkinen 2025-07-02 06:21:01 UTC Comment hidden (obsolete)
Comment 5 Aleisha Amohia 2025-07-02 23:07:45 UTC Comment hidden (obsolete)
Comment 6 Emmi Takkinen 2025-07-03 06:32:39 UTC
There is now a new problem with this patch. If error occurs all guarantors are displayed twice (or more) in form.

To reproduce:
1. Find patron who has guarantor.
2. Modify their age to be greater than the upperage or under the required age of the patron category.
3. Attempt to save patron.
=> Notice that guarantor is now displayed twice in "Patron guarantor" section.

Guarantor isn't saved again, but this still needs some rethinking. Setting this as Failed QA.
Comment 7 Emmi Takkinen 2025-07-03 09:43:52 UTC
There is an oddity in existing guarantors classes. They use classes "new_guarantor_id" and "new_guarantor_relationship" which are readded to the form if error occurs. Which should only be done to guarantors who are not yet saved as guarantors. I changed those classes as "guarantor_id" and "guarantor_relationship" and now they are no longer duplicated if error occurs. But for some reason I'm now unable to save any of my guarantee patrons :D
Comment 8 Emmi Takkinen 2025-07-03 11:11:16 UTC Comment hidden (obsolete)
Comment 9 Emmi Takkinen 2025-07-04 05:30:50 UTC
Just realized that first patch is actually now obsolete. Getting rid of the "new_guarantor_id" and "new_guarantor_relationship" classes is enough to fix the original problem, there is no need to send variable "nok" to front-end.
Comment 10 Emmi Takkinen 2025-07-04 06:20:01 UTC
Created attachment 183780 [details] [review]
Bug 40116: Do not display "Patron is already a guarantor..."  popup when error occurs

If a yellow error message appears when saving the guaranteed patron,
also an extra popup message "Patron is already a guarantor for this
patron" will appear on the screen. It should only appear when you try
to add the same patron as a guarantor that already is a guarantor for
that patron. This happens because js function select_user is triggered
every time when guarantor data is send back to front-end with variable
new_guarantors if error occurs. Already existing guarantors shouldn't
be send back to front-end since their data is not lost. This patch
changes existing guarantors form elements to use classes "guarantor_id"
and "guarantor_relationship" to prevent this.

To test:
1. Find a patron with Patron guarantor or add first a Patron guarantor
(not a Non-patron guarantor) to a juvenile patron and save.
2. Edit again the same patron with guarantor and modify their age
to be greater than the upperage or under the required age of the patron
category.
=> Notice that you will get a yellow message "The following fields are wrong.
Please fix them..."
=> Notice that you will also get a pop up notice that says "Patron is already
a guarantor for this patron".
3. Apply this patch.
4. Repeat step 2.
=> Confirm that yellow message box is displayed but "Patron is..." pop-up is not
=> Also confirm that guarantors data is not lost.
5. Try to add same patron guarantor as guarantor for guarantee patron again.
=> Confirm that pop-up is displayed right after attempting to add guarantor.
6. Try to add new guarantor for patron.
=> New guarantor should be added.
7. Attempt to save the patron.
=> Confirm that both guarantors data is still displayed in form.
8. Fix patrons age and attempt to save.
=> Patron is saved and both guarantors are displayed in their details.

Sponsored-by: Koha-Suomi Oy
Comment 11 Owen Leonard 2025-07-14 11:57:12 UTC
Created attachment 184049 [details] [review]
Bug 40116: Do not display "Patron is already a guarantor..." popup when error occurs

If a yellow error message appears when saving the guaranteed patron,
also an extra popup message "Patron is already a guarantor for this
patron" will appear on the screen. It should only appear when you try
to add the same patron as a guarantor that already is a guarantor for
that patron. This happens because js function select_user is triggered
every time when guarantor data is send back to front-end with variable
new_guarantors if error occurs. Already existing guarantors shouldn't
be send back to front-end since their data is not lost. This patch
changes existing guarantors form elements to use classes "guarantor_id"
and "guarantor_relationship" to prevent this.

To test:
1. Find a patron with Patron guarantor or add first a Patron guarantor
   (not a Non-patron guarantor) to a juvenile patron and save.
2. Edit again the same patron with guarantor and modify their age
   to be greater than the upperage or under the required age of the
   patron category.
   => Notice that you will get a yellow message "The following fields
      are wrong. Please fix them..."
   => Notice that you will also get a pop up notice that says "Patron is
      already a guarantor for this patron".
3. Apply this patch.
4. Repeat step 2.
   => Confirm that yellow message box is displayed but "Patron is..."
      pop-up is not
   => Also confirm that guarantors data is not lost.
5. Try to add same patron guarantor as guarantor for guarantee patron
   again.
   => Confirm that pop-up is displayed right after attempting to add
      guarantor.
6. Try to add new guarantor for patron.
   => New guarantor should be added.
7. Attempt to save the patron.
   => Confirm that both guarantors data is still displayed in form.
8. Fix patrons age and attempt to save.
   => Patron is saved and both guarantors are displayed in their
      details.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 12 Aleisha Amohia 2025-07-15 21:37:17 UTC
Created attachment 184119 [details] [review]
Bug 40116: Do not display "Patron is already a guarantor..." popup when error occurs

If a yellow error message appears when saving the guaranteed patron,
also an extra popup message "Patron is already a guarantor for this
patron" will appear on the screen. It should only appear when you try
to add the same patron as a guarantor that already is a guarantor for
that patron. This happens because js function select_user is triggered
every time when guarantor data is send back to front-end with variable
new_guarantors if error occurs. Already existing guarantors shouldn't
be send back to front-end since their data is not lost. This patch
changes existing guarantors form elements to use classes "guarantor_id"
and "guarantor_relationship" to prevent this.

To test:
1. Find a patron with Patron guarantor or add first a Patron guarantor
   (not a Non-patron guarantor) to a juvenile patron and save.
2. Edit again the same patron with guarantor and modify their age
   to be greater than the upperage or under the required age of the
   patron category.
   => Notice that you will get a yellow message "The following fields
      are wrong. Please fix them..."
   => Notice that you will also get a pop up notice that says "Patron is
      already a guarantor for this patron".
3. Apply this patch.
4. Repeat step 2.
   => Confirm that yellow message box is displayed but "Patron is..."
      pop-up is not
   => Also confirm that guarantors data is not lost.
5. Try to add same patron guarantor as guarantor for guarantee patron
   again.
   => Confirm that pop-up is displayed right after attempting to add
      guarantor.
6. Try to add new guarantor for patron.
   => New guarantor should be added.
7. Attempt to save the patron.
   => Confirm that both guarantors data is still displayed in form.
8. Fix patrons age and attempt to save.
   => Patron is saved and both guarantors are displayed in their
      details.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 13 Lucas Gass (lukeg) 2025-07-16 20:32:49 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 14 Lucas Gass (lukeg) 2025-07-16 20:33:47 UTC
Please don't forget to add release notes
Comment 15 Paul Derscheid 2025-07-24 08:20:18 UTC
Nice work everyone!

Pushed to 25.05.x
Comment 16 Fridolin Somers 2025-08-01 09:42:55 UTC
Pushed to 24.11.x for 24.11.08