2024-04-09 20:18:41 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RepositorySerializer < ActiveModel::Serializer
|
|
|
|
include Rails.application.routes.url_helpers
|
|
|
|
|
2024-06-04 17:02:28 +08:00
|
|
|
attributes :urls, :id, :team_id, :repository_columns, :name, :export_actions, :team_name
|
2024-04-19 22:28:00 +08:00
|
|
|
|
|
|
|
def repository_columns
|
|
|
|
object.repository_columns.pluck(:id, :name, :data_type)
|
|
|
|
end
|
2024-04-09 20:18:41 +08:00
|
|
|
|
2024-06-04 17:02:28 +08:00
|
|
|
def team_name
|
|
|
|
object.team.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def export_actions
|
|
|
|
{
|
|
|
|
path: export_repositories_team_path(object.team),
|
|
|
|
export_file_type: current_user.settings[:repository_export_file_type] || 'xlsx'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2024-04-09 20:18:41 +08:00
|
|
|
def urls
|
|
|
|
{
|
2024-04-19 22:28:00 +08:00
|
|
|
parse_sheet: parse_sheet_repository_path(object),
|
2024-05-28 17:40:57 +08:00
|
|
|
import_records: import_records_repository_path(object),
|
2024-06-04 17:02:28 +08:00
|
|
|
export_empty_repository: export_empty_repository_team_repository_path(object.team, object)
|
2024-04-09 20:18:41 +08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|