]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/serials/directives/sub_selector.js
LP#1708291: tweak to subscription selector
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / serials / directives / sub_selector.js
1 angular.module('egSerialsAppDep')
2
3 .directive('egSubSelector', function() {
4     return {
5         transclude: true,
6         restrict:   'E',
7         scope: {
8             bibId  : '=',
9             ssubId : '='
10         },
11         templateUrl: './serials/t_sub_selector',
12         controller:
13        ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider',
14         '$uibModal',
15 function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
16                      $uibModal) {
17     if ($scope.ssubId) {
18         $scope.owning_ou = egCore.org.root();
19     }
20     $scope.owning_ou_changed = function(org) {
21         $scope.selected_owning_ou = org.id();
22         reload();
23     }
24     function reload() {
25         egSerialsCoreSvc.fetch($scope.bibId, $scope.selected_owning_ou).then(function() {
26             $scope.subscriptions = egCore.idl.toTypedHash(egSerialsCoreSvc.subTree);
27             if ($scope.subscriptions.length == 1 && !$scope.ssubId) {
28                 $scope.ssubId = $scope.subscriptions[0].id;
29             }
30         });
31     }
32 }]
33     }
34 })