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