[open-ils-commits] [GIT] Evergreen ILS branch rel_2_1 updated. 792dbb7638305abab5307674fdbebc00e6f8e0fa

Evergreen Git git at git.evergreen-ils.org
Thu Aug 4 14:57:26 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_1 has been updated
       via  792dbb7638305abab5307674fdbebc00e6f8e0fa (commit)
      from  a810f09b41f36fa01adfd80360aa003ec17090d9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 792dbb7638305abab5307674fdbebc00e6f8e0fa
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Wed Aug 3 00:44:41 2011 -0400

    Fix staff client Clear Expired Hold Shelf action
    
    Accomodate an API change.  FIXME: See if can remove some of the redundant and/or
    un-needed data being sent over the wire.
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js
index 8df66cf..b9dcd54 100644
--- a/Open-ILS/xul/staff_client/server/patron/holds.js
+++ b/Open-ILS/xul/staff_client/server/patron/holds.js
@@ -39,6 +39,8 @@ patron.holds.prototype = {
 
         var obj = this;
 
+        dojo.require("openils.Util");
+
         obj.patron_id = params['patron_id'];
         obj.patron_barcode = params['patron_barcode'];
         obj.docid = params['docid'];
@@ -1264,44 +1266,9 @@ patron.holds.prototype = {
                     'cmd_clear_expired_onshelf_holds' : [
                         ['command'],
                         function(ev) {
-                            try {
-                                // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
-                                var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
-                                if (robj == null) { robj = []; }
-                                if (typeof robj.ilsevent != 'undefined') { throw(robj); }
-                                if (typeof robj.length == 'undefined') { robj = [ robj ]; }
-
-                                // Disable anything such as filters that can have us accidentally lose these non-repeatable results
-                                var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
-                                if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
-                                var x_lib_type_menu = document.getElementById('lib_type_menu');
-                                if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
-                                var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
-                                if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
-                                obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
-                                obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
-
-                                // id's in xulG.holds will prevent the normal retrieval method from firing
-                                JSAN.use('util.functional');
-                                xulG.holds = util.functional.map_list(
-                                    robj.sort(function(a,b) {
-                                        if (a.action > b.action) { return 1; }
-                                        if (a.action < b.action) { return -1; }
-                                        return 0;
-                                    }),
-                                    function (element, idx) {
-                                        obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
-                                        return element.hold_id;
-                                    }
-                                );
-                                obj.clear_and_retrieve();
-                            } catch(E) {
-                                if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
-                                obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
-                            }
+                            obj.cmd_clear_expired_onshelf_holds();
                         }
                     ],
-
                     'cmd_search_opac' : [
                         ['command'],
                         function(ev) {
@@ -1651,6 +1618,86 @@ patron.holds.prototype = {
         } catch(E) {
             this.error.standard_unexpected_error_alert('rendering lib menu',E);
         }
+    },
+
+    'cmd_clear_expired_onshelf_holds' : function() {
+        var obj = this;
+        try {
+            // Disable anything such as filters that can have us accidentally
+            // lose these non-repeatable results.  Well, now that they're cached
+            // it's less of an issue.
+            if ($('lib_filter_checkbox')) {
+                $('lib_filter_checkbox').checked = false;
+            }
+            if ($('lib_type_menu')) {
+                $('lib_type_menu').disabled = true;
+            }
+            if ($('lib_menu_placeholder')) {
+                $('lib_menu_placeholder').firstChild.disabled = true;
+            }
+            obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute(
+                'disabled', 'true');
+            obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute(
+                'disabled', 'true');
+
+            // I could put this with the "retrieval" methods, but since it has
+            // side effects, seems cleaner to invoke it here
+            var robj = obj.network.simple_request(
+                'CLEAR_HOLD_SHELF',
+                [
+                    ses(),
+                    obj.filter_lib || obj.data.list.au[0].ws_ou()
+                ]
+            );
+            if (typeof robj.ilsevent != 'undefined') { throw(robj); }
+            if (typeof robj.cache_key == 'undefined') { throw(robj); }
+
+            var cache_key = robj.cache_key;
+
+            // id's in xulG.holds will prevent the normal retrieval method from
+            // firing.  Let's put our affected hold.id's in here:
+            xulG.holds = [];
+
+            // Start the progress meter
+            $('progress').value = 0;
+            $('progress').hidden = false;
+
+            // Fetch the affected holds
+            fieldmapper.standardRequest(
+                [ 'open-ils.circ', 'open-ils.circ.hold.clear_shelf.get_cache' ],
+                {
+                    'async' : true,
+                    'params' : [ ses(), cache_key ],
+                    'onresponse' : function(r) {
+                        dojo.forEach(
+                            openils.Util.readResponse(r),
+                            function(resp) {
+                                if (resp.maximum) {
+                                    $('progress').value = Number(resp.progress)
+                                        * 100/resp.maximum;
+                                    return;
+                                }
+                                obj.post_clear_shelf_hold_action_map[
+                                    resp.hold_details.id
+                                ] = resp.action;
+                                xulG.holds.push( resp.hold_details.id );
+                            }
+                        )
+                    },
+                    'oncomplete' : function() {
+                        obj.clear_and_retrieve();
+                        $('progress').hidden = true;
+                    }
+                }
+            );
+
+        } catch(E) {
+            if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
+                return; /* handled by network.js */
+            }
+            obj.error.standard_unexpected_error_alert(
+                'Error in holds.js, cmd_clear_expired_onshelf_holds', E);
+        }
     }
 }
 

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/xul/staff_client/server/patron/holds.js |  119 +++++++++++++++-------
 1 files changed, 83 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list