mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-15 13:45:25 +08:00
36 lines
732 B
Ruby
36 lines
732 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module GlobalSearch
|
||
|
class ProtocolSerializer < ActiveModel::Serializer
|
||
|
include Rails.application.routes.url_helpers
|
||
|
|
||
|
attributes :id, :name, :code, :created_at, :updated_at, :created_by, :team, :archived, :url
|
||
|
|
||
|
def team
|
||
|
{
|
||
|
name: object.team.name,
|
||
|
url: protocols_path(team: object.team)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def created_by
|
||
|
{
|
||
|
name: object.created_by.name,
|
||
|
avatar_url: avatar_path(object.created_by, :icon_small)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def created_at
|
||
|
I18n.l(object.created_at, format: :full_date)
|
||
|
end
|
||
|
|
||
|
def updated_at
|
||
|
I18n.l(object.updated_at, format: :full_date)
|
||
|
end
|
||
|
|
||
|
def url
|
||
|
protocol_path(object)
|
||
|
end
|
||
|
end
|
||
|
end
|