LP1717366 Patron summary auto-collapse as org setting user/khuckins/lp1717366-patron-summary-autocollapse-rebase
authorBill Erickson <berickxx@gmail.com>
Tue, 15 Jan 2019 17:20:52 +0000 (12:20 -0500)
committerKyle Huckins <khuckins@catalyte.io>
Mon, 25 Nov 2019 17:29:22 +0000 (17:29 +0000)
Treat "circ.auto_hide_patron_summary" as an org setting instead of a
browser client (workstation) setting for consistency with XUL client.

Pre-fetch the circ.auto_hide_patron_summary org setting value so it's
loaded and cached along with the initial patron org settings batch (one
fewer API call).

Move the show/hide function up in the file so it's defined before it's
first referenced (for clarity).

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 4a550ac..f71bfd6 100644 (file)
@@ -38,7 +38,8 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', 'egUserBucketMod',
                 'circ.patron_expires_soon_warning',
                 'ui.circ.items_out.lost',
                 'ui.circ.items_out.longoverdue',
-                'ui.circ.items_out.claimsreturned'
+                'ui.circ.items_out.claimsreturned',
+                'circ.auto_hide_patron_summary'
             ]).then(function(settings) { 
                 // local settings are cached within egOrg.  Caching them
                 // again in egEnv just simplifies the syntax for access.
@@ -267,6 +268,15 @@ function($scope,  $q , $location , $filter , egCore , egNet , egUser , egAlertDi
         return false;
     }
 
+    // Expand or collapse the patron summary side bar.
+    function setSummaryState(condition) {
+        if (condition) {
+            egCore.hatch.setItem('eg.circ.patron.summary.collapse', true);
+        } else {
+            egCore.hatch.removeItem('eg.circ.patron.summary.collapse');
+        }
+    }
+
     // called after each route-specified controller is instantiated.
     // this doubles as a way to inform the top-level controller that
     // egStartup.go() has completed, which means we are clear to 
@@ -277,6 +287,11 @@ function($scope,  $q , $location , $filter , egCore , egNet , egUser , egAlertDi
         $scope.aous = egCore.env.aous;
         $scope.auth_user_id = egCore.auth.user().id();
 
+        if (egCore.env.aous && // cached in startup
+            egCore.env.aous['circ.auto_hide_patron_summary']) {
+            setSummaryState(true);
+        }
+
         if (patron_id) {
             $scope.patron_id = patron_id;
             return patronSvc.setPrimary($scope.patron_id)
@@ -357,18 +372,6 @@ function($scope,  $q , $location , $filter , egCore , egNet , egUser , egAlertDi
         lNode.style.visibility = 'hidden';
     }
 
-    function setSummaryState(condition) {
-        if (condition) {
-            egCore.hatch.setItem('eg.circ.patron.summary.collapse', true);
-        } else {
-            egCore.hatch.removeItem('eg.circ.patron.summary.collapse');
-        }
-    }
-
-    egCore.hatch.getItem('circ.auto_hide_patron_summary').then(function(res) {
-        setSummaryState(res);
-    });
-
     $scope.toggle_expand_summary = function() {
         if ($scope.collapsePatronSummary) {
             $scope.collapsePatronSummary = false;