LP#1284864 propagate patron barcode to advanced hold options
authorBill Erickson <berick@esilibrary.com>
Tue, 25 Feb 2014 19:58:06 +0000 (14:58 -0500)
committerMike Rylander <mrylander@gmail.com>
Mon, 10 Mar 2014 16:29:51 +0000 (12:29 -0400)
1. Staff searches the catalog within the staff client, not focused on a
patron.

2. Staff types a barcode into the patron barcode input

3. Staff clicks "Advanced Holds Options" and the typed barcode now
propagates to the metarecord hold page.

--

Minor HTML cleanup to avoid 350+-wide character columns.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/opac/parts/place_hold.tt2
Open-ILS/web/js/ui/default/opac/staff.js

index 390b9ea..5383753 100644 (file)
             <label for="hold_usr_is_requestor_not">
                 [% l("Place hold for patron by barcode:") %]
             </label>
-            <input type="text" name="hold_usr" id="hold_usr_input" onchange="staff_hold_usr_barcode_changed();" onpaste="setTimeout(staff_hold_usr_barcode_changed,1);" onkeypress="return no_hold_submit(event)" autofocus /> <span id="patron_name"></span><span id="patron_usr_barcode_not_found" style="display: none">[% l('Patron barcode was not found') %]</span><br />
-            <input type="hidden" id="staff_barcode" value="[% ctx.staff_recipient.card.barcode | html %]"/>
+            <input type="text" name="hold_usr" id="hold_usr_input" 
+              value="[% CGI.param('usr_barcode') | html %]"
+              onchange="staff_hold_usr_barcode_changed();" 
+              onpaste="setTimeout(staff_hold_usr_barcode_changed,1);" 
+              onkeypress="return no_hold_submit(event)" autofocus /> 
+            <span id="patron_name"></span>
+            <span id="patron_usr_barcode_not_found" style="display: none">
+              [% l('Patron barcode was not found') %]
+            </span><br />
+            <input type="hidden" id="staff_barcode" 
+              value="[% ctx.staff_recipient.card.barcode | html %]"/>
             <span>
                 <input type="radio" id="hold_usr_is_requestor"
                     onchange="staff_hold_usr_input_disabler(this);"
@@ -66,7 +75,8 @@
                     [% END %]
                     [% IF NOT metarecords.disabled %]
                         [% IF CGI.param('hold_type') == 'T' AND hdata.record.metarecord %]
-                            <a href="[% mkurl('', {hold_type => 'M', hold_target => hdata.record.metarecord.id}) %]">
+                            <a  id='advanced_hold_link'
+                                href="[% mkurl('', {hold_type => 'M', hold_target => hdata.record.metarecord.id}) %]">
                                 [% l('Advanced Hold Options') %]</a>
                         [% END %]
                         [% IF hdata.metarecord_filters.formats.size OR # should this be size > 1
index 2be839f..8bae62f 100644 (file)
@@ -27,13 +27,23 @@ function no_hold_submit(event) {
     return true;
 }
 function staff_hold_usr_barcode_changed(isload) {
+
+    if (!document.getElementById('place_hold_submit')) {
+        // in some cases, the submit button is not present.
+        // exit early to avoid needless JS errors
+        return;
+    }
+
     if(typeof xulG != 'undefined' && xulG.get_barcode_and_settings) {
         var cur_hold_barcode = undefined;
         var barcode = isload;
         if(!barcode || barcode === true) barcode = document.getElementById('staff_barcode').value;
         var only_settings = true;
+        var bc_from_cgi = false; // user_barcode passed via cgi
         if(!document.getElementById('hold_usr_is_requestor').checked) {
-            if(!isload) {
+            if (isload && document.getElementById('hold_usr_input').value)
+                bc_from_cgi = true;
+            if(!isload || bc_from_cgi) {
                 barcode = document.getElementById('hold_usr_input').value;
                 only_settings = false;
             }
@@ -94,8 +104,20 @@ function staff_hold_usr_barcode_changed(isload) {
             document.getElementById('patron_name').innerHTML = load_info.patron_name;
             document.getElementById("patron_usr_barcode_not_found").style.display = 'none';
         }
-        // Ok, now we can allow submitting again, unless this is a "true" load, in which case we likely have a blank barcode box active
-        if (isload !== true)
+        
+        // update the advanced hold options link to propagate the patron
+        // barcode if clicked.  This is needed when the patron barcode
+        // is manually entered (i.e. the staff client does not provide one).
+        var adv_link = document.getElementById('advanced_hold_link');
+        if (adv_link) { // not present on MR hold pages
+            var href = adv_link.getAttribute('href').replace(
+                /;usr_barcode=[^;\&]+|$/, 
+                ';usr_barcode=' + encodeURIComponent(cur_hold_barcode));
+            adv_link.setAttribute('href', href);
+        }
+
+        // if we're here, we have a valid barcode.  activate the sumbmit option
+        if(!isload || bc_from_cgi) 
             document.getElementById('place_hold_submit').disabled = false;
     }
 }