Add output tag to reports [SCI-11560]

This commit is contained in:
Andrej 2025-02-25 11:30:46 +01:00
parent 7dc9df6813
commit 8786ee45c1
2 changed files with 10 additions and 3 deletions

View file

@ -371,9 +371,13 @@ class MyModule < ApplicationRecord
)
end
rows.find_each do |row|
row_tags = []
row_tags << "[#{I18n.t('general.archived')}]" if row.archived
row_tags << "[#{I18n.t('general.output')}]" if row.output? && id == row.my_module_id
row_json = []
row_json << row.code
row_json << (row.archived ? "#{escape_script_tag(row.name)} [#{I18n.t('general.archived')}]" : escape_script_tag(row.name))
row_json << "#{escape_script_tag(row.name)} #{row_tags.join(' ')}"
row_json << I18n.l(row.created_at, format: :full)
row_json << escape_script_tag(row.created_by.full_name)
if repository.has_stock_management? && repository.has_stock_consumption?
@ -414,7 +418,7 @@ class MyModule < ApplicationRecord
end
records = repository.assigned_rows(self)
.select(:id, :name, :created_at, :created_by_id, :repository_id, :parent_id, :archived)
.select(:id, :name, :created_at, :created_by_id, :repository_id, :parent_id, :archived, :my_module_id)
{ headers: headers, rows: records, custom_columns: custom_columns, excluded_columns: excluded_columns }
end

View file

@ -14,7 +14,10 @@ module Reports::Docx::RepositoryHelper
row = []
row.push(record.code) unless excluded_columns.include?(-1)
unless excluded_columns.include?(-2)
row.push(escape_input(record.archived ? "#{record.name} [#{I18n.t('general.archived')}]" : record.name))
row_tags = []
row_tags << "[#{I18n.t('general.archived')}]" if record.archived
row_tags << "[#{I18n.t('general.output')}]" if my_module && record.output? && my_module.id == record.my_module_id
row.push(escape_input("#{record.name} #{row_tags.join(' ')}"))
end
row.push(I18n.l(record.created_at, format: :full)) unless excluded_columns.include?(-3)
row.push(escape_input(record.created_by.full_name)) unless excluded_columns.include?(-4)