From 552fbfbb6ed46a0758a67e62de38f7616b810ad8 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 14 Mar 2024 20:25:20 +0100 Subject: [PATCH 1/3] buttons to check/uncheck inheriting all user properties --- .../web/model/shared/UserSettingsBeanBase.java | 7 +++++-- .../phoenixctms/ctsms/web/model/user/UserBean.java | 13 +++++++++++++ .../webapp/META-INF/includes/user/userMain.xhtml | 12 +++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/web/src/main/java/org/phoenixctms/ctsms/web/model/shared/UserSettingsBeanBase.java b/web/src/main/java/org/phoenixctms/ctsms/web/model/shared/UserSettingsBeanBase.java index c1d12a5ec9cd..45bd407d0bd0 100644 --- a/web/src/main/java/org/phoenixctms/ctsms/web/model/shared/UserSettingsBeanBase.java +++ b/web/src/main/java/org/phoenixctms/ctsms/web/model/shared/UserSettingsBeanBase.java @@ -224,9 +224,12 @@ public List completeTimeZone(String query) { public abstract void setShowTooltips(boolean showTooltips); private void loadInheritedPropertiesMap() { + setInheritedPropertiesMap(true, getInheritedProperties()); + } + + protected void setInheritedPropertiesMap(boolean inherit, Collection inheritedProperties) { inheritedPropertiesMap.clear(); - Collection inheritedProperties = getInheritedProperties(); - if (inheritedProperties != null) { + if (inherit && inheritedProperties != null) { Iterator it = inheritedProperties.iterator(); while (it.hasNext()) { inheritedPropertiesMap.put(it.next(), Boolean.TRUE.toString()); diff --git a/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserBean.java b/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserBean.java index 05ac9cde0df8..7cc633646eb4 100644 --- a/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserBean.java +++ b/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserBean.java @@ -1081,6 +1081,19 @@ private static String visibleTabListToString(List tabList) { return result.toString(); } + private void setInheritedProperties(boolean inherit) { + setInheritedPropertiesMap(inherit, CommonUtil.USER_INHERITABLE_PROPERTIES); + clearInheritedPropertiesTooltips(); + } + + public void enableInheritedProperties() { + setInheritedProperties(true); + } + + public void disableInheritedProperties() { + setInheritedProperties(false); + } + @Override protected Collection getInheritedProperties() { return in != null ? in.getInheritedProperties() : null; diff --git a/web/src/main/webapp/META-INF/includes/user/userMain.xhtml b/web/src/main/webapp/META-INF/includes/user/userMain.xhtml index 40c96f021cf2..c044a2b59702 100644 --- a/web/src/main/webapp/META-INF/includes/user/userMain.xhtml +++ b/web/src/main/webapp/META-INF/includes/user/userMain.xhtml @@ -574,7 +574,7 @@ for="parent" value="#{userlabels.user_parent_label}" /> + + From b0d412fac98d549233cdbabb595a06827625fb0c Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 14 Mar 2024 20:27:43 +0100 Subject: [PATCH 2/3] button to check&save all inherited user permissions --- .../model/user/UserPermissionProfileBean.java | 30 ++++++++++++++++--- .../ctsms/web/user/labels.properties | 5 ++++ .../ctsms/web/user/labels_de.properties | 5 ++++ .../includes/user/userPermissionProfile.xhtml | 7 +++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java b/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java index 8dca7c6920f9..4cea5ce8b3bf 100644 --- a/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java +++ b/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java @@ -34,6 +34,8 @@ import org.phoenixctms.ctsms.web.util.WebUtil; import org.primefaces.context.RequestContext; +import io.jsonwebtoken.lang.Collections; + @ManagedBean @ViewScoped public class UserPermissionProfileBean extends ManagedBeanBase { @@ -170,6 +172,16 @@ private void initIn() { } } + private void setInheritedPermissionProfileGroupsMap(boolean inherit, Collection inheritedPermissionProfileGroups) { + inheritedPermissionProfileGroupsMap.clear(); + if (inherit && inheritedPermissionProfileGroups != null) { + Iterator it = inheritedPermissionProfileGroups.iterator(); + while (it.hasNext()) { + inheritedPermissionProfileGroupsMap.put(it.next().name(), Boolean.TRUE.toString()); + } + } + } + private void initSets() { user = WebUtil.getUser(userId, GRAPH_MAX_USER_INSTANCES, GRAPH_MAX_USER_PARENT_DEPTH, GRAPH_MAX_USER_CHILDREN_DEPTH); parent = null; @@ -178,10 +190,7 @@ private void initSets() { parentPermissionProfileVOMap.clear(); if (user != null) { parent = WebUtil.getInheritedUser(user.getParent() != null ? user.getParent().getId() : null); - Iterator profileGroupIt = user.getInheritedPermissionProfileGroups().iterator(); - while (profileGroupIt.hasNext()) { - inheritedPermissionProfileGroupsMap.put(profileGroupIt.next().name(), Boolean.TRUE.toString()); - } + setInheritedPermissionProfileGroupsMap(true, user.getInheritedPermissionProfileGroups()); if (parent != null) { Collection parentUserPermissionProfiles = null; try { @@ -299,10 +308,23 @@ public String updateAction() { return ERROR_OUTCOME; } + public String updateInheritAction() { + setInheritedPermissionProfileGroupsMap(true, Collections.arrayToList(PermissionProfileGroup.values())); + return updateAction(); + } + + public void updateInherit() { + actionPostProcess(updateInheritAction()); + } + public Set getParentPermissionProfiles() { return parentPermissionProfiles; } + public boolean isHasParent() { + return parent != null; + } + public String getInheritedPermissionProfileGroupTooltip(String profileGroup) { if (parentPermissionProfileVOMap.containsKey(profileGroup)) { return Messages.getMessage(MessageCodes.INHERITED_USER_PERMISSION_PROFILE_TOOLTIP, parentPermissionProfileVOMap.get(profileGroup).getProfileName()); diff --git a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties index b4cf053b20fc..5276d6f049e9 100644 --- a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties +++ b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties @@ -79,6 +79,9 @@ user_identity_tooltip=A person/organisation can be optionally selected as a user user_parent_label=Parent user\: user_parent_tooltip=Inherit settings and permissions from a parent user.\n +enable_inherited_properties_button_label=Inherit all settings from parent user +disable_inherited_properties_button_label=Inherit no settings from parent user + user_modules_field_set=Modules user_enable_inventory_module_label=Inventory: @@ -263,6 +266,8 @@ password_department_password_prompt_dialog_message=The department password is re password_department_password=new department's password password_department_password_tooltip=The new department's password. +update_inherit_user_permission_profiles_button_label=Inherit permissions from parent user + #user activity: user_activity_useractivity_list_header=journal entries diff --git a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties index cf65947ca730..993b1278ca61 100644 --- a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties +++ b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties @@ -79,6 +79,9 @@ user_identity_tooltip=Optional kann eine Person/Organisation als Identit\u00E4t user_parent_label=\u00DCbergeordneter Benutzer\: user_parent_tooltip=Einstellungen und Berechtigungen von einem \u00FCbergeordneten Benutzer vererben.\n +enable_inherited_properties_button_label=Alle Einstellungen des \u00FCbergeordneten Benutzers \u00FCbernehmen +disable_inherited_properties_button_label=Keine Einstellungen des \u00FCbergeordneten Benutzers \u00FCbernehmen + user_modules_field_set=Module user_enable_inventory_module_label=Inventar: @@ -263,6 +266,8 @@ password_department_password_prompt_dialog_message=Das Passwort f\u00FCr die Org password_department_password=neue Org.Einheit Passwort password_department_password_tooltip=Passwort der neuen Org.Einheit. +update_inherit_user_permission_profiles_button_label=Berechtigungen des \u00FCbergeordneten Benutzers \u00FCbernehmen + #user activity: user_activity_useractivity_list_header=Protokolleintr\u00E4ge diff --git a/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml b/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml index 5bc60b298f58..2d9f607ca951 100644 --- a/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml +++ b/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml @@ -73,6 +73,13 @@ icon="ui-icon ui-icon-disk" ajax="true" disabled="#{!userPermissionProfileBean.editable}" update="userpermissionprofile_input_grid" /> + Date: Thu, 14 Mar 2024 20:32:18 +0100 Subject: [PATCH 3/3] buttons to check/uncheck inheriting all user properties - fix tooltip --- web/src/main/webapp/META-INF/includes/user/userMain.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/main/webapp/META-INF/includes/user/userMain.xhtml b/web/src/main/webapp/META-INF/includes/user/userMain.xhtml index c044a2b59702..6a87999d5f86 100644 --- a/web/src/main/webapp/META-INF/includes/user/userMain.xhtml +++ b/web/src/main/webapp/META-INF/includes/user/userMain.xhtml @@ -608,7 +608,7 @@ icon="ui-icon ui-icon-squaresmall-close" ajax="true" update="@([id$=\'inherit_input\'],[id$=\'Module\'],[id$=\'ModuleTabs\'])" />