2019-12-12 05:43:11 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
class CustomWizard::FieldSerializer < ::WizardFieldSerializer
|
2019-12-06 10:05:19 +01:00
|
|
|
|
2020-04-06 10:36:38 +02:00
|
|
|
attributes :image,
|
2019-12-12 05:43:11 +01:00
|
|
|
:file_types,
|
2020-07-16 05:26:56 +02:00
|
|
|
:format,
|
2019-12-12 05:43:11 +01:00
|
|
|
:limit,
|
2020-03-24 10:35:46 +01:00
|
|
|
:property,
|
2021-01-12 11:46:24 +01:00
|
|
|
:content,
|
|
|
|
:char_counter
|
2020-04-05 03:37:09 +02: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 file_types
|
|
|
|
object.file_types
|
|
|
|
end
|
|
|
|
|
2020-07-16 05:26:56 +02:00
|
|
|
def format
|
|
|
|
object.format
|
|
|
|
end
|
|
|
|
|
2019-12-05 09:05:21 +01:00
|
|
|
def limit
|
|
|
|
object.limit
|
|
|
|
end
|
|
|
|
|
|
|
|
def property
|
|
|
|
object.property
|
|
|
|
end
|
2020-03-24 10:35:46 +01:00
|
|
|
|
2020-03-30 08:16:03 +02:00
|
|
|
def content
|
|
|
|
object.content
|
2020-03-24 10:35:46 +01:00
|
|
|
end
|
2020-04-07 09:54:30 +02:00
|
|
|
|
|
|
|
def include_choices?
|
|
|
|
object.choices.present?
|
|
|
|
end
|
2021-01-12 11:46:24 +01:00
|
|
|
|
|
|
|
def char_counter
|
|
|
|
object.char_counter
|
|
|
|
end
|
2019-12-05 09:05:21 +01:00
|
|
|
end
|