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

Support AR enums in resource models #2210

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

robinboening
Copy link
Contributor

@robinboening robinboening commented Nov 5, 2021

This PR adds support for ActiveRecord enums, in the context of Alchemy resource models.
If a resource model has enum values defined they'll be rendered in a select box within the resource form.

Example view
Screenshot 2021-11-05 at 16 55 58

If we agree on this proposal I can add a test as well. I think adding a spec shouldn't be a big deal.

@robinboening robinboening force-pushed the resource_enum_support branch from 6ed88ca to e1e3729 Compare November 5, 2021 17:00
@robinboening robinboening requested a review from a team November 5, 2021 17:00
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the idea. Do we need to translate the enums?

@tvdeyen tvdeyen added this to the 6.0 milestone Nov 18, 2021
@robinboening robinboening requested a review from tvdeyen November 22, 2021 21:22
@robinboening robinboening force-pushed the resource_enum_support branch 3 times, most recently from 42c8434 to 56de65a Compare November 27, 2021 23:38
@robinboening robinboening force-pushed the resource_enum_support branch 2 times, most recently from 65e755a to c59d5cc Compare March 24, 2022 21:01
@robinboening
Copy link
Contributor Author

@tvdeyen any chance we can get this PR in before the next release? I believe it's ready from my side.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature. I agree with the translation key, but I think we should not raise for missing translations.

@robinboening robinboening force-pushed the resource_enum_support branch from c59d5cc to 6c52755 Compare March 31, 2022 20:54
translate enum values using I18n

```
activerecord:
  attributes:
    modelname:
      enumname: translated name
      enumname_values:
        value1: translated value 1
        value2: translated value 2
```
@robinboening robinboening force-pushed the resource_enum_support branch from 6c52755 to 473edb6 Compare March 31, 2022 21:07
@tvdeyen tvdeyen merged commit a4397f2 into AlchemyCMS:main Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants