2019-12-12 05:43:11 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CustomWizardFieldSerializer < ::WizardFieldSerializer
|
2019-12-06 10:05:19 +01:00
|
|
|
|
2019-12-12 05:43:11 +01:00
|
|
|
attributes :dropdown_none,
|
|
|
|
:image,
|
|
|
|
:file_types,
|
|
|
|
:limit,
|
2020-03-24 10:35:46 +01:00
|
|
|
:property,
|
|
|
|
:filter
|
2019-12-12 23:54:13 +01:00
|
|
|
|
|
|
|
has_many :choices, serializer: WizardFieldChoiceSerializer, embed: :objects
|
2019-12-12 05:43:11 +01:00
|
|
|
|
2019-12-05 09:05:21 +01:00
|
|
|
def label
|
|
|
|
return object.label if object.label.present?
|
|
|
|
I18n.t("#{object.key || i18n_key}.label", default: '')
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
return object.description if object.description.present?
|
|
|
|
I18n.t("#{object.key || i18n_key}.description", default: '', base_url: Discourse.base_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
def image
|
|
|
|
object.image
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_image?
|
|
|
|
object.image.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def placeholder
|
|
|
|
I18n.t("#{object.key || i18n_key}.placeholder", default: '')
|
|
|
|
end
|
|
|
|
|
|
|
|
def dropdown_none
|
|
|
|
object.dropdown_none
|
|
|
|
end
|
|
|
|
|
|
|
|
def file_types
|
|
|
|
object.file_types
|
|
|
|
end
|
|
|
|
|
|
|
|
def limit
|
|
|
|
object.limit
|
|
|
|
end
|
|
|
|
|
|
|
|
def property
|
|
|
|
object.property
|
|
|
|
end
|
2020-03-24 10:35:46 +01:00
|
|
|
|
|
|
|
def filter
|
|
|
|
object.filter
|
|
|
|
end
|
2019-12-05 09:05:21 +01:00
|
|
|
end
|