webstaff: Default receiving callnumber to last created; UI cleanup
authorMike Rylander <mrylander@gmail.com>
Tue, 23 May 2017 14:48:37 +0000 (10:48 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:48 +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/directives/view-items-grid.js
Open-ILS/web/js/ui/default/staff/serials/services/core.js

index 3f78a0c..9beaf9c 100644 (file)
@@ -2,18 +2,12 @@
 <div class="modal-header">
     <button type="button" class="close" ng-click="cancel()" 
         aria-hidden="true">&times;</button>
-    <h4 class="modal-title">{{ title || "[% l('Construct new holding code') %]" }}</h4>
+    <h4 class="modal-title">{{ title || "[% l('Receive items') %]" }}</h4>
 </div>
 
 <div class="modal-body">
   <div class="row">
     <div class="col-md-2">
-      <b>[% l('Receive date') %]</b>
-    </div>
-    <div class="col-md-2">
-      <eg-date-input ng-model="receive_date"></eg-date-input>
-    </div>
-    <div class="col-md-2">
       <label class="checkbox-inline">
         <input type="checkbox" ng-model="barcode_items">[% l('Barcode Items') %]
       </label>
@@ -38,6 +32,9 @@
     <div class="col-md-2">
       <b>[% l('Library : Distribution/Stream') %]</b>
     </div>
+    <div class="col-md-1">
+      <b>[% l('Issuance') %]</b>
+    </div>
     <div class="col-md-2">
       <b>[% l('Copy location') %]</b>
     </div>
@@ -50,7 +47,7 @@
   </div>
 
   <div class="row">
-    <div class="col-md-2"></div>
+    <div class="col-md-3"></div>
     <div class="col-md-2">
       <select
         class="form-control"
@@ -88,6 +85,9 @@
     <div class="col-md-2">
       {{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">
       <select
         ng-disabled="bind_or_none($index)"
index 19644f9..af6b38a 100644 (file)
@@ -261,22 +261,6 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
 
         if (!list.length) return $q.reject();
 
-        var donor_unit_ids = {};
-        angular.forEach(list, function (item) {
-            if (item.unit()) donor_unit_ids[item.unit().id()] = 1;
-            if (do_barcode) item.unit(-1);
-            if (bind) item.unit(-2);
-        });
-
-        var method; var success_label;
-        if (mode == 'receive') {
-            method = 'open-ils.serial.receive_items';
-            success_label = 'received';
-        } else { // bind mode
-            method = 'open-ils.serial.bind_items';
-            success_label = 'bound';
-        } 
-
         // deal with locations and circ mods for *NEW* units
         var copy_locations = {};
         var circ_mods = {};
@@ -299,7 +283,6 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                 controller:
                 ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
 
-                    $scope.receive_date = new Date();
                     $scope.barcode_items = do_barcode;
                     $scope.force_bind = bind;
                     $scope.bind = bind;
@@ -307,52 +290,27 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                     $scope.acn_list = [];
                     $scope.acpl_list = [];
 
-                    var acpl_hash = {};
-                    var acn_hash = {};
-
-                    $scope.bind_or_none = function (index) {
-                        return !$scope.barcode_items || ($scope.bind && index > 0);
-                    }
-
-                    $scope.focus_next_barcode = function (index) {
-                        index++;
-                        $('#item_barcode_'+index).focus().select();
-                    }
-
-                    $scope.$watch('auto_barcodes', function (n) {
-                        var bc = '@@AUTO';
-                        if (!n) bc = '';
-
-                        angular.forEach($scope.items, function (i) {
-                            var _barcode = i._barcode;
-                            i._barcode = bc || i._old_barcode;
-                            i._old_barcode = _barcode;
-                        });
-                    });
-
-                    $scope.apply_template_overrides = function (e) {
-                        if ($scope.selected_call_number) {
-                            angular.forEach($scope.items, function (i) {
-                                i._call_number = $scope.selected_call_number;
-                            });
-                        }
-                        if ($scope.selected_circ_mod) {
-                            angular.forEach($scope.items, function (i) {
-                                i._circ_mod = $scope.selected_circ_mod;
-                            });
-                        }
-                        if ($scope.selected_copy_location) {
-                            angular.forEach($scope.items, function (i) {
-                                i._copy_location = $scope.selected_copy_location;
-                            });
-                        }
-                    }
-
                     var pile_o_promises = [$q.when()];
                     // let's gather what we need...
                     angular.forEach(list, function (i) {
-                        if (i.stream().distribution()[mode + '_call_number']())
-                            i._call_number = i.stream().distribution()[mode + '_call_number']().label();
+                        if (i.unit()) {
+                            i._barcode = i.unit().barcode();
+                            pile_o_promises.push(
+                                egCore.pcrud.retrieve(
+                                    'acn', i.unit().call_number()
+                                ).then(function(cn){ i._call_number = cn.label() })
+                            );
+                        } else {
+                            if (i.stream().distribution()[mode + '_call_number']()) {
+                                i._call_number = i.stream().distribution()[mode + '_call_number']().label();
+                            } else {
+                                pile_o_promises.push(
+                                    egSerialsCoreSvc.fetchLastCallnumber(
+                                        i.stream().distribution().holding_lib().id()
+                                    ).then(function(cn){ i._call_number = cn.label() })
+                                );
+                            }
+                        }
 
                         if (i.stream().distribution()[mode + '_unit_template']()) {
                             i._copy_location = i.stream().distribution()[mode + '_unit_template']().location();
@@ -389,6 +347,56 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                         console.log('receive data collected');
                     });
 
+                    $scope.bind_or_none = function (index) {
+                        return !$scope.barcode_items || ($scope.bind && index > 0);
+                    }
+
+                    $scope.focus_next_barcode = function (index) {
+                        index++;
+                        $('#item_barcode_'+index).focus().select();
+                    }
+
+                    $scope.apply_template_overrides = function (e) {
+                        if ($scope.selected_call_number) {
+                            angular.forEach($scope.items, function (i) {
+                                i._call_number = $scope.selected_call_number;
+                            });
+                        }
+                        if ($scope.selected_circ_mod) {
+                            angular.forEach($scope.items, function (i) {
+                                i._circ_mod = $scope.selected_circ_mod;
+                            });
+                        }
+                        if ($scope.selected_copy_location) {
+                            angular.forEach($scope.items, function (i) {
+                                i._copy_location = $scope.selected_copy_location;
+                            });
+                        }
+                    }
+
+                    $scope.$watch('barcode_items', function (n,o) {
+                        if (n === undefined || n == o) return;
+                        do_barcode = n;
+                    });
+
+                    $scope.$watch('bind', function (n,o) {
+                        if (n === undefined || n == o) return;
+                        bind = n;
+                    });
+                        
+                    $scope.$watch('auto_barcodes', function (n,o) {
+                        if (n === undefined || n == o) return;
+
+                        var bc = '@@AUTO';
+                        if (!n) bc = '';
+
+                        angular.forEach($scope.items, function (i) {
+                            var _barcode = i._barcode;
+                            i._barcode = bc || i._old_barcode;
+                            i._old_barcode = _barcode;
+                        });
+                    });
+
                     $scope.ok = function(items) { $uibModalInstance.close(items) }
                     $scope.cancel = function () { $uibModalInstance.dismiss() }
                 }]
@@ -399,7 +407,11 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
 
         current_promise.then(function (items) {
 
+            var donor_unit_ids = {};
             angular.forEach(items, function(i, index) {
+                if (item.unit()) donor_unit_ids[item.unit().id()] = 1;
+                if (do_barcode) item.unit(-1);
+                if (bind) item.unit(-2);
                 copy_locations[i.id()] = i._copy_location;
                 circ_mods[i.id()] = i._circ_mod;
                 call_numbers[i.id()] = i._call_number || 'DEFAULT';
@@ -407,6 +419,13 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                 if (bind && index > 0) barcodes[i.id()] = items[0]._barcode;
             });
 
+            var method;
+            if (mode == 'receive') {
+                method = 'open-ils.serial.receive_items';
+            } else { // bind mode
+                method = 'open-ils.serial.bind_items';
+            } 
+
             return egCore.net.request(
                 'open-ils.serial', method,
                 egCore.auth.token(), items, barcodes, call_numbers, donor_unit_ids,
index ec60fce..edf250e 100644 (file)
@@ -126,6 +126,19 @@ function(egCore , orderByFilter , $q , $filter , $uibModal) {
         });
     }
 
+    // fetch subscription, distributions, streams, captions,
+    // and notes associated with the indicated bib
+    service.fetchLastCallnumber = function(contextOrg) {
+        return egCore.pcrud.search('acn', {
+                record : service.bibId,
+                owning_lib : contextOrg
+            }, { order_by : [{class:'acn',field:'create_date',direction:'desc'}], limit : 1 },
+            { atomic : true }
+        ).then(function(list) {
+            return $q.when(list[0]);
+        });
+    }
+
     service.fetchItemsForSubPaged = function(subId,filter,offset,limit) {
         return service.fetchItemsForSub(
             subId,