Skip to content

Commit

Permalink
Merge pull request #1429 from axonivy-market/feature/IVYPORTAL-18316-…
Browse files Browse the repository at this point in the history
…Update-the-Avatar-component-to-auto-convert-email-to-lower-cases-10

IVYPORTAL-18159 Various or urgent requests in IVYPORTAL - S270 > IVYP…
  • Loading branch information
mnhnam-axonivy authored Jan 15, 2025
2 parents bedbdac + 6cdf386 commit 1059a81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.axonivy.portal.components.bean;

import java.io.Serializable;
import java.util.Optional;

import javax.faces.bean.ManagedBean;

import org.apache.commons.lang3.BooleanUtils;

import com.axonivy.portal.components.dto.RoleDTO;
import com.axonivy.portal.components.dto.SecurityMemberDTO;
import com.axonivy.portal.components.dto.UserDTO;
Expand All @@ -27,11 +30,16 @@ public String getNameInitials(String displayName) {
return SecurityMemberUtils.getNameInitials(displayName);
}

public String getEmailAddress(ISecurityMember securityMember) {
public String getEmailAddress(ISecurityMember securityMember,
boolean useLowercaseEmail) {
if (securityMember == null || !securityMember.isUser()) {
return "";
}
return ((IUser) securityMember).getEMailAddress();

String email = ((IUser) securityMember).getEMailAddress();
return BooleanUtils.isTrue(useLowercaseEmail)
? Optional.ofNullable(email).map(String::toLowerCase).orElse(email)
: email;
}

public String getEmailAddress(SecurityMemberDTO securityMember) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
<cc:attribute name="securityMember" required="true" />
<cc:attribute name="id" />
<cc:attribute name="renderedAvatar" default="#{portalComponentAvatarBean.getPortalShowAvatarSettingOrDefault(true)}" />
<cc:attribute name="useLowercaseEmail" default="true" shortDescription="Convert the email address to lowercase before looking up the avatar." />
</cc:interface>

<cc:implementation>
<h:outputStylesheet library="css" name="portal-components.css" />

<p:avatar id="#{cc.attrs.id}" rendered="#{cc.attrs.renderedAvatar}"
gravatar="#{portalComponentAvatarBean.getEmailAddress(cc.attrs.securityMember)}" gravatarConfig="d=blank"
gravatar="#{portalComponentAvatarBean.getEmailAddress(cc.attrs.securityMember, cc.attrs.useLowercaseEmail)}" gravatarConfig="d=blank"
label="#{portalComponentAvatarBean.getNameInitials(cc.attrs.securityMember.getDisplayName())}" styleClass="gravatar" shape="circle" />
</cc:implementation>
</html>

0 comments on commit 1059a81

Please sign in to comment.