Bug 14011

Summary: Triggering slip print with enter key collides with 'barcode submitted' message
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: CirculationAssignee: Bugs List <koha-bugs>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: gmcharlt, jonathan.druart, kyle.m.hall, kyle, tomascohen, veron
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13415
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 14011 - Triggering slip print with enter key collides with 'barcode submitted'
Bug 14011 - Triggering slip print with enter key collides with 'barcode submitted'
Bug 14011 - Triggering slip print with enter key collides with 'barcode submitted'
Bug 14011: Make the jQuery selector explicit

Description Katrin Fischer 2015-04-17 21:20:05 UTC
To test:

- submit empty checkout for triggering a slip print
- print the slip or cancel
- notice you can't read a new barcode into the field now,
  instead, the 'barcode submitted' message will be triggered each time
  you try
Comment 1 Marc Véron 2015-04-19 18:31:19 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2015-04-20 01:05:12 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-04-20 10:28:25 UTC
Comment on attachment 38148 [details] [review]
Bug 14011 - Triggering slip print with enter key collides with 'barcode submitted'

Review of attachment 38148 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ +64,4 @@
>  
>  $(document).ready(function() {
>      $('#mainform').on('submit',function() {
> +        if (barcode && barcode.value) {

What is the barcode variable?
This variable is never defined, and you will never pass this condition.
Comment 4 Marc Véron 2015-04-20 12:51:30 UTC
Hi Jonathan,

Add following alerts after line 66 in circulation.tt:

$(document).ready(function() {
    $('#mainform').on('submit',function() {
alert(barcode);
alert(barcode.value);
        $('#barcode').on('keypress',function(event) {
            $('#barcodeSubmittedModal').modal();
            event.preventDefault(); }
        );
    });
(...)

...and then do checkout with a barcode e.g. 123456789 

Result: With the first alert you will get [object HTMLInputELement] and with the second the barcode 123456789

While testing I detected errors because there seem to be cases where the object barcode does not (yet?) exist. That's why I test first for the existence of barcode and then for it's value.
Comment 5 Jonathan Druart 2015-04-20 13:14:19 UTC
Created attachment 38185 [details] [review]
Bug 14011 - Triggering slip print with enter key collides with 'barcode submitted'

To reproduce:

- Log into staff client
- Find a client with 0 checkouts
- Print a slip (or cancel printing it)
- Attempt to type in a barcode to checkout
  -- annoying modal screen pops up
     'barcode submitted' message will be triggered each time
     you try

To test:
- apply patch
- try to reproduce issue

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 6 Jonathan Druart 2015-04-20 13:14:29 UTC
Created attachment 38186 [details] [review]
Bug 14011: Make the jQuery selector explicit

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 7 Jonathan Druart 2015-04-20 13:15:34 UTC
(In reply to Marc Véron from comment #4)
> Hi Jonathan,
> 
> Add following alerts after line 66 in circulation.tt:
> 
> $(document).ready(function() {
>     $('#mainform').on('submit',function() {
> alert(barcode);
> alert(barcode.value);
>         $('#barcode').on('keypress',function(event) {
>             $('#barcodeSubmittedModal').modal();
>             event.preventDefault(); }
>         );
>     });
> (...)

It's seem that barcode and $("#barcode") is the same, I was not aware of that.
Comment 8 Marc Véron 2015-04-20 13:31:13 UTC
Thanks Jonathan for passing QA.

BTW: 
I did some tests with $('#barcode') instead of barcode (see #4).
The first alert showed [object Object] instead of [object HTMLInputELement] and the second 'undefined' instead of the value (and the patch did not work).
Comment 9 Marc Véron 2015-04-20 14:02:56 UTC
Re-tested with second patch, works as expected.
Comment 10 Tomás Cohen Arazi (tcohen) 2015-05-04 14:48:52 UTC
Patches pushed to master.

Thanks Marc!