add folder name to submission resp
This commit is contained in:
@@ -17,7 +17,8 @@ module Api
|
|||||||
submissions = submissions.joins(template: :folder).where(folder: { name: params[:template_folder] })
|
submissions = submissions.joins(template: :folder).where(folder: { name: params[:template_folder] })
|
||||||
end
|
end
|
||||||
|
|
||||||
submissions = paginate(submissions.preload(:created_by_user, :template, :submitters,
|
submissions = paginate(submissions.preload(:created_by_user, :submitters,
|
||||||
|
template: :folder,
|
||||||
audit_trail_attachment: :blob))
|
audit_trail_attachment: :blob))
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
@@ -155,7 +156,8 @@ module Api
|
|||||||
completed_at opened_at sent_at
|
completed_at opened_at sent_at
|
||||||
created_at updated_at external_id metadata],
|
created_at updated_at external_id metadata],
|
||||||
methods: %i[status application_key] },
|
methods: %i[status application_key] },
|
||||||
template: { only: %i[id name created_at updated_at] },
|
template: { only: %i[id name external_id created_at updated_at],
|
||||||
|
methods: %i[folder_name] },
|
||||||
created_by_user: { only: %i[id email first_name last_name] }
|
created_by_user: { only: %i[id email first_name last_name] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ class Template < ApplicationRecord
|
|||||||
scope :active, -> { where(archived_at: nil) }
|
scope :active, -> { where(archived_at: nil) }
|
||||||
scope :archived, -> { where.not(archived_at: nil) }
|
scope :archived, -> { where.not(archived_at: nil) }
|
||||||
|
|
||||||
|
delegate :name, to: :folder, prefix: true
|
||||||
|
|
||||||
def application_key
|
def application_key
|
||||||
external_id
|
external_id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ module Templates
|
|||||||
|
|
||||||
def call(template, schema_documents = template.schema_documents, preview_image_attachments = [])
|
def call(template, schema_documents = template.schema_documents, preview_image_attachments = [])
|
||||||
json = template.as_json(
|
json = template.as_json(
|
||||||
methods: %i[application_key],
|
methods: %i[application_key folder_name],
|
||||||
include: { author: { only: %i[id email first_name last_name] } }
|
include: { author: { only: %i[id email first_name last_name] } }
|
||||||
)
|
)
|
||||||
|
|
||||||
json[:folder_name] = template.folder.name
|
|
||||||
|
|
||||||
json[:documents] = template.schema.map do |item|
|
json[:documents] = template.schema.map do |item|
|
||||||
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
|
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user