2019-12-12 22:33:29 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Reports::Docx::RepositoryHelper
|
|
|
|
include InputSanitizeHelper
|
|
|
|
|
|
|
|
def prepare_row_columns(repository_data)
|
|
|
|
result = [repository_data[:headers]]
|
2020-01-16 21:42:26 +08:00
|
|
|
repository_data[:rows].each do |record|
|
2019-12-12 22:33:29 +08:00
|
|
|
row = []
|
2021-07-19 20:23:36 +08:00
|
|
|
row.push(record.code)
|
2020-06-18 14:52:59 +08:00
|
|
|
row.push(escape_input(record.archived ? "#{record.name} [#{I18n.t('general.archived')}]" : record.name))
|
2019-12-12 22:33:29 +08:00
|
|
|
row.push(I18n.l(record.created_at, format: :full))
|
|
|
|
row.push(escape_input(record.created_by.full_name))
|
|
|
|
|
2020-01-07 21:21:55 +08:00
|
|
|
cell_values = {}
|
2019-12-12 22:33:29 +08:00
|
|
|
custom_cells = record.repository_cells
|
2020-01-07 21:21:55 +08:00
|
|
|
custom_cells.each do |cell|
|
|
|
|
cell_values[cell.repository_column_id] = cell.value.formatted
|
|
|
|
end
|
|
|
|
|
2020-01-16 21:42:26 +08:00
|
|
|
repository_data[:custom_columns].each do |column_id|
|
2020-01-07 21:21:55 +08:00
|
|
|
value = cell_values[column_id]
|
2019-12-12 22:33:29 +08:00
|
|
|
row.push(value)
|
|
|
|
end
|
|
|
|
|
|
|
|
result.push(row)
|
|
|
|
end
|
|
|
|
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|