[open-ils-commits] [GIT] Evergreen ILS branch master updated. 1f5c30502a1c7923a8978d0f4e3d28618c5c07d4

Evergreen Git git at git.evergreen-ils.org
Thu Mar 22 12:42:22 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  1f5c30502a1c7923a8978d0f4e3d28618c5c07d4 (commit)
      from  667bc1a5a3433b4cd936cd9d362668d23e6ad3b3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1f5c30502a1c7923a8978d0f4e3d28618c5c07d4
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Mar 19 15:22:44 2018 -0400

    LP#1361258 Patron reg repair user settings saving/loading
    
    Avoid caching user setting values at the service (app) level in the user
    editor.  In other words, always fetch a fresh copy of the current user's
    setting with each instance of the editor page.
    
    This solves a number problems where stale versions of the cached data
    were referenced and acted on, both when displaying an updating user
    settings.
    
    Additionally, ensure that clone user and stage user data is refreshed
    on all page instances as the URL params that affect these values can
    change per instance.
    
    Other data that is common to all instances (e.g. the set of profile
    groups) is still cached as before.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Terran McCanna <tmccanna at georgialibraries.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
index 8b389ae..8716184 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
@@ -22,29 +22,32 @@ angular.module('egCoreMod')
         init_done : false           // have we loaded our initialization data?
     };
 
-    // launch a series of parallel data retrieval calls
+    // Launch a series of parallel data retrieval calls.
     service.init = function(scope) {
 
-        // Data loaded here only needs to be retrieved the first time this
-        // tab becomes active within the current instance of the patron app.
-        // In other words, navigating between patron tabs will not cause
-        // all of this data to be reloaded.  Navigating to a separate app
-        // and returning will cause the data to be reloaded.
-        if (service.init_done) return $q.when();
-        service.init_done = true;
-
-        return $q.all([
-            service.get_field_doc(),
-            service.get_perm_groups(),
-            service.get_ident_types(),
+        // These are fetched with every instance of the page.
+        var page_data = [
             service.get_user_settings(),
-            service.get_org_settings(),
-            service.get_stat_cats(),
-            service.get_surveys(),
             service.get_clone_user(),
-            service.get_stage_user(),
-            service.get_net_access_levels()
-        ]);
+            service.get_stage_user()
+        ];
+
+        var common_data = [];
+        if (!service.init_done) {
+            // These are fetched with every instance of the app.
+            common_data = [
+                service.get_field_doc(),
+                service.get_perm_groups(),
+                service.get_ident_types(),
+                service.get_org_settings(),
+                service.get_stat_cats(),
+                service.get_surveys(),
+                service.get_net_access_levels()
+            ];
+            service.init_done = true;
+        }
+
+        return $q.all(common_data.concat(page_data));
     };
 
     service.get_clone_user = function() {
@@ -459,7 +462,12 @@ angular.module('egCoreMod')
 
     };
 
-    service.get_user_settings = function() {
+    service.get_user_setting_types = function() {
+
+        // No need to re-fetch the common setting types.
+        if (Object.keys(service.user_setting_types).length) 
+            return $q.when();
+
         var org_ids = egCore.org.ancestors(egCore.auth.user().ws_ou(), true);
 
         var static_types = [
@@ -494,6 +502,15 @@ angular.module('egCoreMod')
                     service.opt_in_setting_types[stype.name()] = stype;
                 }
             });
+        });
+    };
+
+    service.get_user_settings = function() {
+
+        return service.get_user_setting_types()
+        .then(function() {
+
+            var setting_types = Object.values(service.user_setting_types);
 
             if (service.patron_id) {
                 // retrieve applied values for the current user 
@@ -511,6 +528,7 @@ angular.module('egCoreMod')
                 ).then(function(settings) {
                     service.user_settings = settings;
                 });
+
             } else {
 
                 // apply default user setting values
@@ -1046,19 +1064,15 @@ angular.module('egCoreMod')
     }
 
     service.save_user_settings = function(new_user, user_settings) {
-        // user_settings contains the values from the scope/form.
-        // service.user_settings contain the values from page load time.
 
         var settings = {};
         if (service.patron_id) {
-            // only update modified settings for existing patrons
-            angular.forEach(user_settings, function(val, key) {
-                if (val !== service.user_settings[key])
-                    settings[key] = val;
-            });
+            // Update all user editor setting values for existing 
+            // users regardless of whether a value changed.
+            settings = user_settings;
 
         } else {
-            // all non-null setting values are updated for new patrons
+            // Create settings for all non-null setting values for new patrons.
             angular.forEach(user_settings, function(val, key) {
                 if (val !== null) settings[key] = val;
             });

-----------------------------------------------------------------------

Summary of changes:
 .../web/js/ui/default/staff/circ/patron/regctl.js  |   70 ++++++++++++--------
 1 files changed, 42 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list