refactor(graphql): fix types_de_champ usage
This commit is contained in:
parent
7003014831
commit
ee50b8ad25
4 changed files with 17 additions and 11 deletions
|
@ -18,14 +18,14 @@ module Types
|
|||
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)
|
||||
if object.type_de_champ.repetition?
|
||||
Loaders::Association.for(object.class, :revision_types_de_champ).load(object)
|
||||
end
|
||||
end
|
||||
|
||||
def options
|
||||
if object.drop_down_list?
|
||||
object.drop_down_list_options.reject(&:empty?)
|
||||
if object.type_de_champ.drop_down_list?
|
||||
object.type_de_champ.drop_down_list_options.reject(&:empty?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,8 +48,8 @@ module Types
|
|||
argument :deleted_since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers supprimés depuis la date."
|
||||
end
|
||||
|
||||
field :champ_descriptors, [Types::ChampDescriptorType], null: false, method: :types_de_champ
|
||||
field :annotation_descriptors, [Types::ChampDescriptorType], null: false, method: :types_de_champ_private
|
||||
field :champ_descriptors, [Types::ChampDescriptorType], null: false
|
||||
field :annotation_descriptors, [Types::ChampDescriptorType], null: false
|
||||
|
||||
field :draft_revision, Types::RevisionType, null: false
|
||||
field :published_revision, Types::RevisionType, null: true
|
||||
|
@ -120,6 +120,14 @@ module Types
|
|||
dossiers.order(deleted_at: order)
|
||||
end
|
||||
|
||||
def champ_descriptors
|
||||
object.active_revision.revision_types_de_champ_public
|
||||
end
|
||||
|
||||
def annotation_descriptors
|
||||
object.active_revision.revision_types_de_champ_private
|
||||
end
|
||||
|
||||
def self.authorized?(object, context)
|
||||
context.authorized_demarche?(object)
|
||||
end
|
||||
|
|
|
@ -8,11 +8,11 @@ module Types
|
|||
field :annotation_descriptors, [Types::ChampDescriptorType], null: false
|
||||
|
||||
def champ_descriptors
|
||||
Loaders::Association.for(object.class, :types_de_champ_public).load(object)
|
||||
Loaders::Association.for(object.class, revision_types_de_champ_public: :type_de_champ).load(object)
|
||||
end
|
||||
|
||||
def annotation_descriptors
|
||||
Loaders::Association.for(object.class, :types_de_champ_private).load(object)
|
||||
Loaders::Association.for(object.class, revision_types_de_champ_private: :type_de_champ).load(object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,9 +22,7 @@ class ProcedureRevisionTypeDeChamp < ApplicationRecord
|
|||
scope :public_only, -> { joins(:type_de_champ).where(types_de_champ: { private: false }) }
|
||||
scope :private_only, -> { joins(:type_de_champ).where(types_de_champ: { private: true }) }
|
||||
|
||||
def private?
|
||||
type_de_champ.private?
|
||||
end
|
||||
delegate :stable_id, :libelle, :description, :type_champ, :mandatory?, :private?, :to_typed_id, to: :type_de_champ
|
||||
|
||||
def child?
|
||||
parent_id.present?
|
||||
|
|
Loading…
Reference in a new issue