Merge pull request #8323 from tchak/fix-graphql-champs
feat(graphql): add pays champ to API
This commit is contained in:
commit
62813f3d74
6 changed files with 53 additions and 6 deletions
|
@ -59,6 +59,7 @@ class API::V2::Schema < GraphQL::Schema
|
|||
Types::Champs::IntegerNumberChampType,
|
||||
Types::Champs::LinkedDropDownListChampType,
|
||||
Types::Champs::MultipleDropDownListChampType,
|
||||
Types::Champs::PaysChampType,
|
||||
Types::Champs::PieceJustificativeChampType,
|
||||
Types::Champs::RegionChampType,
|
||||
Types::Champs::RepetitionChampType,
|
||||
|
|
|
@ -454,6 +454,12 @@ class API::V2::StoredQuery
|
|||
code
|
||||
}
|
||||
}
|
||||
... on PaysChamp {
|
||||
pays {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
... on SiretChamp {
|
||||
etablissement {
|
||||
...PersonneMoraleFragment
|
||||
|
|
|
@ -2017,6 +2017,26 @@ type ParcelleCadastrale implements GeoArea {
|
|||
surfaceParcelle: Float! @deprecated(reason: "Utilisez le champ `surface` à la place.")
|
||||
}
|
||||
|
||||
type Pays {
|
||||
code: String!
|
||||
name: String!
|
||||
}
|
||||
|
||||
type PaysChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
pays: Pays
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
type PersonneMorale implements Demandeur {
|
||||
address: Address!
|
||||
adresse: String! @deprecated(reason: "Utilisez le champ `address.label` à la place.")
|
||||
|
|
|
@ -43,6 +43,12 @@ module Types
|
|||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
when ::Champs::PaysChamp
|
||||
if context.has_fragment?(:PaysChamp)
|
||||
Types::Champs::PaysChampType
|
||||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
when ::Champs::DossierLinkChamp
|
||||
Types::Champs::DossierLinkChampType
|
||||
when ::Champs::PieceJustificativeChamp
|
||||
|
|
16
app/graphql/types/champs/pays_champ_type.rb
Normal file
16
app/graphql/types/champs/pays_champ_type.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Types::Champs
|
||||
class PaysChampType < Types::BaseObject
|
||||
implements Types::ChampType
|
||||
|
||||
class PaysType < Types::BaseObject
|
||||
field :name, String, null: false
|
||||
field :code, String, null: false
|
||||
end
|
||||
|
||||
field :pays, PaysType, null: true
|
||||
|
||||
def pays
|
||||
object if object.external_id.present?
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,15 +22,15 @@
|
|||
#
|
||||
class Champs::PaysChamp < Champs::TextChamp
|
||||
def for_export
|
||||
[formatted_value, code]
|
||||
[name, code]
|
||||
end
|
||||
|
||||
def to_s
|
||||
formatted_value
|
||||
name
|
||||
end
|
||||
|
||||
def for_tag
|
||||
formatted_value
|
||||
name
|
||||
end
|
||||
|
||||
def selected
|
||||
|
@ -54,9 +54,7 @@ class Champs::PaysChamp < Champs::TextChamp
|
|||
external_id || APIGeoService.country_code(value)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def formatted_value
|
||||
def name
|
||||
if external_id
|
||||
APIGeoService.country_name(external_id)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue