From: Mike Rylander Date: Tue, 29 Sep 2015 16:28:16 +0000 (-0400) Subject: webstaff: Normalize the type of values going into in-memory objects X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1f7f4731b8e1999a77e7d06cc78ccb0fa7cff615;p=evergreen%2Ftadl.git webstaff: Normalize the type of values going into in-memory objects Signed-off-by: Mike Rylander 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 cead130026..273f5895a0 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 @@ -323,14 +323,14 @@ function(egCore , $q) { template: '
'+ '
'+ - ''+ '
'+ '
'+ - ''+ '
'+ '
'+ '
'+ - ''+ '
'+ '
'+ '
'+ @@ -384,6 +384,7 @@ function(egCore , $q) { itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){ $scope.suffix_list = list; $scope.$watch('callNumber.suffix()', function (v) { + if (angular.isObject(v)) v = v.id(); $scope.suffix = $scope.suffix_list.filter( function (s) { return s.id() == v; })[0]; @@ -392,7 +393,7 @@ function(egCore , $q) { }); $scope.updateSuffix = function () { angular.forEach($scope.copies, function(cp) { - cp.call_number().suffix($scope.suffix.id()); + cp.call_number().suffix($scope.suffix); cp.call_number().ischanged(1); }); } @@ -401,6 +402,7 @@ function(egCore , $q) { itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){ $scope.prefix_list = list; $scope.$watch('callNumber.prefix()', function (v) { + if (angular.isObject(v)) v = v.id(); $scope.prefix = $scope.prefix_list.filter(function (p) { return p.id() == v; })[0]; @@ -409,7 +411,7 @@ function(egCore , $q) { }); $scope.updatePrefix = function () { angular.forEach($scope.copies, function(cp) { - cp.call_number().prefix($scope.prefix.id()); + cp.call_number().prefix($scope.prefix); cp.call_number().ischanged(1); }); } @@ -418,6 +420,7 @@ function(egCore , $q) { itemSvc.get_classifications().then(function(list){ $scope.classification_list = list; $scope.$watch('callNumber.label_class()', function (v) { + if (angular.isObject(v)) v = v.id(); $scope.classification = $scope.classification_list.filter(function (c) { return c.id() == v; })[0]; @@ -426,7 +429,7 @@ function(egCore , $q) { }); $scope.updateClassification = function () { angular.forEach($scope.copies, function(cp) { - cp.call_number().label_class($scope.classification.id()); + cp.call_number().label_class($scope.classification); cp.call_number().ischanged(1); }); } @@ -883,18 +886,29 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , angular.forEach($scope.data.tree, function(cn_hash) { angular.forEach(cn_hash, function(copies) { angular.forEach(copies, function(cp) { - if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '') - cp.call_number().label_class($scope.batch.classification); + if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '') { + var label_class = $scope.classification_list.filter(function(p){ return p.id() == $scope.batch.classification })[0]; + cp.call_number().label_class(label_class); + cp.call_number().ischanged(1); $scope.dirty = true; - if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '') - cp.call_number().prefix($scope.batch.prefix); + } + if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '') { + var prefix = $scope.prefix_list.filter(function(p){ return p.id() == $scope.batch.prefix })[0]; + cp.call_number().prefix(prefix); + cp.call_number().ischanged(1); $scope.dirty = true; - if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '') + } + if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '') { cp.call_number().label($scope.batch.label); + cp.call_number().ischanged(1); $scope.dirty = true; - if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '') - cp.call_number().suffix($scope.batch.suffix); + } + if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '') { + var suffix = $scope.suffix_list.filter(function(p){ return p.id() == $scope.batch.suffix })[0]; + cp.call_number().suffix(suffix); + cp.call_number().ischanged(1); $scope.dirty = true; + } }); }); });