2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-04 18:04:23 -06:00
|
|
|
class ThemeSettingsSerializer < ApplicationSerializer
|
2018-08-03 15:41:37 -05:00
|
|
|
attributes :setting, :type, :default, :value, :description, :valid_values,
|
2021-03-10 19:15:04 -06:00
|
|
|
:list_type, :textarea, :json_schema
|
2018-03-04 18:04:23 -06: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 08:49:59 -05: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 18:04:23 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def valid_values
|
|
|
|
object.choices
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_valid_values?
|
|
|
|
object.type == ThemeSetting.types[:enum]
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_description?
|
2019-05-31 08:49:59 -05:00
|
|
|
description.present?
|
2018-03-04 18:04:23 -06:00
|
|
|
end
|
2018-08-03 15:41:37 -05:00
|
|
|
|
|
|
|
def list_type
|
|
|
|
object.list_type
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_list_type?
|
|
|
|
object.type == ThemeSetting.types[:list]
|
|
|
|
end
|
2019-02-05 08:14:53 -06:00
|
|
|
|
|
|
|
def textarea
|
|
|
|
object.textarea
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_textarea?
|
|
|
|
object.type == ThemeSetting.types[:string]
|
|
|
|
end
|
|
|
|
|
2021-03-10 19:15:04 -06:00
|
|
|
def json_schema
|
|
|
|
object.json_schema
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_json_schema?
|
|
|
|
object.type == ThemeSetting.types[:string] && object.json_schema.present?
|
|
|
|
end
|
2018-03-04 18:04:23 -06:00
|
|
|
end
|