mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 22:25:30 +08:00
33 lines
965 B
Ruby
33 lines
965 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ResultTableSerializer < ActiveModel::Serializer
|
|
include Canaid::Helpers::PermissionsHelper
|
|
include Rails.application.routes.url_helpers
|
|
|
|
attributes :name, :contents, :urls, :icon, :metadata
|
|
|
|
def contents
|
|
object.contents_utf_8
|
|
end
|
|
|
|
def icon
|
|
'fa-table'
|
|
end
|
|
|
|
def urls
|
|
return if object.destroyed?
|
|
|
|
object.reload unless object.result
|
|
|
|
p object.result
|
|
p scope[:user] || @instance_options[:user]
|
|
p can_manage_result?(scope[:user] || @instance_options[:user], object.result)
|
|
return {} unless can_manage_result?(scope[:user] || @instance_options[:user], object.result)
|
|
|
|
{
|
|
duplicate_url: duplicate_my_module_result_table_path(object.result.my_module, object.result, object),
|
|
delete_url: my_module_result_table_path(object.result.my_module, object.result, object),
|
|
update_url: my_module_result_table_path(object.result.my_module, object.result, object)
|
|
}
|
|
end
|
|
end
|