Angular selfcheck WIP : holds
authorBill Erickson <berickxx@gmail.com>
Thu, 27 Oct 2016 21:40:26 +0000 (17:40 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 11 Aug 2017 19:20:25 +0000 (15:20 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/circ/selfcheck/index.tt2
Open-ILS/src/templates/staff/circ/selfcheck/t_holds.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/circ/selfcheck/t_items.tt2
Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js

index c6c2261..e6b1bce 100644 (file)
@@ -63,7 +63,7 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
     </fieldset>
     <fieldset>
       <legend>[% l('Holds') %]</legend>
-      <div>[% l('You have [_1] item(s) ready for pickup', '{{counts("hold_ready")}}') %]</div>
+      <div>[% l('You have [_1] item(s) ready for pickup', '{{counts("ready_hold")}}') %]</div>
       <div>[% l('You have [_1] total holds', '{{counts("total_hold")}}') %]</div>
       <div><button class="btn btn-success" ng-click="show_pane('holds')">
         [% l('View Holds') %]</button></div>
diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/t_holds.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/t_holds.tt2
new file mode 100644 (file)
index 0000000..38b9852
--- /dev/null
@@ -0,0 +1,22 @@
+
+<div class="row">
+  <div class="col-md-1"></div>
+  <div class="col-md-3">[% l('Title') %]</div>
+  <div class="col-md-3">[% l('Author') %]</div>
+  <div class="col-md-2">[% l('Status') %]</div>
+</div>
+
+<div class="row" 
+  ng-repeat="hold in holds | orderBy:'queue_position':reverse">
+  <div class="col-md-1">
+    <img src="/opac/extras/ac/jacket/small/r/{{hold.mvr.doc_id()}}"/>
+  </div>
+  <div class="col-md-3">{{hold.mvr.title()}}</div>
+  <div class="col-md-3">{{hold.mvr.author()}}</div>
+  <div class="col-md-2">
+    <span ng-if="hold.status == 4">[% l('Ready for Pickup') %]</span>
+    <span ng-if="hold.status != 4">[% l('#[_1] in line with [_2] copies', 
+      '{{hold.queue_position}}', '{{hold.potential_copies}}') %]</span>
+  </div>
+</div>
+
index 55511c6..f96e963 100644 (file)
@@ -7,7 +7,7 @@
   <div class="col-md-2">[% l('Due Date') %]</div>
 </div>
 
-<div class="row" ng-repeat="circ in circs track by circ.circ.id()">
+<div class="row" ng-repeat="circ in circs | orderBy:'circ.due_date()':reverse">
   <div class="col-md-1">
     <img src="/opac/extras/ac/jacket/small/r/{{circ.record.doc_id()}}"/>
   </div>
index beb3a21..347039b 100644 (file)
@@ -72,6 +72,12 @@ angular.module('egSelfCheckApp',
         resolve : resolver
     });
 
+    $routeProvider.when('/circ/selfcheck/holds', {
+        templateUrl: './circ/selfcheck/t_holds',
+        controller: 'HoldsCtrl',
+        resolve : resolver
+    });
+
     $routeProvider.otherwise({redirectTo : '/circ/selfcheck/login'});
 })
 
@@ -97,11 +103,13 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial
 
         session_circ_count : 0,
         total_circ_count : 0,
-        hold_ready_count : 0,
+        ready_hold_count : 0,
         total_hold_count : 0,
-
     };
 
+    service.get_counts = function() {
+    }
+
     // called with each path load
     service.new_path_init = function() {
         if (!service.patron) 
@@ -228,18 +236,38 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial
 
     /* 
      * Returns a notify-stream of open circ blobs.
-     * Resets total circ count to match the server.
      */
     service.get_items_out = function() {
-        service.total_circ_count = 0;
         return egCore.net.request(
             'open-ils.circ',
             'open-ils.circ.actor.user.checked_out',
             egCore.auth.token(), service.patron.id()
-        ).then(null, null, function(circ_blob) {
-            service.total_circ_count++;
-            return circ_blob;
+        );
+    }
+
+    /*
+     * Returns a notify-stream of open hold blobs
+     */
+    service.get_holds = function() {
+        // Don't rely on promise chaining when the final outcome is
+        // a stream of notify()'s, since resolve() data from earlier
+        // promises will leak into the notify() stream.
+        var deferred = $q.defer(); 
+
+        egCore.net.request(
+            'open-ils.circ',
+            'open-ils.circ.holds.id_list.retrieve',
+            egCore.auth.token(), service.patron.id()
+
+        ).then(function(ids) {
+            egCore.net.request(
+                'open-ils.circ',
+                'open-ils.circ.hold.details.batch.retrieve',
+                egCore.auth.token(), ids
+            ).then(deferred.resolve, deferred.reject, deferred.notify)
         });
+
+        return deferred.promise;
     }
 
     return service;
@@ -340,4 +368,15 @@ function($scope,  $q,  $location , egCore,  scSvc) {
 
 }])
 
+.controller('HoldsCtrl',
+       ['$scope','$q','$location','egCore','scSvc',
+function($scope,  $q,  $location , egCore,  scSvc) {
+    scSvc.new_path_init();
+    $scope.scanbox.focus = true;
+    $scope.holds = [];
+
+    scSvc.get_holds().then(null, null, 
+        function(hold_blob) { $scope.holds.push(hold_blob) });
+
+}])