From 11bae0ebb53bf99959481d1604185df797dd11ba Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 30 Aug 2011 17:04:57 -0400 Subject: [PATCH] Library Settings Editor: Use real perms When update_perm exists use that permission, instead of a permission based solely on the name of the permission. Signed-off-by: Thomas Berezansky Signed-off-by: Bill Erickson --- .../staff_client/server/admin/org_unit_settings.js | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js index 82f04751ff..72a8abbbc1 100644 --- a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js +++ b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js @@ -22,6 +22,7 @@ var user; var osSettings = {}; var ouSettingValues = {}; var osEditAutoWidget; +var perm_codes = {}; function osInit(data) { authtoken = new openils.CGI().param('ses') || dojo.cookie('ses'); @@ -43,6 +44,20 @@ function osInit(data) { }; new openils.User().buildPermOrgSelector('VIEW_ORG_SETTINGS', osContextSelector, null, connect); + + fieldmapper.standardRequest( + [ 'open-ils.actor', + 'open-ils.actor.permissions.retrieve'], + { async: true, + oncomplete: function(r) { + var data = r.recv().content(); + if(e = openils.Event.parse(data)) + return alert(e); + for(var key in data) + perm_codes[data[key].id()] = data[key].code(); + } + } + ); } dojo.addOnLoad(osInit); @@ -65,7 +80,8 @@ function osDraw(specific_setting) { label : type.label(), desc : type.description(), type : type.datatype(), - fm_class : type.fm_class() + fm_class : type.fm_class(), + update_perm : type.update_perm() } } ); @@ -183,8 +199,12 @@ function osFormatEditLink(name) { function osLaunchEditor(name) { osEditDialog._osattr = name; osEditDialog.show(); + var perm = 'UPDATE_ORG_UNIT_SETTING.' + name; + if(osSettings[name].update_perm && perm_codes[osSettings[name].update_perm]) { + perm = perm_codes[osSettings[name].update_perm]; + } user.buildPermOrgSelector( - ['UPDATE_ORG_UNIT_SETTING.' + name, 'UPDATE_ORG_UNIT_SETTING_ALL'], + [perm, 'UPDATE_ORG_UNIT_SETTING_ALL'], osEditContextSelector, osSettings[name].context ); dojo.byId('os-edit-name').innerHTML = osSettings[name].label; -- 2.11.0