manager: localize dossier enums

In the previous commit, we cleaned up the localization of the
Dossier.state enum. This prevented administrate from crashing, but now
the dossier enum are no longer localized in the Manager.

By using a `Field::Enum` type, we instruct the administrate plugin
to look up our localized name for the Dossier state enum.
This commit is contained in:
Pierre de La Morinerie 2021-05-06 10:29:52 +00:00
parent b8f71bd52c
commit b398485d97
3 changed files with 5 additions and 1 deletions

View file

@ -6,6 +6,7 @@ gem 'active_model_serializers'
gem 'activestorage-openstack' gem 'activestorage-openstack'
gem 'active_storage_validations' gem 'active_storage_validations'
gem 'administrate', git: 'https://github.com/thoughtbot/administrate.git', ref: 'refs/pull/1972/head' # Provides an administration UI (pull request #1972 has fixes for Rails 6.1.3.2) gem 'administrate', git: 'https://github.com/thoughtbot/administrate.git', ref: 'refs/pull/1972/head' # Provides an administration UI (pull request #1972 has fixes for Rails 6.1.3.2)
gem 'administrate-field-enum' # Allow using Field::Enum in administrate
gem 'after_party' gem 'after_party'
gem 'anchored' gem 'anchored'
gem 'bcrypt' gem 'bcrypt'

View file

@ -102,6 +102,8 @@ GEM
zeitwerk (~> 2.3) zeitwerk (~> 2.3)
addressable (2.7.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
administrate-field-enum (0.0.9)
administrate (~> 0.12)
aes_key_wrap (1.1.0) aes_key_wrap (1.1.0)
after_party (1.11.2) after_party (1.11.2)
anchored (1.1.0) anchored (1.1.0)
@ -776,6 +778,7 @@ DEPENDENCIES
active_storage_validations active_storage_validations
activestorage-openstack activestorage-openstack
administrate! administrate!
administrate-field-enum
after_party after_party
anchored anchored
annotate annotate

View file

@ -10,7 +10,7 @@ class DossierDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = { ATTRIBUTE_TYPES = {
id: Field::Number.with_options(searchable: true), id: Field::Number.with_options(searchable: true),
procedure: Field::HasOne, procedure: Field::HasOne,
state: Field::String, state: Field::Enum,
user: Field::BelongsTo, user: Field::BelongsTo,
text_summary: Field::String.with_options(searchable: false), text_summary: Field::String.with_options(searchable: false),
created_at: Field::DateTime, created_at: Field::DateTime,