controller: 'ManageCtrl',
resolve : resolver
});
+
+ $routeProvider.when('/serials/:bib_id/:active_tab/:subscription_id', {
+ templateUrl: './serials/t_manage',
+ controller: 'ManageCtrl',
+ resolve : resolver
+ });
})
.controller('ManageCtrl',
- ['$scope','$routeParams','$location',
-function($scope , $routeParams , $location) {
+ ['$scope','$routeParams','$location','egSerialsCoreSvc',
+function($scope , $routeParams , $location , egSerialsCoreSvc) {
$scope.bib_id = $routeParams.bib_id;
$scope.active_tab = $routeParams.active_tab ? $routeParams.active_tab : 'manage-subscriptions';
+ $scope.ssub_id = null;
+ if ($routeParams.subscription_id) {
+ egSerialsCoreSvc.verify_subscription_id($scope.bib_id, $routeParams.subscription_id)
+ .then(function(verified) {
+ if (verified) {
+ $scope.ssub_id = $routeParams.subscription_id;
+ } else {
+ // subscription ID is no good, so drop it from the URL
+ $location.path('/serials/' + $scope.bib_id + '/' + $scope.active_tab);
+ }
+ });
+ }
}])
angular.module('egSerialsMod', ['egCoreMod'])
.factory('egSerialsCoreSvc',
- ['egCore','orderByFilter',
-function(egCore , orderByFilter) {
+ ['egCore','orderByFilter','$q',
+function(egCore , orderByFilter , $q) {
var service = {
bibId : null,
subId : null,
});
}
+ // verify that a subscription ID and bib ID are actually
+ // associated with each other
+ service.verify_subscription_id = function(bibId, ssubId) {
+ var deferred = $q.defer();
+ egCore.pcrud.search('ssub', {
+ record_entry : bibId,
+ id : ssubId
+ }, {}, { atomic : true, idlist : true }
+ ).then(function(list) {
+ if (list.length == 1) {
+ deferred.resolve(true);
+ } else {
+ deferred.resolve(false);
+ }
+ });
+ return deferred.promise;
+ }
+
return service;
}]);