Fix CSS for generated pdf/docx reports [SCI-7660] (#4911)

* Fix CSS for generated pdf/docx reports [SCI-7660]

* Call correct asset previewable function [SCI-7660]
This commit is contained in:
ajugo 2023-02-01 12:01:18 +01:00 committed by GitHub
parent e2da83ee6e
commit 6fcb9152dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 9 deletions

View file

@ -244,14 +244,16 @@ label {
/* Project header element style */
.report-project-header-element {
margin-bottom: 20px;
margin-bottom: 0;
.report-element-header {
border-bottom: none;
}
.report-element-body {
.project-name {
@include font-h1;
margin-top: 0;
}
}
@ -617,7 +619,7 @@ label {
margin: 3px 2px;
.activity-prefix {
color: $color-emperor;
color: $color-silver-chalice;
}
}
}

View file

@ -73,7 +73,7 @@ module Reports::Docx::DrawMyModule
@docx.h4 I18n.t('Results') if my_module.results.any?
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)
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')

View file

@ -19,8 +19,6 @@ module Reports::Docx::DrawProjectHeader
text I18n.t('projects.reports.elements.project_header.user_time', code: project.code,
timestamp: I18n.l(project.created_at, format: :full)), color: color[:gray]
br
br
br
end
end
end

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Reports::Docx::DrawResultAsset
def draw_result_asset(result)
def draw_result_asset(result, settings)
asset = result.asset
timestamp = asset.created_at
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
@ -27,6 +27,10 @@ module Reports::Docx::DrawResultAsset
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')

View file

@ -20,4 +20,6 @@ module ActiveStorageFileUtil
previewable
end
module_function :previewable_document?
end

View file

@ -2,13 +2,13 @@
<% export_all = defined?(export_all) && export_all %>
<div class="report-element report-module-protocol-element">
<div class="report-element-body">
<div class="protocol-name">
<h4 class="protocol-name">
<% if protocol.name.present? %>
<%= protocol.name %>
<% else %>
<%= t('projects.reports.elements.module.protocol.name') %>
<% end %>
</div>
</h4>
<div class="user-time">
<%= t('projects.reports.elements.module.protocol.user_time', code: protocol.code, timestamp: l(protocol.created_at, format: :full)) %>
</div>

View file

@ -38,7 +38,7 @@
</div>
<div class="user-time">
<%= t("projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full)) %>
<% if report.settings.dig(:task, :file_results_previews) %>
<% if report.settings.dig(:task, :file_results_previews) && ActiveStorageFileUtil.previewable_document?(asset&.file&.blob) %>
<%= t('projects.reports.elements.result_asset.full_preview_attached') %>
<% end %>
</div>