From 13624f0f7ebc2f40998abd5fef34360131aca3a3 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 20 Oct 2023 09:51:32 +0200 Subject: [PATCH] add type de champs ej bin/rails generate add_champ EngagementJuridique --- .../engagement_juridique_component.rb | 2 ++ .../engagement_juridique_component/en.yml | 2 ++ .../engagement_juridique_component.html.haml | 1 + .../engagement_juridique_component/fr.yml | 2 ++ app/graphql/api/v2/schema.rb | 3 +- app/graphql/schema.graphql | 33 +++++++++++++++++++ app/graphql/types/champ_descriptor_type.rb | 3 ++ ...agement_juridique_champ_descriptor_type.rb | 5 +++ .../champs/engagement_juridique_champ.rb | 2 ++ app/models/type_de_champ.rb | 7 ++++ .../engagement_juridique_type_de_champ.rb | 2 ++ spec/factories/champ.rb | 7 ++-- spec/factories/type_de_champ.rb | 3 ++ 13 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 app/components/editable_champ/engagement_juridique_component.rb create mode 100644 app/components/editable_champ/engagement_juridique_component/en.yml create mode 100644 app/components/editable_champ/engagement_juridique_component/engagement_juridique_component.html.haml create mode 100644 app/components/editable_champ/engagement_juridique_component/fr.yml create mode 100644 app/graphql/types/champs/descriptor/engagement_juridique_champ_descriptor_type.rb create mode 100644 app/models/champs/engagement_juridique_champ.rb create mode 100644 app/models/types_de_champ/engagement_juridique_type_de_champ.rb diff --git a/app/components/editable_champ/engagement_juridique_component.rb b/app/components/editable_champ/engagement_juridique_component.rb new file mode 100644 index 000000000..223cc0e9e --- /dev/null +++ b/app/components/editable_champ/engagement_juridique_component.rb @@ -0,0 +1,2 @@ +class EditableChamp::EngagementJuridiqueComponent < EditableChamp::EditableChampBaseComponent +end diff --git a/app/components/editable_champ/engagement_juridique_component/en.yml b/app/components/editable_champ/engagement_juridique_component/en.yml new file mode 100644 index 000000000..1491cafbf --- /dev/null +++ b/app/components/editable_champ/engagement_juridique_component/en.yml @@ -0,0 +1,2 @@ +--- +en: diff --git a/app/components/editable_champ/engagement_juridique_component/engagement_juridique_component.html.haml b/app/components/editable_champ/engagement_juridique_component/engagement_juridique_component.html.haml new file mode 100644 index 000000000..e88fc3332 --- /dev/null +++ b/app/components/editable_champ/engagement_juridique_component/engagement_juridique_component.html.haml @@ -0,0 +1 @@ += @form.text_field(:value, input_opts(id: @champ.input_id, required: @champ.required?, aria: { describedby: @champ.describedby_id })) diff --git a/app/components/editable_champ/engagement_juridique_component/fr.yml b/app/components/editable_champ/engagement_juridique_component/fr.yml new file mode 100644 index 000000000..09f6db466 --- /dev/null +++ b/app/components/editable_champ/engagement_juridique_component/fr.yml @@ -0,0 +1,2 @@ +--- +fr: diff --git a/app/graphql/api/v2/schema.rb b/app/graphql/api/v2/schema.rb index ba90e45fb..bef5be7c3 100644 --- a/app/graphql/api/v2/schema.rb +++ b/app/graphql/api/v2/schema.rb @@ -116,7 +116,8 @@ class API::V2::Schema < GraphQL::Schema Types::Champs::Descriptor::TextChampDescriptorType, Types::Champs::Descriptor::TitreIdentiteChampDescriptorType, Types::Champs::Descriptor::YesNoChampDescriptorType, - Types::Champs::Descriptor::ExpressionReguliereChampDescriptorType + Types::Champs::Descriptor::ExpressionReguliereChampDescriptorType, +Types::Champs::Descriptor::EngagementJuridiqueChampDescriptorType def self.unauthorized_object(error) # Add a top-level error to the response instead of returning nil: diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 2b35ec1ae..fdd8c3ad5 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -2172,6 +2172,34 @@ type EmailChampDescriptor implements ChampDescriptor { type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.") } +type EngagementJuridiqueChampDescriptor implements ChampDescriptor { + """ + Description des champs d’un bloc répétable. + """ + champDescriptors: [ChampDescriptor!] @deprecated(reason: "Utilisez le champ `RepetitionChampDescriptor.champ_descriptors` à la place.") + + """ + Description du champ. + """ + description: String + id: ID! + + """ + Libellé du champ. + """ + label: String! + + """ + Est-ce que le champ est obligatoire ? + """ + required: Boolean! + + """ + Type de la valeur du champ. + """ + type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.") +} + type Entreprise { attestationFiscaleAttachment: File attestationSocialeAttachment: File @@ -4019,6 +4047,11 @@ enum TypeDeChamp { """ email + """ + Translation missing: fr.activerecord.attributes.type_de_champ.type_champs.engagement_juridique + """ + engagement_juridique + """ EPCI """ diff --git a/app/graphql/types/champ_descriptor_type.rb b/app/graphql/types/champ_descriptor_type.rb index 44563b102..3cf7d1302 100644 --- a/app/graphql/types/champ_descriptor_type.rb +++ b/app/graphql/types/champ_descriptor_type.rb @@ -22,6 +22,9 @@ module Types definition_methods do def resolve_type(object, context) case object.type_champ + when TypeDeChamp.type_champs.fetch(:engagement_juridique) + Types::Champs::Descriptor::EngagementJuridiqueChampDescriptorType + when TypeDeChamp.type_champs.fetch(:text) Types::Champs::Descriptor::TextChampDescriptorType when TypeDeChamp.type_champs.fetch(:textarea) diff --git a/app/graphql/types/champs/descriptor/engagement_juridique_champ_descriptor_type.rb b/app/graphql/types/champs/descriptor/engagement_juridique_champ_descriptor_type.rb new file mode 100644 index 000000000..9d6928358 --- /dev/null +++ b/app/graphql/types/champs/descriptor/engagement_juridique_champ_descriptor_type.rb @@ -0,0 +1,5 @@ +module Types::Champs::Descriptor + class EngagementJuridiqueChampDescriptorType < Types::BaseObject + implements Types::ChampDescriptorType + end +end diff --git a/app/models/champs/engagement_juridique_champ.rb b/app/models/champs/engagement_juridique_champ.rb new file mode 100644 index 000000000..f21777a8b --- /dev/null +++ b/app/models/champs/engagement_juridique_champ.rb @@ -0,0 +1,2 @@ +class Champs::EngagementJuridiqueChamp < Champ +end diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index f97d89439..2dc807eb4 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -3,9 +3,12 @@ class TypeDeChamp < ApplicationRecord FILE_MAX_SIZE = 200.megabytes FEATURE_FLAGS = { + engagement_juridique: :engagement_juridique_type_de_champ, + cojo: :cojo_type_de_champ, expression_reguliere: :expression_reguliere_type_de_champ } + MINIMUM_TEXTAREA_CHARACTER_LIMIT_LENGTH = 400 STRUCTURE = :structure @@ -20,6 +23,8 @@ class TypeDeChamp < ApplicationRecord CATEGORIES = [STRUCTURE, ETAT_CIVIL, LOCALISATION, PAIEMENT_IDENTIFICATION, STANDARD, PIECES_JOINTES, CHOICE, REFERENTIEL_EXTERNE] TYPE_DE_CHAMP_TO_CATEGORIE = { + engagement_juridique: REFERENTIEL_EXTERNE, + header_section: STRUCTURE, repetition: STRUCTURE, dossier_link: STRUCTURE, @@ -62,6 +67,8 @@ class TypeDeChamp < ApplicationRecord } enum type_champs: { + engagement_juridique: 'engagement_juridique', + header_section: 'header_section', repetition: 'repetition', dossier_link: 'dossier_link', diff --git a/app/models/types_de_champ/engagement_juridique_type_de_champ.rb b/app/models/types_de_champ/engagement_juridique_type_de_champ.rb new file mode 100644 index 000000000..bd076d2c8 --- /dev/null +++ b/app/models/types_de_champ/engagement_juridique_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::EngagementJuridiqueTypeDeChamp < TypesDeChamp::TypeDeChampBase +end diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index 1f422f02f..57c190de4 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -238,9 +238,12 @@ FactoryBot.define do value { 'W173847273' } end + factory :champ_engagement_juridique, class: 'Champs::EngagementJuridiqueChamp' do + type_de_champ { association :type_de_champ_engagement_juridique, procedure: dossier.procedure } +end factory :champ_cojo, class: 'Champs::COJOChamp' do - type_de_champ { association :type_de_champ_cojo, procedure: dossier.procedure } - end + type_de_champ { association :type_de_champ_cojo, procedure: dossier.procedure } + end factory :champ_rnf, class: 'Champs::RNFChamp' do type_de_champ { association :type_de_champ_rnf, procedure: dossier.procedure } diff --git a/spec/factories/type_de_champ.rb b/spec/factories/type_de_champ.rb index 4d49abd7c..062eb609d 100644 --- a/spec/factories/type_de_champ.rb +++ b/spec/factories/type_de_champ.rb @@ -184,6 +184,9 @@ FactoryBot.define do factory :type_de_champ_epci do type_champ { TypeDeChamp.type_champs.fetch(:epci) } end + factory :type_de_champ_engagement_juridique do + type_champ { TypeDeChamp.type_champs.fetch(:engagement_juridique) } + end factory :type_de_champ_cojo do type_champ { TypeDeChamp.type_champs.fetch(:cojo) } end