marmelab / ng-admin

Add an AngularJS admin GUI to any RESTful API
http://ng-admin-book.marmelab.com/
MIT License
3.95k stars 728 forks source link

Enums no appropriate shows in admin #1395

Closed malinich closed 4 years ago

malinich commented 4 years ago

Thanks for your product. It helps much.

Scope

In admin-panel some list resources that have enum property

Prerequisites

class AuthConfirmType(enum.Enum):
    SMS = "СМС"
    BIRTH_DAY = "Дата рождения"

settings = sa.Table(
    "settings",
    meta,
    sa.Column("id", sa.Integer(), primary_key=True),
   .....
   sa.Column(
        "auth_confirm_by",
        sa.Enum(AuthConfirmType),
        nullable=True,
    )
)

Description

In admin-panel I catch error on detail-action. if I change enums on this (add str )

class AuthConfirmType(str, enum.Enum):
    SMS = "СМС"
    BIRTH_DAY = "Дата рождения"

I will catch misleading value, that no will use properly.

To hook this misbehavior need override jsonEncoder, but in PGResource I can't use mixins, ( only copy-paste, It's pain