Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings: Anatomy template enumerator #436

Open
jakubjezek001 opened this issue Nov 14, 2024 · 2 comments
Open

Settings: Anatomy template enumerator #436

jakubjezek001 opened this issue Nov 14, 2024 · 2 comments
Assignees
Labels
type: enhancement Improvement of existing functionality or minor addition

Comments

@jakubjezek001
Copy link
Member

jakubjezek001 commented Nov 14, 2024

Current Issue

We currently lack an enumerator for selecting available templates. This would help us avoid potential issues with mistyping text input.

Enhancement Proposal

Let's create another enumerator helper function similar to link_types_enum. We could name it anatomy_template_items_enum. This function should include options for selecting specific template types, like delivery, for example. This way, we can easily select only the delivery category of anatomy templates.

delivery_template_names: list[str] = anatomy_template_items_enum(project_name, "delivery")
@jakubjezek001
Copy link
Member Author

@iLLiCiTiT might also have some openion about it?

@jakubjezek001 jakubjezek001 added the type: enhancement Improvement of existing functionality or minor addition label Nov 14, 2024
@iLLiCiTiT
Copy link
Member

iLLiCiTiT commented Nov 14, 2024

I agree we need it.

But I just realized that from technical point of view it probably cannot be done with argument in function because project name is filled dynamically from the model, whereas we want to define it for the field.

Ideal usecase are these two options (we can support both).

delivery_template_names_a: list[str] = SettingsField(
     default_factory=list,
     enum_items=get_anatomy_templates_enum("delivery"),
)

delivery_template_names_b: list[str] = SettingsField(
     default_factory=list,
     enum_items=anatomy_delivery_templates_enum,
)
def _real_templates_getter(project_name: str | None, category_name: str):
    ...Implementation of the project anatomy query and getting template names from category


def anatomy_delivery_templates_enum(project_name: str | None = None):
    return _real_templates_getter(project_name, "delivery")

...
Other templates category enum methods
...


def get_anatomy_templates_enum(category_name: str):
    if category_name == "delivery":
        return anatomy_delivery_templates_enum
    if category_name == "publish":
        ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvement of existing functionality or minor addition
Projects
None yet
Development

No branches or pull requests

3 participants