Expose repetitions and options on champ_descriptors
This commit is contained in:
parent
eb6c4b3dd1
commit
86f562e7ea
3 changed files with 34 additions and 2 deletions
|
@ -54,6 +54,11 @@ interface Champ {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChampDescriptor {
|
type ChampDescriptor {
|
||||||
|
"""
|
||||||
|
Description des champs d'un bloc répétable.
|
||||||
|
"""
|
||||||
|
champDescriptors: [ChampDescriptor!]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Description du champ.
|
Description du champ.
|
||||||
"""
|
"""
|
||||||
|
@ -65,6 +70,11 @@ type ChampDescriptor {
|
||||||
"""
|
"""
|
||||||
label: String!
|
label: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
List des options d'un champ avec selection.
|
||||||
|
"""
|
||||||
|
options: [String!]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Est-ce que le champ est obligatoire ?
|
Est-ce que le champ est obligatoire ?
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -13,5 +13,20 @@ module Types
|
||||||
field :label, String, "Libellé du champ.", null: false, method: :libelle
|
field :label, String, "Libellé du champ.", null: false, method: :libelle
|
||||||
field :description, String, "Description du champ.", null: true
|
field :description, String, "Description du champ.", null: true
|
||||||
field :required, Boolean, "Est-ce que le champ est obligatoire ?", null: false, method: :mandatory?
|
field :required, Boolean, "Est-ce que le champ est obligatoire ?", null: false, method: :mandatory?
|
||||||
|
|
||||||
|
field :champ_descriptors, [Types::ChampDescriptorType], "Description des champs d'un bloc répétable.", null: true
|
||||||
|
field :options, [String], "List des options d'un champ avec selection.", null: true
|
||||||
|
|
||||||
|
def champ_descriptors
|
||||||
|
if object.repetition?
|
||||||
|
Loaders::Association.for(object.class, :types_de_champ).load(object)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def options
|
||||||
|
if object.drop_down_list?
|
||||||
|
object.drop_down_list_options.reject(&:empty?)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,6 +74,11 @@ describe API::V2::GraphqlController do
|
||||||
label
|
label
|
||||||
description
|
description
|
||||||
required
|
required
|
||||||
|
champDescriptors {
|
||||||
|
id
|
||||||
|
type
|
||||||
|
}
|
||||||
|
options
|
||||||
}
|
}
|
||||||
dossiers {
|
dossiers {
|
||||||
nodes {
|
nodes {
|
||||||
|
@ -129,7 +134,9 @@ describe API::V2::GraphqlController do
|
||||||
label: tdc.libelle,
|
label: tdc.libelle,
|
||||||
type: tdc.type_champ,
|
type: tdc.type_champ,
|
||||||
description: tdc.description,
|
description: tdc.description,
|
||||||
required: tdc.mandatory?
|
required: tdc.mandatory?,
|
||||||
|
champDescriptors: tdc.repetition? ? tdc.reload.types_de_champ.map { |tdc| { id: tdc.to_typed_id, type: tdc.type_champ } } : nil,
|
||||||
|
options: tdc.drop_down_list? ? tdc.drop_down_list_options.reject(&:empty?) : nil
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
dossiers: {
|
dossiers: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue