Open Closed

module entity extension with one-many List from custom repository #426


User avatar
0
mmorrisset created
  • ABP Framework version: v3.1.2
  • UI type: MVC
  • Tiered (MVC) or Identity Server Seperated (Angular): no
  • Exception message and stack trace: NA
  • Steps to reproduce the issue:

Hi, Started with the community edition and just bought the Commercial version for the modules / template. Created a new Commercial project and merged in my existing code. I have the basics figured out for adding columns to ABP (AppUsers) entities. With the OSS version I was overriding the Identity pages (Index, createmodal, editmodal) to display a drop down and all was well. It appears that I cannot do that with the commercial version. I can not get my existing overrides to work. Started reading the docs and found the "module entity extensions". I have my fields added to AbpUsers and displaying in the UI but I don't know how to make my "CountryId" field display as a drop down. Closest I found was https://docs.abp.io/en/commercial/latest/guides/module-entity-extensions#special-types which deals with enums. I essentially need the enum to be a list of Countries from another repo.

DB structure looks like this.

AbpUsers
added CountryId Guid

Country Entity
Id Guid
CountryName String

In my Createmodal and EditModal view model I had a property like so:

        [SelectItems(nameof(Countries))]
        [DisplayName("Country")]
        [BindProperty]
        public Guid CountryId { get; set; }

Countries was gathered like so:

            var cLkUp = await _countryAppService.GetCountryLookupAsync(Guid.Empty);
            if (cLkUp.Items.Count > 1 && cLkUp.Items[1] != null)
            {
                Countries = cLkUp.Items
                    .Where(x => x != null)
                    .Select(x => new SelectListItem(x.Name, x.Id.ToString()))
                    .ToList();
            }

I need what this this article is detailing, except the other way around. A user has a country. Countries have many users.

https://community.abp.io/articles/abp-suite-how-to-add-the-user-entity-as-a-navigation-property-of-another-entity-furp75ex


3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    this may help you https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities

  • User Avatar
    0
    mmorrisset created

    Thank you for your response but that is not what I'm asking. I already have the field added to abpUsers and displaying as a text box in the user create/edit modals. I need to add a combo box to the user create/edit modal pages that is generated from my own custom table.

    It appears that it has been documented here for Angular but not for MVC: https://docs.abp.io/en/commercial/latest/ui/angular/dynamic-form-extensions

    Appreciate any assistance as this is a major blocker for me right now. This is my User Edit form. I need CountryId to be a drop down of countries that saves the GUID.

  • User Avatar
    0
    alper created
    Support Team Director

    hi I just checked what you want, and it's not implemented yet. it's on the roadmap. so you cannot add a navigation property to another entity by using entity extension feature. alternatively you can add CountryId to the IdentityUser entity and override the User Edit Form.

    I uploaded User create, edit, index pages https://drive.google.com/file/d/1oURFFVMBcHHg73I-zxUBbRw-M9nUxDR7/view?usp=sharing

    if you override the cshtml files and javascript files and put them in the shown location in your web project as embedded source, then you'll be overrided these files

    also see how to override a UI https://docs.abp.io/en/abp/latest/UI/AspNetCore/Customization-User-Interface

    still couldn't succeed? mail to info@abp.io

Made with ❤️ on ABP v9.0.0-preview. Updated on October 07, 2024, 08:52