LP1739271 - Fix Item Edit when Part Present
authorDan Pearl <dpearl@cwmars.org>
Thu, 7 Jun 2018 18:20:49 +0000 (14:20 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 11 Jun 2018 18:12:49 +0000 (14:12 -0400)
Cannot edit item or call number after mono part
assigned.  This was indeed a timing error where parts were referenced before
they were completely assigned to the structure in which they were to reside.
I have restructured the code to ensure the parts are available.

Signed-off-by: Dan Pearl <dpearl@cwmars.org>
Signed-off-by: Jason Boyer <jboyer@library.in.gov>

Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index b722a1c..a744a0c 100644 (file)
@@ -536,25 +536,26 @@ function(egCore , $q) {
                     }
                     $scope.copy.ischanged(1);
                 }
-                $scope.$watch('part', $scope.updatePart);
-
-                $scope.barcode = $scope.copy.barcode();
-                $scope.copy_number = $scope.copy.copy_number();
-
-                if ($scope.copy.parts()) {
-                    $scope.part = $scope.copy.parts()[0];
-                    if ($scope.part) $scope.part = $scope.part.label();
-                };
 
                 $scope.parts = [];
                 $scope.part_list = [];
 
-                itemSvc.get_parts($scope.callNumber.record()).then(function(list){
+                itemSvc.get_parts($scope.callNumber.record())
+                .then(function(list){
                     $scope.part_list = list;
                     angular.forEach(list, function(p){ $scope.parts.push(p.label()) });
                     $scope.parts = angular.copy($scope.parts);
+                
+                    $scope.$watch('part', $scope.updatePart);
+                    if ($scope.copy.parts()) {
+                        var the_part = $scope.copy.parts()[0];
+                        if (the_part) $scope.part = the_part.label();
+                    };
                 });
 
+                $scope.barcode = $scope.copy.barcode();
+                $scope.copy_number = $scope.copy.copy_number();
+
             }
         ]