From: Galen Charlton Date: Tue, 20 Oct 2015 19:08:33 +0000 (+0000) Subject: webstaff: update volume prefix/suffix selectors X-Git-Tag: sprint4-merge-nov22~718 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9974afdb64d0f70a65913822dba9368b5e4d7f9e;p=working%2FEvergreen.git webstaff: update volume prefix/suffix selectors Ensuring that when the owning library changes that the selectors for the volume prefix and suffix refelect the options available to that OU. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 46842460f4..2a3d37a035 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -420,6 +420,31 @@ function(egCore , $q) { cp.call_number().ischanged(1); }); } + $scope.$watch('callNumber.owning_lib()', function(oldLib, newLib) { + if (oldLib == newLib) return; + var currentPrefix = $scope.callNumber.prefix(); + if (angular.isObject(currentPrefix)) currentPrefix = currentPrefix.id(); + itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){ + $scope.prefix_list = list; + $scope.prefix = $scope.prefix_list.filter(function (p) { + return p.id() == currentPrefix; + })[0] || -1; + if ($scope.prefix != currentPrefix) { + $scope.callNumber.prefix($scope.prefix); + } + }); + var currentSuffix = $scope.callNumber.suffix(); + if (angular.isObject(currentSuffix)) currentSuffix = currentSuffix.id(); + itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){ + $scope.suffix_list = list; + $scope.suffix = $scope.suffix_list.filter(function (s) { + return s.id() == currentSuffix; + })[0] || -1; + if ($scope.suffix != currentSuffix) { + $scope.callNumber.suffix($scope.suffix); + } + }); + }); $scope.classification_list = []; itemSvc.get_classifications().then(function(list){ @@ -570,9 +595,11 @@ function(egCore , $q) { $scope.orig_cn_count = $scope.cn_count; $scope.owning_lib = egCore.org.get($scope.lib); - $scope.$watch('owning_lib', function (l) { - angular.forEach( $scope.struct[$scope.first_cn], function (cp) { - cp.call_number().owning_lib( $scope.owning_lib.id() ); + $scope.$watch('owning_lib', function (oldLib, newLib) { + if (oldLib == newLib) return; + angular.forEach( Object.keys($scope.struct), function (cn) { + $scope.struct[cn][0].call_number().owning_lib( $scope.owning_lib.id() ); + $scope.struct[cn][0].call_number().ischanged(1); }); });