LP#1736763: Wait until the org tree is there before using it
authorMike Rylander <mrylander@gmail.com>
Mon, 11 Dec 2017 21:21:39 +0000 (16:21 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 10 Jan 2018 21:06:06 +0000 (16:06 -0500)
In offline mode, we need to wait for the org tree to be fetched or recreated
before we set the working location dropdown.  This commit adds a function
to loop and wait for that to happen.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Open-ILS/web/js/ui/default/staff/offline.js

index c27360b..1441c38 100644 (file)
@@ -359,7 +359,9 @@ function($routeProvider , $locationProvider , $compileProvider) {
 
                     if (match) {
                         // requested WS registered on this client
+                        $scope.workstation_obj = match;
                         $scope.workstation = match.id;
+                        $scope.workstation_owner = match.owning_lib;
                     } else {
                         // the requested WS is not registered on this client
                         $scope.wsNotRegistered = true;
@@ -721,6 +723,17 @@ function($routeProvider , $locationProvider , $compileProvider) {
             return check_digit;
         }
 
+        function fetch_org_after_tree_exists () {
+            $timeout(function(){
+                try {
+                    $scope.org = egCore.org.get($scope.current_workstation_owning_lib());
+                } catch(e) {
+                    fetch_org_after_tree_exists();
+                }
+            },100);
+        }
+
+        fetch_org_after_tree_exists();
     }
 ])