mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 05:05:55 +08:00
31 lines
931 B
Ruby
31 lines
931 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Reports::Docx::RepositoryHelper
|
|
include InputSanitizeHelper
|
|
|
|
def prepare_row_columns(repository_data)
|
|
result = [repository_data[:headers]]
|
|
repository_data[:rows].each do |record|
|
|
row = []
|
|
row.push(record.repository.is_a?(RepositorySnapshot) ? record.parent_id : record.id)
|
|
row.push(escape_input(record.archived ? "#{record.name} [#{I18n.t('general.archived')}]" : record.name))
|
|
row.push(I18n.l(record.created_at, format: :full))
|
|
row.push(escape_input(record.created_by.full_name))
|
|
|
|
cell_values = {}
|
|
custom_cells = record.repository_cells
|
|
custom_cells.each do |cell|
|
|
cell_values[cell.repository_column_id] = cell.value.formatted
|
|
end
|
|
|
|
repository_data[:custom_columns].each do |column_id|
|
|
value = cell_values[column_id]
|
|
row.push(value)
|
|
end
|
|
|
|
result.push(row)
|
|
end
|
|
|
|
result
|
|
end
|
|
end
|