LP#1402797 browser client noncat circ display
authorBill Erickson <berickxx@gmail.com>
Wed, 31 Dec 2014 21:05:53 +0000 (16:05 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Feb 2015 17:03:08 +0000 (12:03 -0500)
Adds a new tab to the patron items out page for Non-Cataloged
Circulations.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js

index 5c87466..ca3eef1 100644 (file)
@@ -1,6 +1,6 @@
 <!-- items out list -->
 
-<div ng-if="show_alt_circs">
+<div>
   <!-- only show the main vs. alt circ list tabs if the alt
       circ list is meant to display -->
   <ul class="nav nav-tabs">
@@ -9,20 +9,40 @@
         [% l('Items Checked Out') %] ({{main_list.length}})
       </a>
     </li>
-    <li ng-class="{active : items_out_display == 'alt'}">
+    <li ng-if="show_alt_circs" ng-class="{active : items_out_display == 'alt'}">
       <a href ng-click="show_alt_list()">
         [% l('Other/Special Circulations') %] ({{alt_list.length}})
       </a>
     </li>
+    <li ng-class="{active : items_out_display == 'noncat'}">
+      <a href ng-click="show_noncat_list()">
+        [% l('Non-Cataloged Circulations') %] ({{noncat_list.length}})
+      </a>
+    </li>
   </ul>
 </div>
-<div ng-if="!show_alt_circs" class="strong-text-2">
-  [% l('Items Checked Out') %]
-</div>
 
 <div class="tab-content">
   <div class="tab-pane active">
+
+<eg-grid
+  ng-if="items_out_display == 'noncat'"
+  idl-class="ancc"
+  id-field="id"
+  features="-sort,-multisort"
+  items-provider="gridDataProvider"
+  persist-key="circ.patron.items_out.noncat">
+
+  <eg-grid-field label="[% l('Circ ID') %]" path='id'></eg-grid-field>
+  <eg-grid-field label="[% l('Item Type') %]" path='item_type.name'></eg-grid-field>
+  <eg-grid-field label="[% l('Checkout Library') %]" path='circ_lib.shortname'></eg-grid-field>
+  <eg-grid-field label="[% l('Checkout Date') %]" path='circ_time' dateformat='short'></eg-grid-field>
+  <eg-grid-field label="[% l('Due Date') %]" path='duedate' dateformat='short'></eg-grid-field>
+  <eg-grid-field label="[% l('Checkout Staff') %]" path='staff.usrname'></eg-grid-field>
+</eg-grid>
+
 <eg-grid
+  ng-if="items_out_display != 'noncat'"
   idl-class="circ"
   id-field="id"
   features="-sort,-multisort"
@@ -71,5 +91,7 @@
   <eg-grid-field path="target_copy.call_number.record.*" hidden></eg-grid-field>
   <eg-grid-field path="target_copy.call_number.record.simple_record.*" hidden></eg-grid-field>
 </eg-grid>
+</div>
+
   </div>
 </div>
index 7558251..f8f4dd8 100644 (file)
@@ -9,7 +9,16 @@ angular.module('egPatronApp')
         'egGridDataProvider','$modal','egCirc','egConfirmDialog','egBilling',
 function($scope,  $q,  $routeParams,  egCore , egUser,  patronSvc , 
          egGridDataProvider , $modal , egCirc , egConfirmDialog , egBilling) {
-    $scope.initTab('items_out', $routeParams.id);
+
+    // list of noncatatloged circulations. Define before initTab to 
+    // avoid any possibility of race condition, since they are loaded
+    // during init, but may be referenced before init completes.
+    $scope.noncat_list = [];
+
+    $scope.initTab('items_out', $routeParams.id).then(function() {
+        // sort inline to support paging
+        $scope.noncat_list = patronSvc.noncat_ids.sort();
+    });
 
     // cache of circ objects for grid display
     patronSvc.items_out = [];
@@ -60,6 +69,13 @@ function($scope,  $q,  $routeParams,  egCore , egUser,  patronSvc ,
         provider.refresh();
     }
 
+    $scope.show_noncat_list = function() {
+        // don't need a full reset_page() to swap tabs
+        $scope.items_out_display = 'noncat';
+        patronSvc.items_out = [];
+        provider.refresh();
+    }
+
     // Reload the user to pick up changes in items out, fines, etc.
     // Reload circs since the contents of the main vs. alt list may
     // have changed.
@@ -112,6 +128,35 @@ function($scope,  $q,  $routeParams,  egCore , egUser,  patronSvc ,
         });
     }
 
+    function fetch_noncat_circs(id_list, offset, count) {
+        if (!id_list.length) return $q.when();
+
+        return egCore.pcrud.search('ancc', {id : id_list},
+            {   flesh : 1,
+                flesh_fields : {ancc : ['item_type','staff']},
+                limit  : count,
+                offset : offset,
+                // we need an order-by to support paging
+                order_by : {circ : ['circ_time']} 
+
+        }).then(null, null, function(noncat_circ) {
+
+            // calculate the virtual due date from the item type duration
+            var seconds = egCore.date.intervalToSeconds(
+                noncat_circ.item_type().circ_duration());
+            var d = new Date(Date.parse(noncat_circ.circ_time()));
+            d.setSeconds(d.getSeconds() + seconds);
+            noncat_circ.duedate(d.toISOString());
+
+            // local flesh org unit
+            noncat_circ.circ_lib(egCore.org.get(noncat_circ.circ_lib()));
+
+            patronSvc.items_out.push(noncat_circ); // cache it
+            return noncat_circ;
+        });
+    }
+
+
     // decide which list each circ belongs to
     function promote_circs(list, display_code, open) {
         if (open) {                                                    
@@ -167,6 +212,11 @@ function($scope,  $q,  $routeParams,  egCore , egUser,  patronSvc ,
                 patronSvc.items_out, offset, count);
         }
 
+        if ($scope.items_out_display == 'noncat') {
+            // if there are any noncat circ IDs, we already have them
+            return fetch_noncat_circs(id_list, offset, count);
+        }
+
         // See if we have the circ IDs for this range already loaded.
         // this would happen navigating to a subsequent page.
         if (id_list[offset]) {