'$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
};
}
});
- 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;
};
$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() {
$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);
+ });
});
}])