Open Closed

Multiple module extensibility questions #1813


User avatar
0
stjepanh_teched created

Hi,

I have couple of questions regarding the abp commercial identity module extensibility:

  • Is it possible to remove existing property from identity module? For example, we don't need phone number property in our project, how can we remove it?
  • Is it possible to set existing property as required. For example, we need "Surname" property to be required in database.
  • Is it possible to change existing property visibility on the UI? We've followed the instructions in the ModuleExtensionConfigurator - configuring visibility of the new properties works but configuring existing (predefinied) properties doesn't. Example:
    user.AddOrUpdateProperty<string>(
            "Surname",
            property =>
            {
                    property.UI.OnTable.IsVisible = false;
            }
    );
  • We've managed to add new property to module per instructions in documentation, but there are couple of problems with it:
    • How to set new property as required in database?

    • How to enable client side validation for the property? We've set required attribute with the following: property.Attributes.Add(new RequiredAttribute());

      But only server side validation works (modal window pops up if field is empty) - is it possible to enable client side validation for new properties? Same goes for field length. We have set the following in ModuleExtensionConfigurator: property.Attributes.Add(new MaxLengthAttribute(UserConsts.MaxTitleLength));

      But only the server side validation is triggered.

Thank you in advance, Hrvoje


11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Is it possible to remove existing property from identity module? For example, we don't need phone number property in our project, how can we remove it?

    You can download the module source code to customize, but we do not recommend it.you can just ignore it

    How to enable client side validation for the property? We've set required attribute with the following: property.Attributes.Add(new RequiredAttribute());

    What UI are you using?

  • User Avatar
    0
    stjepanh_teched created

    Is it possible to remove existing property from identity module? For example, we don't need phone number property in our project, how can we remove it?

    You can download the module source code to customize, but we do not recommend it.you can just ignore it

    How to remove it than from the UI? Third item in original question is dealing with that question.

    How to enable client side validation for the property? We've set required attribute with the following: property.Attributes.Add(new RequiredAttribute());

    What UI are you using?

    We are using Blazor UI.

  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Is it possible to change existing property visibility on the UI? We've followed the instructions in the ModuleExtensionConfigurator - configuring visibility of the new properties works but configuring existing (predefinied) properties doesn't. Example:

    You need custom the UI, see https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components , I can send you the UI source code if you need.

    Is it possible to set existing property as required. For example, we need "Surname" property to be required in database.

    You can override the component and override the OnCreatingEntityAsync method

    Example:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(UserManagement))]
    public class MyUserManagement : UserManagement
    {
        protected override Task OnCreatingEntityAsync()
        {
            if (NewEntity.Surname.IsNullOrWhiteSpace())
            {
                Message.Error("surname is required");
    
                return Task.CompletedTask;
            }
    
            return base.OnCreatingEntityAsync();
        }
    }
    

    How to set new property as required in database?

    See https://docs.abp.io/en/abp/latest/Entity-Framework-Core#mapefcoreproperty, you can add a new field via Object Extension Manager

    How to enable client side validation for the property? We've set required attribute with the following:

    The extended UI does not support client-side validation.

  • User Avatar
    0
    stjepanh_teched created

    Is it possible to change existing property visibility on the UI? We've followed the instructions in the ModuleExtensionConfigurator - configuring visibility of the new properties works but configuring existing (predefinied) properties doesn't. Example:

    You need custom the UI, see https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components , I can send you the UI source code if you need.

    Can you please send the source code so we can fix it quicker?

    The extended UI does not support client-side validation.

    By overriding the UI, I can also get the client side validation? If that is correct, can you please also provide source code of the Identity module Edit modal?

    Thank you very much for your help.

  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    See

    https://gist.github.com/realLiangshiwei/cf96030428f67a5e20c4770c1a5e56a8,

    https://gist.github.com/realLiangshiwei/462dc4888a0590606c27a064c46d4918

  • User Avatar
    0
    stjepanh_teched created

    I've managed to make a custom component by the code you provided, but I can't get pass the exception "CustomUserManagement is not assignable to service Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement".

    I also tried to do the most simple case - basic component with plain html just to try replacing the UserManagement, but I get the same exception. This is the basic component:

    @page "/identity/users"
    
    @using Volo.Abp.Identity
    
    @inherits AbpCrudPageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto>
    
    @attribute [Volo.Abp.DependencyInjection.ExposeServices(typeof(Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement))]
    @attribute [Volo.Abp.DependencyInjection.Dependency(ReplaceServices = true)]
    
    <h3>TestUserManagement</h3>
    

    What am I doing wrong?

  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi

    Try:

    @inherits Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement
    
    @attribute [Volo.Abp.DependencyInjection.ExposeServices(typeof(Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement))]
    @attribute [Volo.Abp.DependencyInjection.Dependency(ReplaceServices = true)]
    
    <h3>TestUserManagement</h3>
    
    
  • User Avatar
    0
    stjepanh_teched created

    Thank you for your help, now it works. Is it possible for this component to inherit AbpCrudPageBase so I can inject my custom types?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    UserManagement is already to inherit AbpCrudPageBase

  • User Avatar
    0
    stjepanh_teched created

    Yes, but i would like to set my own DTOs here: AbpCrudPageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto>

  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, you can't do it.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07