improve init of next status
authorGalen Charlton <gmc@esilibrary.com>
Fri, 18 Dec 2015 18:47:54 +0000 (13:47 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Mar 2017 20:15:52 +0000 (16:15 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/web/js/ui/default/staff/services/ui.js

index 61a1601..1c657c4 100644 (file)
@@ -508,10 +508,26 @@ function($modal , $interpolate , egCore) {
                         return defer.promise;
                     }
 
+                    // returns a promise resolved with the list of circ mods
+                    $scope.get_copy_statuses = function() {
+                        if (egCore.env.ccm)
+                            return $q.when(egCore.env.ccs.list);
+
+                        return egCore.pcrud.retrieveAll('ccs', null, {atomic : true})
+                        .then(function(list) {
+                            egCore.env.absorbList(list, 'ccs');
+                            return list;
+                        });
+                    };
+
                     $scope.mode = args.mode || 'checkin';
 
                     var next_statuses = [];
                     var seen_statuses = {};
+                    $scope.next_statuses = [];
+                    $scope.params = {
+                        'the_next_status' : null
+                    }
                     init(args).then(function(copy_alerts) {
                         $scope.alerts = copy_alerts;
                         angular.forEach($scope.alerts, function(copy_alert) {
@@ -530,32 +546,15 @@ function($modal , $interpolate , egCore) {
                                 });
                             }
                         });
-                    });
-
-                    // returns a promise resolved with the list of circ mods
-                    $scope.get_copy_statuses = function() {
-                        if (egCore.env.ccm)
-                            return $q.when(egCore.env.ccs.list);
-
-                        return egCore.pcrud.retrieveAll('ccs', null, {atomic : true})
-                        .then(function(list) {
-                            egCore.env.absorbList(list, 'ccs');
-                            return list;
-                        });
-                    };
-
-                    $scope.next_statuses = [];
-                    $scope.params = {
-                        'the_next_status' : null
-                    }
-                    if ($scope.mode == 'checkin' && next_statuses.length > 0) {
-                        $scope.get_copy_statuses().then(function() {
-                            angular.forEach(next_statuses, function(st) {
-                                $scope.next_statuses.push(egCore.env.ccs.list[st]);
+                        if ($scope.mode == 'checkin' && next_statuses.length > 0) {
+                            $scope.get_copy_statuses().then(function() {
+                                angular.forEach(next_statuses, function(st) {
+                                    $scope.next_statuses.push(egCore.env.ccs.list[st]);
+                                });
+                                $scope.params.the_next_status = $scope.next_statuses[0].id();
                             });
-                            $scope.params.the_next_status = $scope.next_statuses[0].id();
-                        });
-                    }
+                        }
+                    });
 
                     $scope.isAcknowledged = function(copy_alert) {
                         return (copy_alert.acked);