Add demarche champs and annotations types

This commit is contained in:
Paul Chavard 2018-11-23 18:55:54 +01:00
parent a51fc75628
commit 8928eaba11
4 changed files with 171 additions and 0 deletions

View file

@ -1,8 +1,18 @@
type ChampInfo {
description: String
id: ID!
label: String!
required: Boolean!
type: TypeDeChamp!
}
""" """
Une demarche Une demarche
""" """
type Demarche { type Demarche {
annotations: [ChampInfo!]!
archivedAt: ISO8601DateTime archivedAt: ISO8601DateTime
champs: [ChampInfo!]!
createdAt: ISO8601DateTime! createdAt: ISO8601DateTime!
""" """
@ -245,6 +255,143 @@ type Query {
): Dossier! ): 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 A valid URL, transported as a string
""" """

View 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

View file

@ -25,6 +25,9 @@ module Types
argument :since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers crées depuis la date." argument :since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers crées depuis la date."
end 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 def state
object.aasm.current_state object.aasm.current_state
end end

View file

@ -185,6 +185,10 @@ class TypeDeChamp < ApplicationRecord
self.drop_down_list_attributes = { value: value } self.drop_down_list_attributes = { value: value }
end end
def to_typed_id
GraphQL::Schema::UniqueWithinType.encode('Champ', stable_id)
end
private private
def set_default_drop_down_list def set_default_drop_down_list