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.
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.
Created attachment 183240 [details] [review] Bug 40116: Do not display "Patron is already a guarantor..." pop-up 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. This patch sends nok variable as parameter to this same function so that if error occurs checkin patron guarantors is skipped. 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 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. Sponsored-by: Koha-Suomi Oy
Created attachment 183249 [details] [review] Bug 40116: Do not display "Patron is already a guarantor..." pop-up 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. This patch sends nok variable as parameter to this same function so that if error occurs checkin patron guarantors is skipped. 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 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. Sponsored-by: Koha-Suomi Oy Signed-off-by: David Flater <flaterdavid@gmail.com>
Comment on attachment 183240 [details] [review] Bug 40116: Do not display "Patron is already a guarantor..." pop-up when error occurs >From db6d7ef8c3fc95a837b29ae15dcfed7e302eba00 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Fri, 13 Jun 2025 13:15:57 +0300 >Subject: [PATCH] Bug 40116: Do not display "Patron is already a guarantor..." > pop-up 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. This patch >sends nok variable as parameter to this same function so that if error >occurs checkin patron guarantors is skipped. > >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 >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. > >Sponsored-by: Koha-Suomi Oy >--- > .../intranet-tmpl/prog/en/modules/members/memberentrygen.tt | 2 +- > koha-tmpl/intranet-tmpl/prog/js/members.js | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 361a178107..494bf3cc37 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -1779,7 +1779,7 @@ > > [% IF new_guarantors %] > [% FOREACH g IN new_guarantors %] >- select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]' ); >+ select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]', [% nok | $raw %] ); > [% END %] > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index a20561cfe0..7429e21859 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -90,12 +90,12 @@ function update_category_code(category_code) { > hint.html(hint_string); > } > >-function select_user(borrowernumber, borrower, relationship) { >+function select_user(borrowernumber, borrower, relationship, nok) { > let is_guarantor = $( > `.guarantor-details[data-borrowernumber=${borrowernumber}]` > ).length; > >- if (is_guarantor) { >+ if (is_guarantor && !nok) { > alert("Patron is already a guarantor for this patron"); > } else { > $("#guarantor_id").val(borrowernumber); >-- >2.34.1 >
Created attachment 183718 [details] [review] Bug 40116: Do not display "Patron is already a guarantor..." pop-up 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. This patch sends nok variable as parameter to this same function so that if error occurs checkin patron guarantors is skipped. 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 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. Sponsored-by: Koha-Suomi Oy Signed-off-by: David Flater <flaterdavid@gmail.com> Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
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.
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
Created attachment 183746 [details] [review] Bug 40116: Change classes for existing guarantors in patron form We are currently using classes "new_guarantor_id" and "new_guarantor_relationship" with existing guarantors in patron add/modify form. These classes should mainly be used when new guarantor is added and to ensure their data is not lost when error occurs. Now with previous patch applied using them leads to situation where existing guarantors information is displayed twice (or more times) if error occurs. This patch changes these classes as "guarantor_id" and "guarantor_relationship". To test: 1. Find patron who has a 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. 4. Apply this patch. 5. Attempt to save the patron again. => Notice that guarantor is no longer duplicated in "Patron guarantor" section. 6. Try to readd same patron as guarantor. => Pop-up "Patron is already a guarantor for this patron" should be displayed. 7. Try to add new guarantor for patron. => New guarantor should be added. 8. Attempt to save the patron. => Neither existing patron or new patron is duplicated. 9. Fix patrons age and attempt to save. => Patron is saved and both guarantors are displayed in their details. Sponsored-by: Koha-Suomi Oy
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.
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
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>
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>
Nice work everyone! Pushed to main for 25.11
Please don't forget to add release notes
Nice work everyone! Pushed to 25.05.x
Pushed to 24.11.x for 24.11.08