add type de champs ej bin/rails generate add_champ EngagementJuridique

This commit is contained in:
Martin 2023-10-20 09:51:32 +02:00
parent 6ade116a0e
commit 13624f0f7e
13 changed files with 69 additions and 3 deletions

View file

@ -0,0 +1,2 @@
class EditableChamp::EngagementJuridiqueComponent < EditableChamp::EditableChampBaseComponent
end

View file

@ -0,0 +1,2 @@
---
en:

View file

@ -0,0 +1 @@
= @form.text_field(:value, input_opts(id: @champ.input_id, required: @champ.required?, aria: { describedby: @champ.describedby_id }))

View file

@ -0,0 +1,2 @@
---
fr:

View file

@ -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:

View file

@ -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 dun 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
"""

View file

@ -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)

View file

@ -0,0 +1,5 @@
module Types::Champs::Descriptor
class EngagementJuridiqueChampDescriptorType < Types::BaseObject
implements Types::ChampDescriptorType
end
end

View file

@ -0,0 +1,2 @@
class Champs::EngagementJuridiqueChamp < Champ
end

View file

@ -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',

View file

@ -0,0 +1,2 @@
class TypesDeChamp::EngagementJuridiqueTypeDeChamp < TypesDeChamp::TypeDeChampBase
end

View file

@ -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 }

View file

@ -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