ServiceStack Locode Multi select option

Viewed 26

I am developing an app and got a feature where an user can assign multiple User's to a Feature . I want the Create Feature page (locode) to populate the list of available users so that the end-user can assign multiple users to a feature. As of now it is not able to populate the User list.

Is there an alternate way or do I need to write the custom template and populate the data on mount() lifecycle?

Below is the DTO,

[Route("/feature", "POST")]
    public class CreateFeatureFlag : ICreateDb<Feature>, IReturn<FeatureCreated>
    {    
        [ValidateNotEmpty]
        public string Name { get; set; }
    
        [ValidateNotEmpty]
        public List<Guid> Users{ get; set; }
    }

and the Domain Feature,

 [UniqueConstraint(nameof(Name))]
        public class Feature : AuditBase
        {
            [AutoId]
            public Guid Id { get; set; }           
    
            public string Name { get; set; }
    
            [Reference]
            public List<User> Users { get; set; } = new();   
           
        }
1 Answers

In Locode it would require a custom Form component to implement it in the same form, but you can add related records by navigating to the child relation then adding the child record where it will preserve and prepopulate the parent id.

This is used a lot in https://talent.locode.dev like navigating to a Job's Job Applications defined by its POCO Reference:

locode references

public class Job : AuditBase
{
    //...
    public List<JobApplication> Applications { get; set; } = new();
}

Which will prepopulate the Job Id reference making it easy to add multiple 1:Many Job Applications.

Checkout its Talent.cs DTOs for more Reference examples.

Related