[Bug 9507] New: In order not to submit a form unexpectedly some code is duplicated
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Bug ID: 9507 Summary: In order not to submit a form unexpectedly some code is duplicated Classification: Unclassified Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Staff Client Assignee: koha-bugs@lists.koha-community.org Reporter: jonathan.druart@biblibre.com CC: gmcharlt@gmail.com -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|koha-bugs@lists.koha-commun |jonathan.druart@biblibre.co |ity.org |m -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #1 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 14947 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=14947&action=edit Bug 9507: prevent submit: factorize some code in a js file This patch factorize code in a js file. Test plan: On acqui/neworderempty.pl, acqui/orderreceive.pl and serials/serials-edit.tt try to scan a barcode (or press enter) on the form and check that it is not sent. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |9268 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #14947|0 |1 is obsolete| | --- Comment #2 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 15015 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=15015&action=edit Bug 9507: prevent submit: factorize some code in a js file This patch factorize code in a js file. Test plan: On acqui/neworderempty.pl, acqui/orderreceive.pl and serials/serials-edit.tt try to scan a barcode (or press enter) on the form and check that it is not sent. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|In order not to submit a |Some code used to prevent |form unexpectedly some code |form from being |is duplicated |unexpectedly submitted is | |duplicated -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl --- Comment #3 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Just a question: +function IEEventHandler_KeyDown() { + if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit') + return false; + return true; +} But am I missing a parameter here? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #4 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to comment #3)
Just a question:
+function IEEventHandler_KeyDown() { + if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit') + return false; + return true; +}
But am I missing a parameter here?
Humm, I just factorize the code, so it is not a regression. I don't have IE for testing it. In fact event is a global object, it is not necessary to pass it in parameters. This code should work I think. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #5 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to comment #4)
I don't have IE for testing it. :) I would not recommend IE too for the staff client. But if you change code related to IE, it still would be an idea to test it somehow?
In fact event is a global object, it is not necessary to pass it in parameters. Yes, you are right (of course). As a purist, you could perhaps say that it should be even better to refer to window.event. With Google, I came across this example for a cross-browser solution:
element.onclick = doSomething; function doSomething(e) { if (!e) var e = window.event; // e gives access to the event in all browsers } -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #6 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to comment #5)
With Google, I came across this example for a cross-browser solution:
element.onclick = doSomething; function doSomething(e) { if (!e) var e = window.event; // e gives access to the event in all browsers }
Yep I think the code can be improved, but the goal of this patch is only to factorize the code. When this patch will be pushed, it will be easy to improve it: there will be only 1 place to change :) Don't you agree with me? -- You are receiving this mail because: You are watching all bug changes.
Yep I think the code can be improved, but the goal of this patch is only to factorize the code. Don't you agree with me? Yes, I agree. Will try to qa this today. BTW As a non-native English speaker, I think you mean to refactor the code. I
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #7 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to comment #6) thought factorizing was 12=3*2*2 :-) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #8 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to comment #7)
BTW As a non-native English speaker, I think you mean to refactor the code. I thought factorizing was 12=3*2*2 :-)
Ooops :-/ Thanks! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15015|0 |1 is obsolete| | --- Comment #9 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 18305 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=18305&action=edit Bug 9507: prevent submit: refactor some code in a js file This patch refactores code in a js file. Test plan: On acqui/neworderempty.pl, acqui/orderreceive.pl and serials/serials-edit.tt try to scan a barcode (or press enter) on the form and check that it is not sent. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #10 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 18309 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=18309&action=edit Bug 9507: prevent submit: refactor some code in a js file This patch refactors code in a js file. Test plan: On acqui/neworderempty.pl, acqui/orderreceive.pl and serials/serials-edit.tt try to scan a barcode (or press enter) on the form and check that it is not sent. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Have to note that the code for IE9 does not work. Before and after this patch. If we refactor code, it would have been nice to resolve this too. But I do not oppose pushing this patch. The test uses 'an ancient Netscape property' window.Event (uppercase!) to make the distinction between browers and event models. Some more documentation here would be welcome too. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #18305|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #18309|0 |1 is obsolete| | --- Comment #11 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 18310 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=18310&action=edit Bug 9507: prevent submit: refactor some code in a js file This patch refactors some code in a js file. Test plan: On acqui/neworderempty.pl, acqui/orderreceive.pl and serials/serials-edit.tt try to scan a barcode (or press enter) on the form and check that it is not sent. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Have to note that the code for IE9 does not work. Before and after this patch. If we refactor code, it would have been nice to resolve this too. But I do not oppose pushing this patch. The test uses 'an ancient Netscape property' window.Event (uppercase!) to make the distinction between browers and event models. Some more documentation here would be welcome too. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA --- Comment #12 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- QA Comment: See signoff. Tested under FF. Works well. Tested under IE9. Does not work before or after. No complaints from qa-tools. Passing QA but with some reluctancy as noted. With appreciation for the intention to improve code BTW! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |10310 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master Patch complexity|--- |Small patch --- Comment #13 from Galen Charlton <gmcharlt@gmail.com> --- Pushed to master. Thanks, Jonathan! I too encourage a quick follow-up to improve the Javascript, now that it lives only in one place. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |Pushed to Stable CC| |tomascohen@gmail.com --- Comment #14 from Tomás Cohen Arazi <tomascohen@gmail.com> --- This patch has been pushed to 3.12.x, will be in 3.12.1. I was reluctant to cherry picking refactoring patches, but it is needed by 10310 which is a good bugfix. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bgkriegel@gmail.com --- Comment #15 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- Pushed to 3.10.x, will be in 3.10.7 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Chris Hall <chrish@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chrish@catalyst.net.nz --- Comment #16 from Chris Hall <chrish@catalyst.net.nz> --- I tried applying this patch to 3.8.x and it came across mostly clean, the only concern I had was <script type="text/javascript" src="[% themelang %]/js/cataloging.js"></script> +<script type="text/javascript" src="[% themelang %]/js/prevent_submit.js"></script> 3.8.x doesn't have cataloging.js, will prevent_submit.js work fine without it? I didn't want to make a guess. This patch is required for 10310 so I would quite like it for 3.8.x Thank you for your attention. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #17 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 18726 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=18726&action=edit Bug 9507: prevent submit: refactor some code in a js file This patch refactors some code in a js file. Test plan: On acqui/neworderempty.pl, acqui/orderreceive.pl and serials/serials-edit.tt try to scan a barcode (or press enter) on the form and check that it is not sent. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Have to note that the code for IE9 does not work. Before and after this patch. If we refactor code, it would have been nice to resolve this too. But I do not oppose pushing this patch. The test uses 'an ancient Netscape property' window.Event (uppercase!) to make the distinction between browers and event models. Some more documentation here would be welcome too. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #18726|Bug 9507: prevent submit: |[3.8.x] Bug 9507: prevent description|refactor some code in a js |submit: refactor some code |file |in a js file -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #18 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to comment #16) Hi Chris, this last patch applies on 3.8.x branch. js/cataloguing.js is not needed for this patch. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9507 --- Comment #19 from Chris Hall <chrish@catalyst.net.nz> --- (In reply to comment #18) Thank you very much for that Jonathan :) Followed the test plan and it worked perfectly, you just have to make sure to select the form before hitting enter as the search box has focus (this is not a critique of your patch but a note to others testing it). Pushed to 3.8.x, will be in 3.8.14. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org