From: Galen Charlton Date: Mon, 24 Apr 2017 21:52:56 +0000 (-0400) Subject: webstaff: add subscription ID to serials routes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c2465fb7c3d6a6fb52c11acc40452ca40007d052;p=working%2FEvergreen.git webstaff: add subscription ID to serials routes Teach the serials app to recognize the subscription ID if supplied in the path. The subscription ID is validated against the bib record; if it doesn't belong to the bib, the path is rewritten to drop it. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/web/js/ui/default/staff/serials/app.js b/Open-ILS/web/js/ui/default/staff/serials/app.js index e65ae41fac..7cd7a34d8a 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/app.js +++ b/Open-ILS/web/js/ui/default/staff/serials/app.js @@ -26,11 +26,29 @@ angular.module('egSerialsApp') 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); + } + }); + } }]) diff --git a/Open-ILS/web/js/ui/default/staff/serials/services/core.js b/Open-ILS/web/js/ui/default/staff/serials/services/core.js index e40a08c69c..d138df4fe0 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/serials/services/core.js @@ -1,7 +1,7 @@ angular.module('egSerialsMod', ['egCoreMod']) .factory('egSerialsCoreSvc', - ['egCore','orderByFilter', -function(egCore , orderByFilter) { + ['egCore','orderByFilter','$q', +function(egCore , orderByFilter , $q) { var service = { bibId : null, subId : null, @@ -134,5 +134,23 @@ function(egCore , orderByFilter) { }); } + // 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; }]);