From 29f35dcc1862db26f486e9e0c6a2c0174281019b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 31 Jul 2018 16:30:17 -0400 Subject: [PATCH] LP#1750894 Batch settings lookup handles migration As with a single getItem() call, the batch version of the call, when making server requests, will migrate any settings necessary from localStorage to server settings. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- Open-ILS/web/js/ui/default/staff/services/hatch.js | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/hatch.js b/Open-ILS/web/js/ui/default/staff/services/hatch.js index 55f13a27c8..f99fa34a8f 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -250,6 +250,8 @@ angular.module('egCoreMod') // get the value for a stored item service.getItem = function(key) { + console.debug('getting item: ' + key); + if (!service.keyStoredInBrowser(key)) { return service.getServerItem(key); } @@ -544,19 +546,31 @@ angular.module('egCoreMod') var foundValues = {}; return egNet.request( 'open-ils.actor', - 'open-ils.actor.settings.retrieve', + 'open-ils.actor.settings.retrieve.atomic', keys, service.auth.token() ).then( - function() { return foundValues; }, - function() {}, - function(setting) { - var val = setting.value; - // The server returns null for undefined settings. - // Treat as undefined locally for backwards compat. - service.keyCache[setting.name] = - foundValues[setting.name] = - (val === null) ? undefined : val; - } + function(settings) { + //return foundValues; + + var deferred = $q.defer(); + function checkOne(setting) { + if (!setting) { + deferred.resolve(foundValues); + return; + } + service.handleServerItemResponse(setting) + .then(function(resp) { + if (resp !== undefined) { + foundValues[setting.name] = resp; + } + settings.shift(); + checkOne(settings[0]); + }); + } + + checkOne(settings[0]); + return deferred.promise; + }, ); } -- 2.11.0