expose id, title and address rnf for API
This commit is contained in:
parent
6984dac41e
commit
3be2a8878c
5 changed files with 88 additions and 0 deletions
|
@ -63,6 +63,7 @@ class API::V2::Schema < GraphQL::Schema
|
|||
Types::Champs::DepartementChampType,
|
||||
Types::Champs::DossierLinkChampType,
|
||||
Types::Champs::EpciChampType,
|
||||
Types::Champs::RNFChampType,
|
||||
Types::Champs::IntegerNumberChampType,
|
||||
Types::Champs::LinkedDropDownListChampType,
|
||||
Types::Champs::MultipleDropDownListChampType,
|
||||
|
|
|
@ -564,6 +564,11 @@ class API::V2::StoredQuery
|
|||
...PersonneMoraleFragment
|
||||
}
|
||||
}
|
||||
... on RNFChamp {
|
||||
rnf {
|
||||
...RNFFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment PersonneMoraleFragment on PersonneMorale {
|
||||
|
@ -666,6 +671,14 @@ class API::V2::StoredQuery
|
|||
postalCode
|
||||
}
|
||||
|
||||
fragment RNFFragment on RNF {
|
||||
id
|
||||
title
|
||||
address {
|
||||
...AddressFragment
|
||||
}
|
||||
}
|
||||
|
||||
fragment PageInfoFragment on PageInfo {
|
||||
hasPreviousPage
|
||||
hasNextPage
|
||||
|
|
|
@ -3581,6 +3581,33 @@ type RNAChampDescriptor implements ChampDescriptor {
|
|||
type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.")
|
||||
}
|
||||
|
||||
type RNF {
|
||||
address: Address
|
||||
id: String!
|
||||
title: String
|
||||
}
|
||||
|
||||
type RNFChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
prefilled: Boolean!
|
||||
rnf: RNF
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
|
||||
"""
|
||||
Date de dernière modification du champ.
|
||||
"""
|
||||
updatedAt: ISO8601DateTime!
|
||||
}
|
||||
|
||||
type RNFChampDescriptor implements ChampDescriptor {
|
||||
"""
|
||||
Description des champs d’un bloc répétable.
|
||||
|
|
|
@ -75,6 +75,8 @@ module Types
|
|||
Types::Champs::TitreIdentiteChampType
|
||||
when ::Champs::EpciChamp
|
||||
Types::Champs::EpciChampType
|
||||
when ::Champs::RNFChamp
|
||||
Types::Champs::RNFChampType
|
||||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
|
|
45
app/graphql/types/champs/rnf_champ_type.rb
Normal file
45
app/graphql/types/champs/rnf_champ_type.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
module Types::Champs
|
||||
class RNFChampType < Types::BaseObject
|
||||
implements Types::ChampType
|
||||
|
||||
class RNFType < Types::BaseObject
|
||||
field :id, String, null: false
|
||||
field :title, String, null: true
|
||||
field :address, Types::AddressType, null: true
|
||||
|
||||
def id
|
||||
object.value
|
||||
end
|
||||
|
||||
def title
|
||||
object.data["title"]
|
||||
end
|
||||
|
||||
def address
|
||||
address = object.data["address"]
|
||||
if address
|
||||
{
|
||||
label: address["label"],
|
||||
type: address["type"],
|
||||
street_address: address["streetAddress"],
|
||||
street_number: address["streetNumber"],
|
||||
street_name: address["streetName"],
|
||||
postal_code: address["postalCode"],
|
||||
city_name: address["cityName"],
|
||||
city_code: address["cityCode"],
|
||||
department_name: address["departmentName"],
|
||||
department_code: address["departmentCode"],
|
||||
region_name: address["regionName"],
|
||||
region_code: address["regionCode"]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
field :rnf, RNFType, null: true
|
||||
|
||||
def rnf
|
||||
object if object.external_id.present?
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue