0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 20:02:54 +01:00
discourse-custom-wizard/serializers/wizard_field_serializer.rb

51 Zeilen
1.005 B
Ruby

2019-12-12 00:53:13 +01:00
module CustomWizardFieldSerializerExtension
2019-12-06 10:05:19 +01:00
extend ActiveSupport::Concern
2019-12-12 00:53:13 +01:00
def self.prepended(klass)
klass.class_eval do
attributes :dropdown_none, :image, :file_types, :limit, :property
end
2019-12-06 10:05:19 +01:00
end
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
end
class WizardFieldSerializer
2019-12-12 00:53:13 +01:00
prepend CustomWizardFieldSerializerExtension if SiteSetting.custom_wizard_enabled
2019-12-05 09:05:21 +01:00
end