From 395abafebd0e1f6a8646cb4717a1376681c785b9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 29 May 2018 11:07:51 -0400 Subject: [PATCH] LP#1750894 setting api returns object ... since some settings calls happen before the browser has parsed the IDL, have the API return an generic object instead of an IDL object. And better handle org-only settings. Signed-off-by: Bill Erickson --- Open-ILS/examples/fm_IDL.xml | 14 ------ .../lib/OpenILS/Application/Actor/Settings.pm | 7 +-- .../web/js/ui/default/staff/services/hatch.js | 50 ++++++++++++------- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 2848be8cbf..bb9f9c06ae 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -12403,20 +12403,6 @@ SELECT usr, - - - - - - - - - - diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Settings.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Settings.pm index d76aedb1d7..6ab6818ef6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Settings.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Settings.pm @@ -77,12 +77,9 @@ sub retrieve_settings { ] }); - # The DB responds in setting-name order. while (my $resp = $req->recv) { - my $sumhash = $resp->content; - my $summary = Fieldmapper::actor::cascade_setting_summary->new; - $summary->$_($sumhash->{$_}) for keys %$sumhash; - $summary->value(OpenSRF::Utils::JSON->JSON2perl($summary->value)); + my $summary = $resp->content; + $summary->{value} = OpenSRF::Utils::JSON->JSON2perl($summary->{value}); $client->respond($summary); } 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 12a25f7cde..4936cab74b 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -366,14 +366,18 @@ angular.module('egCoreMod') // If we have already attempted to retrieve a value for this // setting, then we can tell up front whether applying a value // at the server will be an option. If not, store locally. - // Note that the existence of an org unit setting type and no - // user/ws setting type means applying a value locally is - // not allowed. var summary = service.serverSettingSummaries[key]; - if (summary && - summary.has_org_setting() === 'f' && - summary.has_user_setting() === 'f' && - summary.has_workstation_setting() === 'f') { + if (summary && !summary.has_staff_setting) { + + if (summary.has_org_setting === 't') { + // When no user/ws setting types exist but an org unit + // setting type does, it means the value cannot be + // applied by an individual user. Nothing left to do. + return $q.when(); + } + + // No setting types of any flavor exist. + // Fall back to local storage. if (value === null) { // a null value means clear the server setting. @@ -424,10 +428,17 @@ angular.module('egCoreMod') } service.handleServerItemResponse = function(summary) { - var key = summary.name(); - var val = summary.value(); + var key = summary.name; + var val = summary.value; + + // For our purposes, we only care if a setting can be stored + // as an org setting or a user-or-workstation setting. + summary.has_staff_setting = ( + summary.has_user_setting === 't' || + summary.has_workstation_setting === 't' + ); - summary.value(null); // avoid duplicate value caches + summary.value = null; // avoid duplicate value caches service.serverSettingSummaries[key] = summary; if (val !== null) { @@ -435,12 +446,15 @@ angular.module('egCoreMod') return $q.when(service.keyCache[key] = val); } - // Note that the existence of an org unit setting type and no - // user/ws setting type means applying a value locally is - // not allowed. - if (summary.has_org_setting() === 'f' && - summary.has_user_setting() === 'f' && - summary.has_workstation_setting() === 'f') { + if (!summary.has_staff_setting) { + + if (summary.has_org_setting === 't') { + // An org unit setting type exists but no value is applied + // that this workstation has access to. The existence of + // an org unit setting type and no user/ws setting type + // means applying a value locally is not allowed. + return $q.when(service.keyCache[key] = undefined); + } console.warn('No server setting type exists for ' + key + ', using local value.'); @@ -448,8 +462,8 @@ angular.module('egCoreMod') return service.getBrowserItem(key); } - // A server setting type exists, but no server value exists. - // See if we can migrate a local setting to the server. + // A user/ws setting type exists, but no server value exists. + // Migrate the local setting to the server. var deferred = $q.defer(); service.getBrowserItem(key).then(function(browserVal) { -- 2.43.2