serials: Use basic combo box for callnumber affixes; Get callnumbers from distributio...
authorMike Rylander <mrylander@gmail.com>
Thu, 13 Jul 2017 14:07:34 +0000 (10:07 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 13 Jul 2017 14:07:46 +0000 (10:07 -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 78c555c..9ff469e 100644 (file)
       </select>
     </div>
     <div class="col-md-1">
-      <input ng-disabled="!item._receive || bind_or_none($index)" class="form-control" placeholder="[% l('Prefix') %]"
-             ng-model="item._cn_prefix" type="text"/>
+      <eg-basic-combo-box eg-disabled="!item._receive || bind_or_none($index)" list="acnp_labels" selected="item._cn_prefix" placeholder="[% l('Prefix') %]"></eg-basic-combo-box>
       <input ng-disabled="!item._receive || bind_or_none($index)" class="form-control" placeholder="[% l('Label') %]"
              ng-required="item._receive && !bind_or_none($index)" ng-model="item._call_number" type="text"/>
-      <input ng-disabled="!item._receive || bind_or_none($index)" class="form-control" placeholder="[% l('Suffix') %]"
-             ng-model="item._cn_suffix" type="text"/><br/>
+      <eg-basic-combo-box eg-disabled="!item._receive || bind_or_none($index)" list="acns_labels" selected="item._cn_suffix" placeholder="[% l('Suffix') %]"></eg-basic-combo-box>
+      <br/>
     </div>
     <div class="col-md-1">
       <select
index b2ea80b..2d989a5 100644 (file)
@@ -831,6 +831,8 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                     $scope.bind = bind;
                     $scope.items = list;
                     $scope.acn_list = [];
+                    $scope.acnp_labels = [];
+                    $scope.acns_labels = [];
                     $scope.acpl_list = [];
 
                     $scope.cannot_print = function (index) {
@@ -874,9 +876,13 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                     $scope.ok = function(items) { $uibModalInstance.close(items) }
                     $scope.cancel = function () { $uibModalInstance.dismiss() }
 
+                    var dist_libs = {};
                     var pile_o_promises = [$q.when()];
+
                     // let's gather what we need...
                     angular.forEach(list, function (i, index) {
+                        var dlib = i.stream().distribution().holding_lib().id();
+                        dist_libs[dlib] = egCore.org.fullPath(dlib, true);
                         if (i.unit()) {
                             i._barcode = i.unit().barcode();
                             pile_o_promises.push(
@@ -922,6 +928,16 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                         i._receive = true;
                     });
 
+                    // build unique list of orgs from distribution.holding_lib fullPaths
+                    var dist_lib_list = [];
+                    angular.forEach(dist_libs, function (l) {
+                        dist_lib_list = dist_lib_list.concat(l);
+                    });
+                    dist_lib_list = dist_lib_list.filter(function(v,i,s){
+                        return s.indexOf(v) == i;
+                    });
+
+                    // Copy locations only come from the workstation location, same as XUL
                     pile_o_promises.push(egCore.pcrud.search(
                         'acpl',
                         {owning_lib : egCore.org.fullPath(egCore.auth.user().ws_ou(), true)},
@@ -931,15 +947,28 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                         return $q.when();
                     }));
 
+                    // Call numbers, however, come from anywhere the distributions might live
                     pile_o_promises.push(egCore.pcrud.search(
                         'acn',
-                        {deleted : 'f', record : bibId, owning_lib : egCore.org.fullPath(egCore.auth.user().ws_ou(), true)},
+                        {deleted : 'f', record : bibId, owning_lib : dist_lib_list},
                         {flesh : 1, flesh_fields : {acn : ['prefix','suffix']}},{ atomic : true }
                     ).then(function (list) {
                         $scope.acn_list = list.map(function(i){return egCore.idl.toHash(i)});
                         return $q.when();
                     }));
 
+                    // Likewise for prefix and suffix, for combo box
+                    angular.forEach(['acnp','acns'], function (cl) {
+                        pile_o_promises.push(egCore.pcrud.search(
+                            cl,
+                            {owning_lib : dist_lib_list},
+                            {},{ atomic : true }
+                        ).then(function (list) {
+                            $scope[cl+'_labels'] = list.map(function(i){return i.label()});
+                            return $q.when();
+                        }));
+                    });
+
                     pile_o_promises.push(egCore.pcrud.retrieveAll(
                         'ccm', {}, { atomic : true }
                     ).then(function (list) {