2021-06-23 08:13:58 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
class CustomWizard::SubmissionSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:fields,
|
2021-07-14 08:04:19 +02:00
|
|
|
:submitted_at
|
2021-06-23 08:13:58 +02:00
|
|
|
|
2021-07-21 05:31:03 +02:00
|
|
|
has_one :user, serializer: ::BasicUserSerializer, embed: :objects
|
|
|
|
|
|
|
|
def include_user?
|
|
|
|
object.user.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
@fields ||= begin
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
object.wizard.template['steps'].each do |step|
|
|
|
|
step['fields'].each do |field|
|
|
|
|
if value = object.fields[field['id']]
|
|
|
|
result[field['id']] = {
|
|
|
|
value: value,
|
|
|
|
type: field['type'],
|
|
|
|
label: field['label']
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
result
|
|
|
|
end
|
2021-06-23 08:13:58 +02:00
|
|
|
end
|
2021-06-23 08:15:17 +02:00
|
|
|
end
|