mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 12:16:06 +08:00
29 lines
579 B
Ruby
29 lines
579 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TableSerializer < ActiveModel::Serializer
|
|
include Canaid::Helpers::PermissionsHelper
|
|
include Rails.application.routes.url_helpers
|
|
|
|
attributes :name, :contents, :urls, :icon
|
|
|
|
def contents
|
|
object.contents_utf_8
|
|
end
|
|
|
|
def icon
|
|
'fa-table'
|
|
end
|
|
|
|
def urls
|
|
return if object.destroyed?
|
|
|
|
object.reload unless object.step
|
|
|
|
return {} unless can_manage_step?(scope[:user], object.step)
|
|
|
|
{
|
|
delete_url: step_table_path(object.step, object),
|
|
update_url: step_table_path(object.step, object)
|
|
}
|
|
end
|
|
end
|