Search This Blog

Friday, December 16, 2016

Displaying the currently logged user name and photo near the Log Off Action (UPDATED)

We continue to evolve our framework and save time to its users by removing routine work for the most popular customizations like this one. Now in the New Web UI, an image associated with the current user is displayed at the top right corner of the application page when the IModelApplicationWeb.CurrentUserDisplayMode is set to Image or CaptionAndImage.

To provide an individual image for each user, do the following: 
 - Declare a property of the MediaDataObject type in your User business class.
 - Apply the CurrentUserDisplayImageAttribute attribute to the class and pass the property name to it:

[CurrentUserDisplayImage("Photo")]
public class MyAppUser : DCUser, IXafEntityObject, IObjectSpaceLink {
// ...
public virtual MediaDataObject Photo { get; set; }
// ...
}



The result is demonstrated in the image below (look at the top right corner):



The table below demonstrates the effect of different CurrentUserDisplayMode values.
ValueDescriptionScreenshot
CaptionAndImageA user image specified by the CurrentUserDisplayImageAttribute and user display name specified by the XafDefaultPropertyAttribute are shown.
CaptionA user class' icon specified by the ImageNameAttribute and a user display name specified by the XafDefaultPropertyAttribute are shown.
DefaultA user class' icon specified by the ImageNameAttribute and 'My Account' text are shown.
ImageAn image specified by the CurrentUserDisplayImageAttribute and 'My Account' text are shown.

If you wish to customize or localize the "My Account" text, go to the Localization | Captions | MyAccount node in the Model Editor. 
This functionality is available in XAF starting with v16.1.6, so my team and I will be happy to hear your thoughts on it, as always.

No comments:

Post a Comment