mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 15:54:00 +08:00
Ensure reports work with new results [SCI-9245]
This commit is contained in:
parent
520f978f35
commit
a11a879d90
3 changed files with 31 additions and 42 deletions
|
@ -72,13 +72,7 @@ module Reports::Docx::DrawMyModule
|
|||
|
||||
@docx.h4 I18n.t('Results') if my_module.results.any? && (%w(file_results table_results text_results).any? { |k| @settings.dig('task', k) })
|
||||
order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result|
|
||||
if result.is_asset && @settings.dig('task', 'file_results')
|
||||
draw_result_asset(result, @settings)
|
||||
elsif result.is_table && @settings.dig('task', 'table_results')
|
||||
draw_result_table(result)
|
||||
elsif result.is_text && @settings.dig('task', 'text_results')
|
||||
draw_result_text(result)
|
||||
end
|
||||
draw_result_asset(result, @settings)
|
||||
end
|
||||
|
||||
@docx.p
|
||||
|
|
|
@ -2,37 +2,38 @@
|
|||
|
||||
module Reports::Docx::DrawResultAsset
|
||||
def draw_result_asset(result, settings)
|
||||
asset = result.asset
|
||||
timestamp = asset.created_at
|
||||
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
|
||||
color = @color
|
||||
@docx.p
|
||||
result.assets.each do |asset|
|
||||
timestamp = asset.created_at
|
||||
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
|
||||
color = @color
|
||||
@docx.p
|
||||
|
||||
begin
|
||||
Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list?
|
||||
rescue StandardError => e
|
||||
Rails.logger.error e.message
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list?
|
||||
rescue StandardError => e
|
||||
Rails.logger.error e.message
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true
|
||||
text result.name, italic: true
|
||||
text ' '
|
||||
link I18n.t('projects.reports.elements.download'), asset_url do
|
||||
italic true
|
||||
end
|
||||
text " #{I18n.t('search.index.archived')} ", bold: true if result.archived?
|
||||
text ' ' + I18n.t('projects.reports.elements.result_asset.file_name', file: asset.file_name)
|
||||
text ' ' + I18n.t('projects.reports.elements.result_asset.user_time',
|
||||
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
|
||||
|
||||
if settings.dig(:task, :file_results_previews) && ActiveStorageFileUtil.previewable_document?(asset&.file&.blob)
|
||||
text " #{I18n.t('projects.reports.elements.result_asset.full_preview_attached')}", color: color[:gray]
|
||||
end
|
||||
end
|
||||
|
||||
draw_result_comments(result) if @settings.dig('task', 'result_comments')
|
||||
end
|
||||
|
||||
@docx.p do
|
||||
text result.name, italic: true
|
||||
text ' '
|
||||
link I18n.t('projects.reports.elements.download'), asset_url do
|
||||
italic true
|
||||
end
|
||||
text " #{I18n.t('search.index.archived')} ", bold: true if result.archived?
|
||||
text ' ' + I18n.t('projects.reports.elements.result_asset.file_name', file: asset.file_name)
|
||||
text ' ' + I18n.t('projects.reports.elements.result_asset.user_time',
|
||||
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
|
||||
|
||||
if settings.dig(:task, :file_results_previews) && ActiveStorageFileUtil.previewable_document?(asset&.file&.blob)
|
||||
text " #{I18n.t('projects.reports.elements.result_asset.full_preview_attached')}", color: color[:gray]
|
||||
end
|
||||
end
|
||||
|
||||
draw_result_comments(result) if @settings.dig('task', 'result_comments')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,13 +74,7 @@
|
|||
<% end %>
|
||||
|
||||
<% order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| %>
|
||||
<% if result.is_asset && @settings.dig('task', 'file_results') %>
|
||||
<%= render partial: 'reports/elements/my_module_result_asset_element', locals: { result: result, report: report, export_all: export_all } %>
|
||||
<% elsif result.is_table && @settings.dig('task', 'table_results') %>
|
||||
<%= render partial: 'reports/elements/my_module_result_table_element', locals: { result: result, export_all: export_all } %>
|
||||
<% elsif result.is_text && @settings.dig('task', 'text_results') %>
|
||||
<%= render partial: 'reports/elements/my_module_result_text_element', locals: { result: result, export_all: export_all } %>
|
||||
<% end %>
|
||||
<%= render partial: 'reports/elements/my_module_result_asset_element', locals: { result: result, report: report, export_all: export_all } %>
|
||||
<% end %>
|
||||
</div><br>
|
||||
|
||||
|
|
Loading…
Reference in a new issue