2023-04-24 22:30:51 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ThemeFieldSerializer < ApplicationSerializer
|
2024-01-11 14:04:02 +08:00
|
|
|
attributes :name, :target, :value, :error, :type_id, :upload_id, :url, :filename, :migrated
|
2023-04-24 22:30:51 +08:00
|
|
|
|
|
|
|
def include_url?
|
|
|
|
object.upload
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_upload_id?
|
|
|
|
object.upload
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_filename?
|
|
|
|
object.upload
|
|
|
|
end
|
|
|
|
|
|
|
|
def url
|
|
|
|
object.upload&.url
|
|
|
|
end
|
|
|
|
|
|
|
|
def filename
|
|
|
|
object.upload&.original_filename
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_value?
|
|
|
|
@options[:include_value] || false
|
|
|
|
end
|
|
|
|
|
|
|
|
def target
|
|
|
|
Theme.lookup_target(object.target_id)&.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_error?
|
|
|
|
object.error.present?
|
|
|
|
end
|
2024-01-11 14:04:02 +08:00
|
|
|
|
|
|
|
def migrated
|
|
|
|
!!object.theme_settings_migration
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_migrated?
|
|
|
|
target == "migrations"
|
|
|
|
end
|
2023-04-24 22:30:51 +08:00
|
|
|
end
|