checkout repairs for data consistency w/ egCirc
authorBill Erickson <berick@esilibrary.com>
Mon, 30 Jun 2014 19:44:05 +0000 (15:44 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 30 Jun 2014 19:44:05 +0000 (15:44 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/src/templates/staff/circ/renew/t_renew.tt2
Open-ILS/src/templates/staff/circ/share/t_circ_exists_dialog.tt2
Open-ILS/src/templates/staff/share/print_templates/t_checkout.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

index b64c468..945f2db 100644 (file)
 
 <eg-grid
   id-field="index"
-  features="-display,-sort,-multisort"
-  main-label="[% l('Checkouts') %]"
+  features="-sort,-multisort"
   items-provider="gridDataProvider"
+  grid-controls="gridControls"
   persist-key="circ.patron.checkout">
-  <eg-grid-field label="[% l('Barcode') %]"     
-    path='copy_barcode' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Circ ID') %]"     
-    path='payload.circ.id' visible></eg-grid-field>
+
+  <eg-grid-field label="[% l('Alert Msg') %]"   
+    path="acp.alert_message"></eg-grid-field>
+
+  <eg-grid-field label="[% l('Balance Owed') %]"     
+    path='mbts.balance_owed'></eg-grid-field>
+
+  <eg-grid-field label="[% l('Barcode') %]" path="acp_barcode">
+    <!-- FIXME: ng-if / ng-disabled not working since the contents 
+        are $interpolate'd and not $compile'd.
+        I want to hide / disable the href when there is no acp ID 
+    -->
+    <a href="./cat/item/{{item.acp.id()}}/summary" target="_self">
+      {{item.copy_barcode}}
+    </a>
+  </eg-grid-field>
+
+  <eg-grid-field label="[% l('Bill #') %]"     
+    path='circ.id'></eg-grid-field>
+
+  <eg-grid-field label="[% l('Call Number') %]" 
+    path="acn.label"></eg-grid-field>
+
   <eg-grid-field label="[% l('Due Date') %]"    
-    path='payload.circ.due_date' 
-    visible datatype="timestamp" dateformat="short"></eg-grid-field>
-  <eg-grid-field label="[% l('Response') %]"    
-    path='textcode' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Title') %]"       
-    path='payload.record.title' visible></eg-grid-field>
+    path='circ.due_date' dateformat='short'></eg-grid-field>
+
+  <eg-grid-field label="[% l('Family Name') %]"    
+    path='au.family_name'></eg-grid-field>
+
+  <eg-grid-field label="[% l('Location') %]" 
+    path='acp.location.name'> </eg-grid-field>
+
+  <eg-grid-field label="[% l('Remaining Renewals') %]" 
+    path='circ.renewal_remaining'></eg-grid-field>
+
+  <eg-grid-field label="[% l('Title') %]" path="title">
+    <a target="_self" href="[% ctx.base_path %]/opac/record/{{record.doc_id()}}">
+      {{item.title}}
+    </a>
+  </eg-grid-field>
+
   <eg-grid-field label="[% l('Author') %]"      
-    path='payload.record.author' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Call Number') %]" 
-    path='payload.copy.call_number.label' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Alert Msg') %]"   
-    path='payload.copy.alert_message' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Noncat #') %]"    
-    path='noncat_count' visible></eg-grid-field>
+    path="author" hidden></eg-grid-field>
+
+  <eg-grid-field path="circ.*" parent-idl-class="circ" hidden></eg-grid-field>
+  <eg-grid-field path="acp.*" parent-idl-class="acp" hidden></eg-grid-field>
+  <eg-grid-field path="acn.*" parent-idl-class="acn" hidden></eg-grid-field>
+  <eg-grid-field path="record.*" parent-idl-class="mvr" hidden></eg-grid-field>
+  <eg-grid-field path="mbts.*" parent-idl-class="mbts" hidden></eg-grid-field>
+  <eg-grid-field path="au.*" parent-idl-class="au" hidden></eg-grid-field>
 </eg-grid>
 
 <div class="flex-row pad-vert">
index ee38361..c2880c1 100644 (file)
@@ -43,7 +43,6 @@
 <eg-grid
   id-field="index"
   features="-sort,-multisort"
-  main-label="[% l('Items Checked In') %]"
   items-provider="gridDataProvider"
   grid-controls="gridControls"
   persist-key="circ.renew">
index f7516f0..3a8b5d1 100644 (file)
@@ -7,10 +7,18 @@
         <h4 class="modal-title">[% l('Open Circulation') %]</h4>
       </div>
       <div class="modal-body">
-[% |l("{{circDate | date:'shortDate'}}") %]
-There is an open circulation on the requested item.  
-This copy was checked out by another patron on [_1].
-[% END %]
+        <div ng-if="sameUser">
+          [% |l("{{circDate | date:'shortDate'}}") %]
+          There is an open circulation on the requested item.  
+          This item was already checked out to this user on [_1].
+          [% END %]
+        </div>
+        <div ng-if="!sameUser">
+          [% |l("{{circDate | date:'shortDate'}}") %]
+          There is an open circulation on the requested item.  
+          This copy was checked out by another patron on [_1].
+          [% END %]
+        </div>
       </div>
       <div class="modal-footer">
         <input type="submit" class="btn btn-primary" 
index 496fd4c..1f1218e 100644 (file)
@@ -3,11 +3,11 @@
   <div>[% l('You checked out the following items:') %]</div>
   <hr/>
   <ol>
-    <li ng-repeat="circ in circulations">
-      <div>{{circ.title}}</div>
+    <li ng-repeat="checkout in circulations">
+      <div>{{checkout.title}}</div>
       <div>[% l('Barcode: [_1] Due: [_2]', 
-        '{{circ.target_copy.barcode}}',
-        '{{circ.due_date | date:"short"}}') %]</div>
+        '{{checkout.copy.barcode}}',
+        '{{checkout.circ.due_date | date:"short"}}') %]</div>
     </li>
   </ol>
   <hr/>
index 94314a2..5be1d4b 100644 (file)
@@ -116,15 +116,13 @@ function($scope , $q , $modal , $routeParams , egCore , egUser , patronSvc ,
                 // each checkout.
                 patronSvc.patron_stats.checkouts.out++
 
-                // TODO: munge from egCirc
-    
-                munge_checkout_resp(co_resp);
-    
                 // copy the response event into the original grid row item
                 // note: angular.copy clobbers the destination
-                angular.forEach(co_resp.evt, function(v, k) {
-                    row_item[k] = v;
+                row_item.evt = co_resp.evt;
+                angular.forEach(co_resp.data, function(val, key) {
+                    row_item[key] = val;
                 });
+                munge_checkout_resp(co_resp, row_item);
             },
             function() {
                 // Circ was rejected somewhere along the way.
@@ -148,26 +146,14 @@ function($scope , $q , $modal , $routeParams , egCore , egUser , patronSvc ,
         });
     }
 
-    // move some stuff around so it will play nice w/ the template
-    function munge_checkout_resp(co_resp) {
-        var payload = co_resp.evt.payload;
+    // add some checkout-specific additions for display
+    function munge_checkout_resp(co_resp, row_item) {
         var params = co_resp.params;
-
-        if (!payload) return;
-
-        if (params.precat) {
-            payload.record = {
-                title  : params.dummy_title,
-                author : params.dummy_author,
-                isbn   : params.dummy_isbn
-            };
-        } else if (params.noncat) {
-            payload.record = {
-                title : egCore.env.cnct.map[params.noncat_type].name()
-            };
-            co_resp.evt.noncat_count = params.noncat_count;
-            payload.circ = new egCore.idl.circ();
-            payload.circ.due_date(payload.noncat_circ.duedate());
+        if (params.noncat) {
+            row_item.title = egCore.env.cnct.map[params.noncat_type].name();
+            row_item.noncat_count = params.noncat_count;
+            row_item.circ = new egCore.idl.circ();
+            row_item.circ.due_date(co_resp.evt.payload.noncat_circ.duedate());
         }
     }
 
@@ -177,9 +163,15 @@ function($scope , $q , $modal , $routeParams , egCore , egUser , patronSvc ,
         if ($scope.checkouts.length == 0) return $q.when();
 
         angular.forEach($scope.checkouts, function(co) {
-            var circ = egCore.idl.toHash(co.payload.circ);
-            circ.title = co.payload.record.title;
-            print_data.circulations.push(circ);
+            if (co.circ) {
+                print_data.circulations.push({
+                    circ : egCore.idl.toHash(co.circ),
+                    copy : egCore.idl.toHash(co.acp),
+                    call_number : egCore.idl.toHash(co.acn),
+                    title : co.title,
+                    author : co.author
+                })
+            };
         });
 
         return egCore.print.print({
index ca5b311..a18f050 100644 (file)
@@ -770,24 +770,23 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) {
     }
 
     service.circ_exists_dialog = function(evt, params, options) {
+
+        var openCirc = evt.payload.old_circ;
+        var sameUser = openCirc.usr() == params.patron_id;
+        
         return $modal.open({
             templateUrl: './circ/share/t_circ_exists_dialog',
             controller: 
-                       ['$scope','$modalInstance','openCirc',
-                function($scope , $modalInstance , openCirc) {
+                       ['$scope','$modalInstance',
+                function($scope , $modalInstance) {
                 $scope.circDate = openCirc.xact_start();
+                $scope.sameUser = sameUser;
                 $scope.ok = function() { $modalInstance.close() }
                 $scope.cancel = function($event) { 
                     $modalInstance.dismiss();
                     $event.preventDefault(); // form, avoid calling ok();
                 }
-            }],
-            resolve : {
-                // fetch the conflicting open circulation
-                openCirc : function() {
-                    return service.last_copy_circ(evt.payload.copy.id());
-                }
-            }
+            }]
         }).result.then(
             function() {