2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-04 19:04:23 -05:00
|
|
|
class ThemeSettingsSerializer < ApplicationSerializer
|
2018-08-03 16:41:37 -04:00
|
|
|
attributes :setting, :type, :default, :value, :description, :valid_values,
|
2019-02-05 09:14:53 -05:00
|
|
|
:list_type, :textarea
|
2018-03-04 19:04:23 -05:00
|
|
|
|
|
|
|
def setting
|
|
|
|
object.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def type
|
|
|
|
object.type_name
|
|
|
|
end
|
|
|
|
|
|
|
|
def default
|
|
|
|
object.default
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
|
|
|
object.value
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2019-05-31 09:49:59 -04:00
|
|
|
locale_file_description = object.theme.internal_translations.find { |t| t.key == "theme_metadata.settings.#{setting}" } &.value
|
|
|
|
locale_file_description || object.description
|
2018-03-04 19:04:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def valid_values
|
|
|
|
object.choices
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_valid_values?
|
|
|
|
object.type == ThemeSetting.types[:enum]
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_description?
|
2019-05-31 09:49:59 -04:00
|
|
|
description.present?
|
2018-03-04 19:04:23 -05:00
|
|
|
end
|
2018-08-03 16:41:37 -04:00
|
|
|
|
|
|
|
def list_type
|
|
|
|
object.list_type
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_list_type?
|
|
|
|
object.type == ThemeSetting.types[:list]
|
|
|
|
end
|
2019-02-05 09:14:53 -05:00
|
|
|
|
|
|
|
def textarea
|
|
|
|
object.textarea
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_textarea?
|
|
|
|
object.type == ThemeSetting.types[:string]
|
|
|
|
end
|
|
|
|
|
2018-03-04 19:04:23 -05:00
|
|
|
end
|