mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-01-05 20:22:31 -05:00
45 lines
667 B
Ruby
45 lines
667 B
Ruby
|
class WizardFieldSerializer < ApplicationSerializer
|
||
|
|
||
|
attributes :id, :type, :required, :value, :label, :placeholder
|
||
|
|
||
|
def id
|
||
|
object.id
|
||
|
end
|
||
|
|
||
|
def type
|
||
|
object.type
|
||
|
end
|
||
|
|
||
|
def required
|
||
|
object.required
|
||
|
end
|
||
|
|
||
|
def value
|
||
|
object.value
|
||
|
end
|
||
|
|
||
|
def include_value?
|
||
|
object.value.present?
|
||
|
end
|
||
|
|
||
|
def i18n_key
|
||
|
@i18n_key ||= "wizard.step.#{object.step.id}.fields.#{object.id}".underscore
|
||
|
end
|
||
|
|
||
|
def label
|
||
|
I18n.t("#{i18n_key}.label", default: '')
|
||
|
end
|
||
|
|
||
|
def include_label?
|
||
|
label.present?
|
||
|
end
|
||
|
|
||
|
def placeholder
|
||
|
I18n.t("#{i18n_key}.placeholder", default: '')
|
||
|
end
|
||
|
|
||
|
def include_placeholder?
|
||
|
placeholder.present?
|
||
|
end
|
||
|
end
|