initial patron hold placement via catalog
authorBill Erickson <berick@esilibrary.com>
Thu, 17 Jul 2014 21:09:47 +0000 (17:09 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 17 Jul 2014 21:09:47 +0000 (17:09 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_holds.tt2
Open-ILS/src/templates/staff/circ/patron/t_holds_create.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/circ/patron/t_holds_list.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/holds.js
Open-ILS/web/js/ui/default/staff/services/eframe.js

index cdd5e46..5ccd762 100644 (file)
     record-id="detail_hold_record_id"></eg-record-summary>
   <eg-hold-details hold-retrieved="set_hold" hold-id="detail_hold_id"></eg-hold-details>
 </div>
+
+<!-- catalog view for holds placement -->
+
+<div ng-if="placing_hold">
+  <eg-embed-frame url="catalog_url" handlers="handlers" 
+    onchange="handle_page"></eg-embed-frame>
+</div>
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_holds_create.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_holds_create.tt2
new file mode 100644 (file)
index 0000000..e8e82e4
--- /dev/null
@@ -0,0 +1,4 @@
+<!-- holds are created within the catalog -->
+
+<eg-embed-frame url="catalog_url" 
+  handlers="handlers" onchange="handle_page"></eg-embed-frame>
index d3bbae0..df026fa 100644 (file)
@@ -4,6 +4,8 @@
   items-provider="gridDataProvider"
   persist-key="circ.patron.holds">
 
+  <eg-grid-menu-item handler="place_hold" 
+    label="[% l('Place Hold') %]"></eg-grid-menu-item>
   <eg-grid-menu-item handler="detail_view" 
     label="[% l('Detail View') %]"></eg-grid-menu-item>
 
index 4a58a23..8c06ad5 100644 (file)
@@ -72,82 +72,7 @@ function($scope , $routeParams , $location , $q , egCore , egHolds,
     }
 
     // xulG catalog handlers
-    $scope.handlers = {
-        get_barcode_and_settings_async : function(barcode, only_settings) {
-            if (!barcode) return $q.reject();
-            var deferred = $q.defer();
-
-            var barcode_promise = $q.when(barcode);
-            if (!only_settings) {
-
-                // first verify / locate the barcode
-                barcode_promise = egCore.net.request(
-                    'open-ils.actor',
-                    'open-ils.actor.get_barcodes',
-                    egCore.auth.token(), 
-                    egCore.auth.user().ws_ou(), 'actor', barcode
-                ).then(function(resp) {
-
-                    if (!resp || egCore.evt.parse(resp) || !resp.length) {
-                        console.error('user not found: ' + barcode);
-                        deferred.reject();
-                        return null;
-                    } 
-
-                    resp = resp[0];
-                    return barcode = resp.barcode;
-                });
-            }
-
-            barcode_promise.then(function(barcode) {
-                if (!barcode) return;
-
-                return egCore.net.request(
-                    'open-ils.actor',
-                    'open-ils.actor.user.fleshed.retrieve_by_barcode',
-                    egCore.auth.token(), barcode);
-
-            }).then(function(user) {
-                if (!user) return null;
-
-                if (e = egCore.evt.parse(user)) {
-                    console.error('user fetch failed : ' + e.toString());
-                    deferred.reject();
-                    return null;
-                }
-
-                // copied more or less directly from XUL menu.js
-                var settings = {};
-                for(var i = 0; i < user.settings().length; i++) {
-                    settings[user.settings()[i].name()] = 
-                        JSON2js(user.settings()[i].value());
-                }
-
-                if(!settings['opac.default_phone'] && user.day_phone()) 
-                    settings['opac.default_phone'] = user.day_phone();
-                if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') 
-                    settings['opac.hold_notify'] = 'email:phone';
-
-                // Taken from patron/util.js format_name
-                // FIXME: I18n
-                var patron_name = 
-                    ( user.prefix() ? user.prefix() + ' ' : '') +
-                    user.family_name() + ', ' +
-                    user.first_given_name() + ' ' +
-                    ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
-                    ( user.suffix() ? user.suffix() : '');
-
-                deferred.resolve({
-                    "barcode": barcode, 
-                    "settings" : settings, 
-                    "user_email" : user.email(), 
-                    "patron_name" : patron_name
-                });
-            });
-
-            return deferred.promise;
-        }
-    }
+    $scope.handlers = { }
 
     // ------------------------------------------------------------------
     // Holds 
index b150528..275ccfc 100644 (file)
@@ -114,6 +114,12 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap',
         resolve : resolver
     });
 
+    $routeProvider.when('/circ/patron/:id/holds/create', {
+        templateUrl: './circ/patron/t_holds_create',
+        controller: 'PatronHoldsCreateCtrl',
+        resolve : resolver
+    });
+
     $routeProvider.when('/circ/patron/:id/holds/:hold_id', {
         templateUrl: './circ/patron/t_holds',
         controller: 'PatronHoldsCtrl',
index d49c15a..c42a162 100644 (file)
@@ -115,6 +115,10 @@ function($scope,  $q,  $routeParams,  egCore,  egUser,  patronSvc,
         $location.path('/circ/patron/' + $scope.patron_id + '/holds');
     }
 
+    $scope.place_hold = function() {
+        $location.path($location.path() + '/create');
+    }
+
     // when the detail hold is fetched (and updated), update the bib
     // record summary display record id.
     $scope.set_hold = function(hold_data) {
@@ -122,3 +126,30 @@ function($scope,  $q,  $routeParams,  egCore,  egUser,  patronSvc,
     }
 
 }])
+
+
+.controller('PatronHoldsCreateCtrl',
+       ['$scope','$routeParams','$location','egCore','patronSvc',
+function($scope , $routeParams , $location , egCore , patronSvc) {
+
+    $scope.handlers = {
+        opac_hold_placed : function() {
+            // FIXME: this isn't getting called.. not sure why
+            patronSvc.fetchUserStats(); // update hold counts
+        }
+    }
+
+    $scope.initTab('holds', $routeParams.id).then(function(isAlert) {
+        if (isAlert) return;
+        // not guarenteed to have a barcode until init fetches the user
+        $scope.handlers.patron_barcode = patronSvc.current.card().barcode();
+    });
+
+    $scope.catalog_url = 
+        $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
+
+    $scope.handle_page = function(url) {
+    }
+
+}])
index fbbf886..7e18246 100644 (file)
@@ -23,8 +23,8 @@ angular.module('egCoreMod')
             + 'class="eg-embed-frame" style="height:{{height}}px"></iframe>',
 
         controller : 
-                   ['$scope','$window','$location','egCore',
-            function($scope , $window , $location , egCore) {
+                   ['$scope','$window','$location','$q','egCore',
+            function($scope , $window , $location , $q , egCore) {
 
             // Set the iframe height to just under the window height.
             // leave room for the navbar, padding, margins, etc.
@@ -112,7 +112,82 @@ angular.module('egCoreMod')
                     // open a user account
                     new_patron_tab : function(tab_info, usr_info) {
                         open_tab('/circ/patron/' + usr_info.id + '/checkout');
-                    }  
+                    },
+
+                    get_barcode_and_settings_async : function(barcode, only_settings) {
+                        if (!barcode) return $q.reject();
+                        var deferred = $q.defer();
+
+                        var barcode_promise = $q.when(barcode);
+                        if (!only_settings) {
+
+                            // first verify / locate the barcode
+                            barcode_promise = egCore.net.request(
+                                'open-ils.actor',
+                                'open-ils.actor.get_barcodes',
+                                egCore.auth.token(), 
+                                egCore.auth.user().ws_ou(), 'actor', barcode
+                            ).then(function(resp) {
+
+                                if (!resp || egCore.evt.parse(resp) || !resp.length) {
+                                    console.error('user not found: ' + barcode);
+                                    deferred.reject();
+                                    return null;
+                                } 
+
+                                resp = resp[0];
+                                return barcode = resp.barcode;
+                            });
+                        }
+
+                        barcode_promise.then(function(barcode) {
+                            if (!barcode) return;
+
+                            return egCore.net.request(
+                                'open-ils.actor',
+                                'open-ils.actor.user.fleshed.retrieve_by_barcode',
+                                egCore.auth.token(), barcode);
+
+                        }).then(function(user) {
+                            if (!user) return null;
+
+                            if (e = egCore.evt.parse(user)) {
+                                console.error('user fetch failed : ' + e.toString());
+                                deferred.reject();
+                                return null;
+                            }
+
+                            // copied more or less directly from XUL menu.js
+                            var settings = {};
+                            for(var i = 0; i < user.settings().length; i++) {
+                                settings[user.settings()[i].name()] = 
+                                    JSON2js(user.settings()[i].value());
+                            }
+
+                            if(!settings['opac.default_phone'] && user.day_phone()) 
+                                settings['opac.default_phone'] = user.day_phone();
+                            if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') 
+                                settings['opac.hold_notify'] = 'email:phone';
+
+                            // Taken from patron/util.js format_name
+                            // FIXME: I18n
+                            var patron_name = 
+                                ( user.prefix() ? user.prefix() + ' ' : '') +
+                                user.family_name() + ', ' +
+                                user.first_given_name() + ' ' +
+                                ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
+                                ( user.suffix() ? user.suffix() : '');
+
+                            deferred.resolve({
+                                "barcode": barcode, 
+                                "settings" : settings, 
+                                "user_email" : user.email(), 
+                                "patron_name" : patron_name
+                            });
+                        });
+
+                        return deferred.promise;
+                    }
                 }
 
                 if ($scope.handlers) {