Skip to content

Efficiently use enum as a value in Combobox? #418

@RandomInsano

Description

@RandomInsano

I have a few different enums I want users to be able to select with Thaw. The way I'm currently doing that is marshalling back and forth from strings and this is leading to a significant amount of code. I'm considering whether I should create custom components for each enum type and/or create some generic solution. I'm curious if something like this already exists:

enum Status {
    Open,
    Closed
}

let status_mapping = [
    (Status::Open, "Ouvert")
    (Status::Closed, "Fermer")
];

let current_status = vec![Status::Open];
let selected_options;

view! {
    <CustomSelect options=status_mapping value=current_status selected_options>
}

I want to keep display information on the client side and these enums are defined the back-end, so I'd rather not use a macro or traits for things that may need to be translated. Is there a good way to do this already or am I created a component that takes Model<T> and VecModel<T>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions