2019-12-12 05:43:11 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-04-20 19:58:19 +02:00
|
|
|
class CustomWizard::StepSerializer < ::ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:index,
|
|
|
|
:next,
|
|
|
|
:previous,
|
|
|
|
:description,
|
|
|
|
:title,
|
|
|
|
:banner,
|
|
|
|
:permitted,
|
|
|
|
:permitted_message,
|
|
|
|
:final
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
has_many :fields, serializer: ::CustomWizard::FieldSerializer, embed: :objects
|
2019-12-05 09:05:21 +01:00
|
|
|
|
2021-04-20 19:58:19 +02:00
|
|
|
def id
|
|
|
|
object.id
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
object.index
|
|
|
|
end
|
|
|
|
|
|
|
|
def next
|
|
|
|
object.next.id if object.next.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_next?
|
|
|
|
object.next.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def previous
|
|
|
|
object.previous.id if object.previous.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_previous?
|
|
|
|
object.previous.present?
|
|
|
|
end
|
|
|
|
|
2019-12-05 09:05:21 +01:00
|
|
|
def title
|
2021-09-14 05:33:16 +02:00
|
|
|
I18n.t("#{i18n_key}.title", default: object.title, base_url: Discourse.base_url)
|
2019-12-05 09:05:21 +01:00
|
|
|
end
|
|
|
|
|
2021-04-20 19:58:19 +02:00
|
|
|
def include_title?
|
|
|
|
title.present?
|
|
|
|
end
|
|
|
|
|
2019-12-05 09:05:21 +01:00
|
|
|
def description
|
2021-09-14 05:33:16 +02:00
|
|
|
I18n.t("#{i18n_key}.description", default: object.description, base_url: Discourse.base_url)
|
2019-12-05 09:05:21 +01:00
|
|
|
end
|
|
|
|
|
2021-04-20 19:58:19 +02:00
|
|
|
def include_description?
|
|
|
|
description.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def banner
|
|
|
|
object.banner
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_banner?
|
|
|
|
object.banner.present?
|
|
|
|
end
|
|
|
|
|
2019-12-05 09:05:21 +01:00
|
|
|
def permitted
|
|
|
|
object.permitted
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2019-12-05 09:05:21 +01:00
|
|
|
def permitted_message
|
|
|
|
object.permitted_message
|
|
|
|
end
|
2021-04-20 19:58:19 +02:00
|
|
|
|
|
|
|
def final
|
|
|
|
object.final?
|
|
|
|
end
|
2021-09-14 05:33:16 +02:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def i18n_key
|
|
|
|
@i18n_key ||= "#{object.wizard.id}.#{object.id}".underscore
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|