Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buttons to check/uncheck inheriting all user properties/permissions #293

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,12 @@ public List<TimeZoneVO> completeTimeZone(String query) {
public abstract void setShowTooltips(boolean showTooltips);

private void loadInheritedPropertiesMap() {
setInheritedPropertiesMap(true, getInheritedProperties());
}

protected void setInheritedPropertiesMap(boolean inherit, Collection<String> inheritedProperties) {
inheritedPropertiesMap.clear();
Collection<String> inheritedProperties = getInheritedProperties();
if (inheritedProperties != null) {
if (inherit && inheritedProperties != null) {
Iterator<String> it = inheritedProperties.iterator();
while (it.hasNext()) {
inheritedPropertiesMap.put(it.next(), Boolean.TRUE.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,19 @@ private static String visibleTabListToString(List<String> 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<String> getInheritedProperties() {
return in != null ? in.getInheritedProperties() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -170,6 +172,16 @@ private void initIn() {
}
}

private void setInheritedPermissionProfileGroupsMap(boolean inherit, Collection<PermissionProfileGroup> inheritedPermissionProfileGroups) {
inheritedPermissionProfileGroupsMap.clear();
if (inherit && inheritedPermissionProfileGroups != null) {
Iterator<PermissionProfileGroup> 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;
Expand All @@ -178,10 +190,7 @@ private void initSets() {
parentPermissionProfileVOMap.clear();
if (user != null) {
parent = WebUtil.getInheritedUser(user.getParent() != null ? user.getParent().getId() : null);
Iterator<PermissionProfileGroup> profileGroupIt = user.getInheritedPermissionProfileGroups().iterator();
while (profileGroupIt.hasNext()) {
inheritedPermissionProfileGroupsMap.put(profileGroupIt.next().name(), Boolean.TRUE.toString());
}
setInheritedPermissionProfileGroupsMap(true, user.getInheritedPermissionProfileGroups());
if (parent != null) {
Collection<UserPermissionProfileOutVO> parentUserPermissionProfiles = null;
try {
Expand Down Expand Up @@ -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<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion web/src/main/webapp/META-INF/includes/user/userMain.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
for="parent"
value="#{userlabels.user_parent_label}" />
<h:panelGrid
columns="3"
columns="5"
cellpadding="0">
<h:panelGroup>
<h:inputHidden
Expand Down Expand Up @@ -602,6 +602,16 @@
icon="ui-icon ui-icon-close"
type="button"
onclick="clearIDAjax('tabView:usermain_form:parent','tabView:usermain_form:parentName','#{applicationScopeBean.noUserPickedMessage}','clearInheritedPropertiesTooltips')" />
<p:commandButton process="@this"
title="#{userlabels.enable_inherited_properties_button_label}"
actionListener="#{userBean.enableInheritedProperties}"
icon="ui-icon ui-icon-squaresmall-close" ajax="true"
update="@([id$=\'inherit_input\'],[id$=\'Module\'],[id$=\'ModuleTabs\'])" />
<p:commandButton process="@this"
title="#{userlabels.disable_inherited_properties_button_label}"
actionListener="#{userBean.disableInheritedProperties}"
icon="ui-icon ui-icon-circlesmall-close" ajax="true"
update="@([id$=\'inherit_input\'],[id$=\'Module\'],[id$=\'ModuleTabs\'])" />
</h:panelGrid>
<p:message for="parent" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
icon="ui-icon ui-icon-disk" ajax="true"
disabled="#{!userPermissionProfileBean.editable}"
update="userpermissionprofile_input_grid" />
<p:commandButton process="@this,userpermissionprofile_inputs"
id="updateInherit" value="#{userlabels.update_inherit_user_permission_profiles_button_label}"
actionListener="#{userPermissionProfileBean.updateInherit}"
oncomplete="handleUpdateUserTabTitles(xhr, status, args)"
icon="ui-icon ui-icon-disk" ajax="true"
disabled="#{!userPermissionProfileBean.editable or !userPermissionProfileBean.hasParent}"
update="userpermissionprofile_input_grid" />
<p:commandButton process="@this"
value="#{labels.load_button_label}"
actionListener="#{userPermissionProfileBean.load}"
Expand Down
Loading