mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
21 lines
641 B
Ruby
21 lines
641 B
Ruby
# frozen_string_literal: true
|
|
|
|
class LabelTemplateSerializer < ActiveModel::Serializer
|
|
include Canaid::Helpers::PermissionsHelper
|
|
include Rails.application.routes.url_helpers
|
|
|
|
attributes :name, :description, :language_type, :icon_url, :urls, :content, :type,
|
|
:default, :width_mm, :height_mm, :unit, :density
|
|
|
|
def icon_url
|
|
ActionController::Base.helpers.image_path("label_template_icons/#{object.icon}.svg")
|
|
end
|
|
|
|
def urls
|
|
return {} unless can_manage_label_templates?(object.team)
|
|
{
|
|
update: label_template_path(object),
|
|
fields: template_tags_label_templates_path(id: object.id)
|
|
}
|
|
end
|
|
end
|