2019-12-12 05:43:11 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
class CustomWizard::WizardSerializer < CustomWizard::BasicWizardSerializer
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
attributes :start,
|
2019-12-12 05:43:11 +01:00
|
|
|
:background,
|
2021-09-22 10:22:05 +02:00
|
|
|
:submission_last_updated_at,
|
2020-04-13 14:17:22 +02:00
|
|
|
:theme_id,
|
2019-12-12 05:43:11 +01:00
|
|
|
:completed,
|
|
|
|
:required,
|
|
|
|
:permitted,
|
2023-02-07 12:46:17 +01:00
|
|
|
:resume_on_revisit
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
has_many :steps, serializer: ::CustomWizard::StepSerializer, embed: :objects
|
|
|
|
has_one :user, serializer: ::BasicUserSerializer, embed: :objects
|
2019-12-12 05:43:11 +01:00
|
|
|
|
|
|
|
def completed
|
|
|
|
object.completed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_completed?
|
|
|
|
object.completed? &&
|
|
|
|
(!object.respond_to?(:multiple_submissions) || !object.multiple_submissions) &&
|
|
|
|
!scope.is_admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
def permitted
|
|
|
|
object.permitted?
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
def start
|
2021-04-20 19:58:19 +02:00
|
|
|
object.start
|
2020-04-13 14:17:22 +02:00
|
|
|
end
|
2019-12-12 05:43:11 +01:00
|
|
|
|
|
|
|
def include_start?
|
2021-03-12 08:38:50 +01:00
|
|
|
include_steps? && object.start.present?
|
2019-12-12 05:43:11 +01:00
|
|
|
end
|
|
|
|
|
2021-09-22 10:22:05 +02:00
|
|
|
def submission_last_updated_at
|
|
|
|
object.current_submission.updated_at
|
|
|
|
end
|
|
|
|
|
2019-12-12 05:43:11 +01:00
|
|
|
def include_steps?
|
|
|
|
!include_completed?
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|