Merge pull request #7488 from tchak/fix-graphql-demarche-descriptor
fix(graphql): DemarcheDescriptorType can ba a revision or a procedure
This commit is contained in:
commit
070a89db11
1 changed files with 23 additions and 13 deletions
|
@ -21,55 +21,65 @@ Cela évite l’accès récursif aux dossiers."
|
||||||
field :service, Types::ServiceType, null: false
|
field :service, Types::ServiceType, null: false
|
||||||
|
|
||||||
def service
|
def service
|
||||||
Loaders::Record.for(Service).load(object.procedure.service_id)
|
Loaders::Record.for(Service).load(procedure.service_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
object
|
object.is_a?(ProcedureRevision) ? object : object.active_revision
|
||||||
end
|
end
|
||||||
|
|
||||||
def state
|
def state
|
||||||
object.procedure.aasm.current_state
|
procedure.aasm.current_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def number
|
def number
|
||||||
object.procedure.id
|
procedure.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
object.procedure.libelle
|
procedure.libelle
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
object.procedure.description
|
procedure.description
|
||||||
end
|
end
|
||||||
|
|
||||||
def declarative
|
def declarative
|
||||||
object.procedure.declarative_with_state
|
procedure.declarative_with_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_creation
|
def date_creation
|
||||||
object.procedure.created_at
|
procedure.created_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_publication
|
def date_publication
|
||||||
object.procedure.published_at
|
procedure.published_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_derniere_modification
|
def date_derniere_modification
|
||||||
object.procedure.updated_at
|
procedure.updated_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_depublication
|
def date_depublication
|
||||||
object.procedure.unpublished_at
|
procedure.unpublished_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_fermeture
|
def date_fermeture
|
||||||
object.procedure.closed_at
|
procedure.closed_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.authorized?(object, context)
|
def self.authorized?(object, context)
|
||||||
|
if object.is_a?(ProcedureRevision)
|
||||||
context.authorized_demarche?(object.procedure)
|
context.authorized_demarche?(object.procedure)
|
||||||
|
else
|
||||||
|
context.authorized_demarche?(object)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def procedure
|
||||||
|
revision.procedure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue