Add demarche champs and annotations types
This commit is contained in:
parent
a51fc75628
commit
8928eaba11
4 changed files with 171 additions and 0 deletions
|
@ -1,8 +1,18 @@
|
|||
type ChampInfo {
|
||||
description: String
|
||||
id: ID!
|
||||
label: String!
|
||||
required: Boolean!
|
||||
type: TypeDeChamp!
|
||||
}
|
||||
|
||||
"""
|
||||
Une demarche
|
||||
"""
|
||||
type Demarche {
|
||||
annotations: [ChampInfo!]!
|
||||
archivedAt: ISO8601DateTime
|
||||
champs: [ChampInfo!]!
|
||||
createdAt: ISO8601DateTime!
|
||||
|
||||
"""
|
||||
|
@ -245,6 +255,143 @@ type Query {
|
|||
): Dossier!
|
||||
}
|
||||
|
||||
enum TypeDeChamp {
|
||||
"""
|
||||
Adresse
|
||||
"""
|
||||
address
|
||||
|
||||
"""
|
||||
Carte
|
||||
"""
|
||||
carte
|
||||
|
||||
"""
|
||||
Case à cocher
|
||||
"""
|
||||
checkbox
|
||||
|
||||
"""
|
||||
Civilité
|
||||
"""
|
||||
civilite
|
||||
|
||||
"""
|
||||
Date
|
||||
"""
|
||||
date
|
||||
|
||||
"""
|
||||
Date et Heure
|
||||
"""
|
||||
datetime
|
||||
|
||||
"""
|
||||
Nombre décimal
|
||||
"""
|
||||
decimal_number
|
||||
|
||||
"""
|
||||
Départements
|
||||
"""
|
||||
departements
|
||||
|
||||
"""
|
||||
Lien vers un autre dossier
|
||||
"""
|
||||
dossier_link
|
||||
|
||||
"""
|
||||
Menu déroulant
|
||||
"""
|
||||
drop_down_list
|
||||
|
||||
"""
|
||||
Email
|
||||
"""
|
||||
email
|
||||
|
||||
"""
|
||||
Engagement
|
||||
"""
|
||||
engagement
|
||||
|
||||
"""
|
||||
Explication
|
||||
"""
|
||||
explication
|
||||
|
||||
"""
|
||||
Titre de section
|
||||
"""
|
||||
header_section
|
||||
|
||||
"""
|
||||
Nombre entier
|
||||
"""
|
||||
integer_number
|
||||
|
||||
"""
|
||||
Deux menus déroulants liés
|
||||
"""
|
||||
linked_drop_down_list
|
||||
|
||||
"""
|
||||
Menu déroulant à choix multiples
|
||||
"""
|
||||
multiple_drop_down_list
|
||||
|
||||
"""
|
||||
Nombre entier
|
||||
"""
|
||||
number
|
||||
|
||||
"""
|
||||
Pays
|
||||
"""
|
||||
pays
|
||||
|
||||
"""
|
||||
Téléphone
|
||||
"""
|
||||
phone
|
||||
|
||||
"""
|
||||
Pièce justificative
|
||||
"""
|
||||
piece_justificative
|
||||
|
||||
"""
|
||||
Régions
|
||||
"""
|
||||
regions
|
||||
|
||||
"""
|
||||
Bloc répétable
|
||||
"""
|
||||
repetition
|
||||
|
||||
"""
|
||||
SIRET
|
||||
"""
|
||||
siret
|
||||
|
||||
"""
|
||||
Texte
|
||||
"""
|
||||
text
|
||||
|
||||
"""
|
||||
Zone de texte
|
||||
"""
|
||||
textarea
|
||||
|
||||
"""
|
||||
Oui/Non
|
||||
"""
|
||||
yes_no
|
||||
}
|
||||
|
||||
"""
|
||||
A valid URL, transported as a string
|
||||
"""
|
||||
|
|
17
app/graphql/types/champ_descriptor_type.rb
Normal file
17
app/graphql/types/champ_descriptor_type.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module Types
|
||||
class ChampDescriptorType < Types::BaseObject
|
||||
class TypeDeChampType < Types::BaseEnum
|
||||
TypeDeChamp.type_champs.each do |symbol_name, string_name|
|
||||
value(string_name,
|
||||
I18n.t(symbol_name, scope: [:activerecord, :attributes, :type_de_champ, :type_champs]),
|
||||
value: symbol_name)
|
||||
end
|
||||
end
|
||||
|
||||
global_id_field :id
|
||||
field :type, TypeDeChampType, null: false, method: :type_champ
|
||||
field :label, String, null: false, method: :libelle
|
||||
field :description, String, null: true
|
||||
field :required, Boolean, null: false, method: :mandatory?
|
||||
end
|
||||
end
|
|
@ -25,6 +25,9 @@ module Types
|
|||
argument :since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers crées depuis la date."
|
||||
end
|
||||
|
||||
field :champ_descriptors, [Types::ChampDescriptorType], null: false, method: :types_de_champ
|
||||
field :annotation_descriptors, [Types::ChampDescriptorType], null: false, method: :types_de_champ_private
|
||||
|
||||
def state
|
||||
object.aasm.current_state
|
||||
end
|
||||
|
|
|
@ -185,6 +185,10 @@ class TypeDeChamp < ApplicationRecord
|
|||
self.drop_down_list_attributes = { value: value }
|
||||
end
|
||||
|
||||
def to_typed_id
|
||||
GraphQL::Schema::UniqueWithinType.encode('Champ', stable_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_default_drop_down_list
|
||||
|
|
Loading…
Reference in a new issue