webstaff: make bind/receive smarter; allow individual item receive/bind selection...
authorMike Rylander <mrylander@gmail.com>
Thu, 25 May 2017 17:16:02 +0000 (13:16 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:50 +0000 (12:06 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/staff/serials/t_batch_receive.tt2
Open-ILS/web/js/ui/default/staff/serials/services/core.js

index 409f62b..17559e1 100644 (file)
@@ -2,7 +2,8 @@
 <div class="modal-header">
     <button type="button" class="close" ng-click="cancel()" 
         aria-hidden="true">&times;</button>
-    <h4 class="modal-title">{{ title || "[% l('Receive items') %]" }}</h4>
+    <h4 ng-show="force_bind" class="modal-title">{{ title || "[% l('Bind items') %]" }}</h4>
+    <h4 ng-show="!force_bind" class="modal-title">{{ title || "[% l('Receive items') %]" }}</h4>
 </div>
 
 <div class="modal-body">
   </div>
 
   <div class="row">
-    <div class="col-md-2">
+    <div class="col-md-3">
       <b>[% l('Library : Distribution/Stream') %]</b>
     </div>
     <div class="col-md-1">
       <b>[% l('Issuance') %]</b>
     </div>
-    <div class="col-md-2">
+    <div class="col-md-1">
       <b>[% l('Copy location') %]</b>
     </div>
-    <div class="col-md-2">
+    <div class="col-md-1">
       <b>[% l('Call number') %]</b>
     </div>
     <div class="col-md-2">
       <b>[% l('Circulation modifier') %]</b>
     </div>
-    <div class="col-md-2"></div>
+    <div class="col-md-1">
+      <b>[% l('Barcode') %]</b>
+    </div>
+    <div class="col-md-1">
+      <b ng-show="!bind">[% l('Receive') %]</b>
+      <b ng-show="bind">[% l('Include') %]</b>
+    </div>
     <div class="col-md-1">
       <b>[% l('Routing List') %]</b>
     </div>
   </div>
 
   <div class="row">
-    <div class="col-md-3"></div>
-    <div class="col-md-2">
+    <div class="col-md-4"></div>
+    <div class="col-md-1">
       <select
         class="form-control"
         ng-model="selected_copy_location"
@@ -65,7 +72,7 @@
         <option value="">[% l('Template default') %]</option>
       </select>
     </div>
-    <div class="col-md-2">
+    <div class="col-md-1">
       <select
         class="form-control"
         ng-model="selected_call_number"
@@ -73,7 +80,7 @@
         <option value="">[% l('Default') %]</option>
       </select>
     </div>
-    <div class="col-md-2">
+    <div class="col-md-1">
       <select
         class="form-control"
         ng-model="selected_circ_mod"
@@ -81,7 +88,8 @@
         <option value="">[% l('Template default') %]</option>
       </select>
     </div>
-    <div class="col-md-2">
+    <div class="col-md-4"></div>
+    <div class="col-md-1">
       <div class="btn btn-primary" ng-click="apply_template_overrides()">[% l('Apply') %]</div>
     </div>
   </div>
   </div>
 
   <div class="row" ng-repeat="item in items">
-    <div class="col-md-2">
+    <div class="col-md-3">
       {{item.stream().distribution().holding_lib().name()}}: {{item.stream().distribution().label()}}/{{item.stream().routing_label()}}
     </div>
     <div class="col-md-1">
       {{item.issuance().label()}}
     </div>
-    <div class="col-md-2">
+    <div class="col-md-1">
       <select
-        ng-disabled="bind_or_none($index)"
+        ng-disabled="!item._receive || bind_or_none($index)"
         class="form-control"
         ng-model="item._copy_location"
         ng-options="l.id as l.name for l in acpl_list | orderBy:'name'">
         <option value="">[% l('Template default') %]</option>
       </select>
     </div>
-    <div class="col-md-2">
-      <input ng-disabled="bind_or_none($index)" class="form-control"
-             ng-model="item._call_number" type="text"/>
+    <div class="col-md-1">
+      <input ng-disabled="!item._receive || bind_or_none($index)" class="form-control"
+             ng-required="item._receive && !bind_or_none($index)" ng-model="item._call_number" type="text"/>
     </div>
-    <div class="col-md-2">
+    <div class="col-md-1">
       <select
-        ng-disabled="bind_or_none($index)"
+        ng-disabled="!item._receive || bind_or_none($index)"
         class="form-control"
         ng-model="item._circ_mod"
         ng-options="l.code as l.name for l in ccm_list | orderBy:'name'">
       </select>
     </div>
     <div class="col-md-2">
-      <input ng-disabled="bind_or_none($index)" class="form-control" focus-me="$first"
+      <input ng-disabled="!item._receive || bind_or_none($index)" class="form-control" focus-me="$first"
              ng-model="item._barcode" type="text" id="item_barcode_{{$index}}"
-             ng-required="!bind_or_none($index)" eg-enter="focus_next_barcode($index)"/>
+             ng-required="item._receive && !bind_or_none($index)" eg-enter="focus_next_barcode($index)"/>
+    </div>
+    <div class="col-md-1">
+      <input type="checkbox" ng-model="item._receive"/>
     </div>
     <div class="col-md-1">
-      <input type="checkbox" ng-disabled="cannot_print($index)" ng-model="item._print_routing_list"/>
+      <input type="checkbox" ng-disabled="!item._receive || cannot_print($index)" ng-model="item._print_routing_list"/>
     </div>
   </div>
 
index de958be..0a02ffe 100644 (file)
@@ -801,6 +801,8 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
 
                         if ($scope.print_routing_lists && !$scope.cannot_print(index))
                             i._print_routing_list = true;
+
+                        i._receive = true;
                     });
 
                     pile_o_promises.push(egCore.pcrud.search(
@@ -887,6 +889,19 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
 
         last_promise.then(function (items) {
 
+            var method;
+            if (mode == 'receive') {
+                method = 'open-ils.serial.receive_items';
+                items = items.filter(function(i){return i._receive});
+            } else if ( mode == 'bind') {
+                method = 'open-ils.serial.bind_items';
+                items = items.filter(function(i){return i._receive});
+            } else if ( mode == 'reset') {
+                method = 'open-ils.serial.reset_items';
+            } 
+
+            if (!items.length) return $q.reject();
+
             var donor_unit_ids = {};
             angular.forEach(items, function(i, index) {
                 if (i.unit()) donor_unit_ids[i.unit().id()] = 1;
@@ -899,15 +914,6 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                 if (bind && index > 0) barcodes[i.id()] = items[0]._barcode;
             });
 
-            var method;
-            if (mode == 'receive') {
-                method = 'open-ils.serial.receive_items';
-            } else if ( mode == 'bind') {
-                method = 'open-ils.serial.bind_items';
-            } else if ( mode == 'reset') {
-                method = 'open-ils.serial.reset_items';
-            } 
-
             return egCore.net.request(
                 'open-ils.serial', method,
                 egCore.auth.token(), items, barcodes, call_numbers, donor_unit_ids,