7556046419dd72edc91c833e95915878c4297c06
[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         });
28     }
29 }]
30     }
31 })