mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-02 21:51:51 +08:00
50 lines
1.2 KiB
Ruby
50 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ReportDatatable < CustomDatatable
|
|
TABLE_COLUMNS = %w(
|
|
Views::Datatables::DatatablesReport.project_name
|
|
Views::Datatables::DatatablesReport.name
|
|
Views::Datatables::DatatablesReport.created_by
|
|
Views::Datatables::DatatablesReport.last_modified_by
|
|
Views::Datatables::DatatablesReport.created_at
|
|
Views::Datatables::DatatablesReport.updated_at
|
|
).freeze
|
|
|
|
def_delegator :@view, :edit_project_report_path
|
|
def initialize(view, user, reports)
|
|
super(view)
|
|
@user = user
|
|
@reports = reports
|
|
end
|
|
|
|
def sortable_columns
|
|
@sortable_columns ||= TABLE_COLUMNS
|
|
end
|
|
|
|
def searchable_columns
|
|
@searchable_columns ||= TABLE_COLUMNS
|
|
end
|
|
|
|
private
|
|
|
|
def data
|
|
records.map do |record|
|
|
{
|
|
'0' => record.id,
|
|
'1' => record.project_name,
|
|
'2' => record.name,
|
|
'3' => record.created_by,
|
|
'4' => record.last_modified_by,
|
|
'5' => I18n.l(record.created_at, format: :full),
|
|
'6' => I18n.l(record.updated_at, format: :full),
|
|
'edit' => edit_project_report_path(record.project_id, record.id)
|
|
}
|
|
end
|
|
end
|
|
|
|
def get_raw_records
|
|
@reports
|
|
end
|
|
|
|
# ==== Insert 'presenter'-like methods below if necessary
|
|
end
|