From: lbmarshallv Date: Mon, 6 Dec 2021 17:47:20 +0000 (-0500) Subject: flesh all OPAC visible settings in patron registration controller X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ad1ac18b54ad43384e08be1195132b363c51bada;p=working%2FEvergreen.git flesh all OPAC visible settings in patron registration controller Find opt-in settings through pcrud instead of assuming that all non-static settings are opt-ins return promise from anonymous function so that user settings are not loaded before user setting types --- 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 5ab7176218..172ec028a3 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 @@ -568,31 +568,39 @@ angular.module('egCoreMod') 'opac.default_pickup_location', 'opac.default_sms_carrier', 'opac.default_sms_notify']; - - return egCore.pcrud.search('cust', { + + var opt_in_types = []; + + return egCore.pcrud.search('atevdef',{owner : org_ids}, {}, {atomic : true}) + .then(function(event_defs){ + //get opt-in setting types from org unit's event definitions + angular.forEach(event_defs, function(def) { + var opt_in = def.opt_in_setting(); + if(opt_in && opt_in_types.indexOf(opt_in) == -1){ + opt_in_types.push(opt_in) + } + } + ); + }) + .then(function(){ + return egCore.pcrud.search('cust', { '-or' : [ {name : static_types}, // common user settings - {name : { // opt-in notification user settings - 'in': { - select : {atevdef : ['opt_in_setting']}, - from : 'atevdef', - // we only care about opt-in settings for - // event_defs our users encounter - where : {'+atevdef' : {owner : org_ids}} - } - }} + {name : opt_in_types}, //opt-in types + {opac_visible : 't'} // opac visible user settings + ] }, {}, {atomic : true}).then(function(setting_types) { - egCore.env.absorbList(setting_types, 'cust'); // why not... angular.forEach(setting_types, function(stype) { service.user_setting_types[stype.name()] = stype; - if (static_types.indexOf(stype.name()) == -1) { + if (opt_in_types.indexOf(stype.name()) !== -1) { service.opt_in_setting_types[stype.name()] = stype; } }); }); + }); }; service.get_user_settings = function() {