mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-12 00:31:48 -05:00
50 lines
829 B
Ruby
50 lines
829 B
Ruby
class WizardStepSerializer < ApplicationSerializer
|
|
|
|
attributes :id, :next, :previous, :description, :title, :index
|
|
has_many :fields, serializer: WizardFieldSerializer, embed: :objects
|
|
|
|
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
|
|
|
|
def i18n_key
|
|
@i18n_key ||= "wizard.step.#{object.id}".underscore
|
|
end
|
|
|
|
def description
|
|
I18n.t("#{i18n_key}.description", default: '')
|
|
end
|
|
|
|
def include_description?
|
|
description.present?
|
|
end
|
|
|
|
def title
|
|
I18n.t("#{i18n_key}.title", default: '')
|
|
end
|
|
|
|
def include_title?
|
|
title.present?
|
|
end
|
|
|
|
end
|