Clicking twice or more on the Save button will generate duplicate patrons when adding patrons. Of course, there is handling that detects this, so you can choose to either edit the original record (i.e. throw away the duplicate) or create a duplicate record. However, it shouldn't get to that point by clicking on the Save button. That handling seems to be there to handle cases where you go through the whole process of trying to add a new patron only to find out that they already exist in the system (or at least their username/password do). -- I tried briefly to add the following code to the memberentrygen page: $("#entryform").preventDoubleFormSubmit(); But it doesn't seem to work. I wonder if it's because of the check_form_borrower code that executes on a submit of the form.
Created attachment 16010 [details] [review] Bug 9783 - can hit submit twice when adding patrons Currently, clicking twice or more on the Save button will generate duplicate patrons when adding patrons in the Patron module. Of course, there is handling that detects this, so you can choose to either edit the original record (i.e. throw away the duplicate) or create a duplicate record. However, it shouldn't get to that point by clicking on the Save button. That handling seems to be there to handle cases where you go through the whole process of trying to add a new patron only to find out that they already exist in the system (or at least their username/password do). -- This patch uses the "preventDoubleFormSubmit" function (which is also used in holds and fines to prevent double form submits). It was also necessary to edit members.js, since "check_form_borrowers" was forcing form submits despite the "preventDoubleFormSubmit" function. I've changed it from forcing a document.form.submit to return true, which the browser will still submit the form if it's a unique borrower, but the "preventDoubleFormSubmit" function will still prevent multiple submits. I've also added a "waiting" class to staff-global.js which changes the cursor to "wait" (i.e. loading circle graphic). I've included an "AddClass" call in "preventDoubleFormSubmit", so that the cursor graphic will change to show users that the page is loading so that they don't click Save again. Of course, even if they do click save again, there will only be one submit. However, this way - as Chris Cormack mentioned - the user knows that "something" is happening and that the form isn't broken. ------- Test Plan Before applying patch... 1) Fill out the form for a new patron in the Patron module 2) Click "Save" several times 3) Once the page loads, you'll be shown a prompt that says that this borrower already exists. You will have the option to view the original record, edit the original record, or create a new patron anyway 4) Click on edit the existing record, and delete the patron Apply the patch 5) Repeat steps 1 and 2 6) Notice that your cursor has changed into a little "loading" circle graphic when you hover over the "body" of the page, as well as any links or any inputs/buttons of the type "submit" within that form 7) Notice that no matter how many times you press the button, the form is not re-submitted. Eventually you will be taken to the new patron's record (no mention of duplication will occur) Ta da! Multiple form submits are prevented and the loading graphic signals to users that the form was submitted and that Koha is processing their data -- I understand that some people might want to change which elements are given the "waiting" class. I'm happy to renegotiate this as necessary.
Created attachment 16041 [details] [review] [SIGNED-OFF] Bug 9783 - can hit submit twice when adding patrons Currently, clicking twice or more on the Save button will generate duplicate patrons when adding patrons in the Patron module. Of course, there is handling that detects this, so you can choose to either edit the original record (i.e. throw away the duplicate) or create a duplicate record. However, it shouldn't get to that point by clicking on the Save button. That handling seems to be there to handle cases where you go through the whole process of trying to add a new patron only to find out that they already exist in the system (or at least their username/password do). -- This patch uses the "preventDoubleFormSubmit" function (which is also used in holds and fines to prevent double form submits). It was also necessary to edit members.js, since "check_form_borrowers" was forcing form submits despite the "preventDoubleFormSubmit" function. I've changed it from forcing a document.form.submit to return true, which the browser will still submit the form if it's a unique borrower, but the "preventDoubleFormSubmit" function will still prevent multiple submits. I've also added a "waiting" class to staff-global.js which changes the cursor to "wait" (i.e. loading circle graphic). I've included an "AddClass" call in "preventDoubleFormSubmit", so that the cursor graphic will change to show users that the page is loading so that they don't click Save again. Of course, even if they do click save again, there will only be one submit. However, this way - as Chris Cormack mentioned - the user knows that "something" is happening and that the form isn't broken. ------- Test Plan Before applying patch... 1) Fill out the form for a new patron in the Patron module 2) Click "Save" several times 3) Once the page loads, you'll be shown a prompt that says that this borrower already exists. You will have the option to view the original record, edit the original record, or create a new patron anyway 4) Click on edit the existing record, and delete the patron Apply the patch 5) Repeat steps 1 and 2 6) Notice that your cursor has changed into a little "loading" circle graphic when you hover over the "body" of the page, as well as any links or any inputs/buttons of the type "submit" within that form 7) Notice that no matter how many times you press the button, the form is not re-submitted. Eventually you will be taken to the new patron's record (no mention of duplication will occur) Ta da! Multiple form submits are prevented and the loading graphic signals to users that the form was submitted and that Koha is processing their data -- I understand that some people might want to change which elements are given the "waiting" class. I'm happy to renegotiate this as necessary. Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Created attachment 16913 [details] [review] [PASSED QA] Bug 9783 - can hit submit twice when adding patrons Currently, clicking twice or more on the Save button will generate duplicate patrons when adding patrons in the Patron module. Of course, there is handling that detects this, so you can choose to either edit the original record (i.e. throw away the duplicate) or create a duplicate record. However, it shouldn't get to that point by clicking on the Save button. That handling seems to be there to handle cases where you go through the whole process of trying to add a new patron only to find out that they already exist in the system (or at least their username/password do). -- This patch uses the "preventDoubleFormSubmit" function (which is also used in holds and fines to prevent double form submits). It was also necessary to edit members.js, since "check_form_borrowers" was forcing form submits despite the "preventDoubleFormSubmit" function. I've changed it from forcing a document.form.submit to return true, which the browser will still submit the form if it's a unique borrower, but the "preventDoubleFormSubmit" function will still prevent multiple submits. I've also added a "waiting" class to staff-global.js which changes the cursor to "wait" (i.e. loading circle graphic). I've included an "AddClass" call in "preventDoubleFormSubmit", so that the cursor graphic will change to show users that the page is loading so that they don't click Save again. Of course, even if they do click save again, there will only be one submit. However, this way - as Chris Cormack mentioned - the user knows that "something" is happening and that the form isn't broken. ------- Test Plan Before applying patch... 1) Fill out the form for a new patron in the Patron module 2) Click "Save" several times 3) Once the page loads, you'll be shown a prompt that says that this borrower already exists. You will have the option to view the original record, edit the original record, or create a new patron anyway 4) Click on edit the existing record, and delete the patron Apply the patch 5) Repeat steps 1 and 2 6) Notice that your cursor has changed into a little "loading" circle graphic when you hover over the "body" of the page, as well as any links or any inputs/buttons of the type "submit" within that form 7) Notice that no matter how many times you press the button, the form is not re-submitted. Eventually you will be taken to the new patron's record (no mention of duplication will occur) Ta da! Multiple form submits are prevented and the loading graphic signals to users that the form was submitted and that Koha is processing their data -- I understand that some people might want to change which elements are given the "waiting" class. I'm happy to renegotiate this as necessary. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Looks good and works nicely.
This patch has been pushed to master.