Merge pull request #5383 from tchak/graphql-champ-descriptors
Expose repetitions and options on champ_descriptors
This commit is contained in:
commit
266ef479a5
3 changed files with 34 additions and 2 deletions
|
@ -54,6 +54,11 @@ interface Champ {
|
|||
}
|
||||
|
||||
type ChampDescriptor {
|
||||
"""
|
||||
Description des champs d'un bloc répétable.
|
||||
"""
|
||||
champDescriptors: [ChampDescriptor!]
|
||||
|
||||
"""
|
||||
Description du champ.
|
||||
"""
|
||||
|
@ -65,6 +70,11 @@ type ChampDescriptor {
|
|||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
List des options d'un champ avec selection.
|
||||
"""
|
||||
options: [String!]
|
||||
|
||||
"""
|
||||
Est-ce que le champ est obligatoire ?
|
||||
"""
|
||||
|
@ -1317,4 +1327,4 @@ type ValidationError {
|
|||
A description of the error
|
||||
"""
|
||||
message: String!
|
||||
}
|
||||
}
|
|
@ -13,5 +13,20 @@ module Types
|
|||
field :label, String, "Libellé du champ.", null: false, method: :libelle
|
||||
field :description, String, "Description du champ.", null: true
|
||||
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
|
||||
|
|
|
@ -74,6 +74,11 @@ describe API::V2::GraphqlController do
|
|||
label
|
||||
description
|
||||
required
|
||||
champDescriptors {
|
||||
id
|
||||
type
|
||||
}
|
||||
options
|
||||
}
|
||||
dossiers {
|
||||
nodes {
|
||||
|
@ -129,7 +134,9 @@ describe API::V2::GraphqlController do
|
|||
label: tdc.libelle,
|
||||
type: tdc.type_champ,
|
||||
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,
|
||||
dossiers: {
|
||||
|
|
Loading…
Reference in a new issue