From ce466d072a38694b6fe8266b978069492f57cb58 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 19 Apr 2023 18:29:18 +0200 Subject: [PATCH] feat(manager): display procedure state and unpublished date --- app/dashboards/procedure_dashboard.rb | 5 ++++- app/fields/procedure_state_field.rb | 7 +++++++ app/graphql/schema.graphql | 2 +- app/models/procedure.rb | 9 +++++++++ app/views/fields/procedure_state_field/_index.html.haml | 2 ++ app/views/fields/procedure_state_field/_show.html.haml | 2 ++ config/locales/models/procedure/fr.yml | 1 + 7 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 app/fields/procedure_state_field.rb create mode 100644 app/views/fields/procedure_state_field/_index.html.haml create mode 100644 app/views/fields/procedure_state_field/_show.html.haml diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index 4b0bae3c8..ee76168bd 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -11,6 +11,7 @@ class ProcedureDashboard < Administrate::BaseDashboard published_types_de_champ_public: TypesDeChampCollectionField, published_types_de_champ_private: TypesDeChampCollectionField, path: ProcedureLinkField, + aasm_state: ProcedureStateField, dossiers: Field::HasMany, administrateurs: Field::HasMany, id: Field::Number.with_options(searchable: true), @@ -56,7 +57,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :service, :dossiers, :published_at, - :unpublished_at + :aasm_state ].freeze # SHOW_PAGE_ATTRIBUTES @@ -64,6 +65,7 @@ class ProcedureDashboard < Administrate::BaseDashboard SHOW_PAGE_ATTRIBUTES = [ :id, :path, + :aasm_state, :administrateurs, :libelle, :description, @@ -78,6 +80,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :whitelisted_at, :hidden_at, :closed_at, + :unpublished_at, :published_types_de_champ_public, :published_types_de_champ_private, :for_individual, diff --git a/app/fields/procedure_state_field.rb b/app/fields/procedure_state_field.rb new file mode 100644 index 000000000..0f2f7752e --- /dev/null +++ b/app/fields/procedure_state_field.rb @@ -0,0 +1,7 @@ +require "administrate/field/base" + +class ProcedureStateField < Administrate::Field::String + def name + "Statut" + end +end diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index e53f05039..ad44d1648 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -1070,7 +1070,7 @@ enum DemarcheState { close """ - Depubliee + Dépubliée """ depubliee diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 1b0713dea..955f3afbe 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -917,4 +917,13 @@ class Procedure < ApplicationRecord def stable_ids_used_by_routing_rules @stable_ids_used_by_routing_rules ||= groupe_instructeurs.flat_map { _1.routing_rule&.sources }.compact end + + # We need this to unfuck administrate + aasm + def self.human_attribute_name(attribute, options = {}) + if attribute == :aasm_state + 'Statut' + else + super + end + end end diff --git a/app/views/fields/procedure_state_field/_index.html.haml b/app/views/fields/procedure_state_field/_index.html.haml new file mode 100644 index 000000000..1f9061a3e --- /dev/null +++ b/app/views/fields/procedure_state_field/_index.html.haml @@ -0,0 +1,2 @@ +- if field.data.present? + = t field.data, scope: 'activerecord.attributes.procedure.aasm_state' diff --git a/app/views/fields/procedure_state_field/_show.html.haml b/app/views/fields/procedure_state_field/_show.html.haml new file mode 100644 index 000000000..1f9061a3e --- /dev/null +++ b/app/views/fields/procedure_state_field/_show.html.haml @@ -0,0 +1,2 @@ +- if field.data.present? + = t field.data, scope: 'activerecord.attributes.procedure.aasm_state' diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index 53f378a3e..2c223d149 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -20,6 +20,7 @@ fr: publiee: Publiée close: Close hidden: Supprimée + depubliee: Dépubliée declarative_with_state/en_instruction: En instruction declarative_with_state/accepte: Accepté api_particulier_token: Jeton API Particulier