webstaff: receiving template associated with distribution now displays
authorGalen Charlton <gmc@equinoxinitiative.org>
Mon, 22 May 2017 21:22:44 +0000 (17:22 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:48 +0000 (12:06 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_apply_binding_template.tt2
Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js

index dd0bbc2..20de945 100644 (file)
@@ -40,7 +40,7 @@
         <div class="col-md-4">
             <select id="ou_{{lib.id}}"
                 ng-model="args.bind_unit_template[lib.id]"
-                ng-options="t.id() as t.name() for t in templates[lib.id]">
+                ng-options="t.id as t.name for t in templates[lib.id]">
                 <option value=""></option>
             </select>
         </div>
index 6792379..076380f 100644 (file)
@@ -37,7 +37,7 @@
         </select>
         <label>[% l('Receiving Template') %]</label>
         <select ng-model="sdist.receive_unit_template"
-            ng-options="t.id() as t.name() for t in receiving_templates[sdist.holding_lib.id()]">
+            ng-options="t.id as t.name for t in receiving_templates[sdist.holding_lib.id()]">
             <option value=""></option>
         </select>
       </div>
index a4209ea..cbaa201 100644 (file)
@@ -13,10 +13,24 @@ angular.module('egSerialsAppDep')
         '$uibModal','ngToast',
 function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
          $uibModal , ngToast ) {
-    egSerialsCoreSvc.fetch($scope.bibId).then(function() {
-        $scope.subscriptions = egCore.idl.toTypedHash(egSerialsCoreSvc.subTree);
-        $scope.distStreamGridDataProvider.refresh();
-    });
+
+    function reload() {
+        egSerialsCoreSvc.fetch($scope.bibId).then(function() {
+            $scope.subscriptions = egCore.idl.toTypedHash(egSerialsCoreSvc.subTree);
+            // un-flesh receive unit template so that we can use
+            // it as a model of a select
+            angular.forEach($scope.subscriptions, function(ssub) {
+                angular.forEach(ssub.distributions, function(sdist) {
+                    if (angular.isObject(sdist.receive_unit_template)) {
+                        sdist.receive_unit_template = sdist.receive_unit_template.id;
+                    }
+                });
+            });
+            $scope.distStreamGridDataProvider.refresh();
+        });
+    }
+    reload();
+
     $scope.distStreamGridControls = {
         activateItem : function (item) { } // TODO
     };
@@ -26,13 +40,6 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
         }
     });
 
-    function reload() {
-        egSerialsCoreSvc.fetch($scope.bibId).then(function() {
-            $scope.subscriptions = egCore.idl.toTypedHash(egSerialsCoreSvc.subTree);
-            $scope.distStreamGridDataProvider.refresh();
-        });
-    }
-
     $scope.need_one_selected = function() {
         var items = $scope.distStreamGridControls.selectedItems();
         if (items.length == 1) return false;
@@ -40,16 +47,10 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
     };
 
     $scope.receiving_templates = {};
-    var promises = [];
     angular.forEach(egCore.org.list(), function(org) {
-        promises.push(
-            egSerialsCoreSvc.fetch_templates(org.id()).then(function(list){
-                $scope.receiving_templates[org.id()] = list;
-            })
-        );
-    });
-    $q.all(promises).then(function() {
-        //console.log('finis',$scope.receiving_templates);
+        egSerialsCoreSvc.fetch_templates(org.id()).then(function(list){
+            $scope.receiving_templates[org.id()] = egCore.idl.toTypedHash(list);
+        });
     });
 
     $scope.add_subscription = function() {
@@ -405,16 +406,10 @@ function($scope , $q , $uibModalInstance , egCore , egSerialsCoreSvc ,
     $scope.rows = rows;
     $scope.args = { bind_unit_template : {} };
     $scope.templates = {};
-    var promises = [];
     angular.forEach(libs, function(org) {
-        promises.push(
-            egSerialsCoreSvc.fetch_templates(org.id).then(function(list){
-                $scope.templates[org.id] = list;
-            })
-        );
-    });
-    $q.all(promises).then(function() {
-        //console.log('finis',$scope.receiving_templates);
+        egSerialsCoreSvc.fetch_templates(org.id).then(function(list){
+            $scope.templates[org.id] = egCore.idl.toTypedHash(list);
+        });
     });
 }])