From 07831c02943d1664c495415f0b4f2916dafb4fbe Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Tue, 19 Jan 2021 12:53:49 +0100 Subject: [PATCH] Add new asset icons to report [SCI-5263] --- app/assets/stylesheets/reports.scss | 8 ++++++++ app/assets/stylesheets/reports_print.scss | 16 ++++++++++++++++ app/helpers/file_icons_helper.rb | 15 +++++++++++---- .../_my_module_result_asset_element.html.erb | 2 +- .../elements/_step_asset_element.html.erb | 2 +- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/reports.scss b/app/assets/stylesheets/reports.scss index fad2bbe86..15ffcb80d 100644 --- a/app/assets/stylesheets/reports.scss +++ b/app/assets/stylesheets/reports.scss @@ -368,6 +368,10 @@ label { .file-name { margin-left: 15px; } + + .image-icon.report { + display: none; + } } img { @@ -464,6 +468,10 @@ label { margin-left: 5px; white-space: nowrap; } + + .image-icon.report { + display: none; + } } &:hover > .report-element-header .file-name { diff --git a/app/assets/stylesheets/reports_print.scss b/app/assets/stylesheets/reports_print.scss index 32f41d3ae..7ddecd015 100644 --- a/app/assets/stylesheets/reports_print.scss +++ b/app/assets/stylesheets/reports_print.scss @@ -97,6 +97,14 @@ div.print-report { img { max-width: 100%; } + + .image-icon.preview { + display: none; + } + + .image-icon.report { + display: initial !important; + } } .report-step-table-element { @@ -199,6 +207,14 @@ div.print-report { } } + .image-icon.preview { + display: none; + } + + .image-icon.report { + display: initial !important; + } + img { max-width: 100%; } diff --git a/app/helpers/file_icons_helper.rb b/app/helpers/file_icons_helper.rb index 58d728723..a3c19db47 100644 --- a/app/helpers/file_icons_helper.rb +++ b/app/helpers/file_icons_helper.rb @@ -30,7 +30,7 @@ module FileIconsHelper end # For showing next to file - def file_extension_icon(asset) + def file_extension_icon(asset, report = false) file_ext = asset.file_name.split('.').last if Constants::FILE_TEXT_FORMATS.include?(file_ext) image_link = 'icon_small/docx_file.svg' @@ -46,7 +46,14 @@ module FileIconsHelper image_link = Extends::FILE_ICON_MAPPINGS[file_ext] if Extends::FILE_ICON_MAPPINGS[file_ext] if image_link - ActionController::Base.helpers.image_tag(image_link, class: 'image-icon') + if report + content_tag(:span) do + concat ActionController::Base.helpers.image_tag(image_link, class: 'image-icon preview') + concat wicked_pdf_image_tag(image_link, class: 'image-icon report') + end + else + ActionController::Base.helpers.image_tag(image_link, class: 'image-icon') + end else '' end @@ -100,8 +107,8 @@ module FileIconsHelper end end - def file_extension_icon_html(asset) - html = file_extension_icon(asset) + def file_extension_icon_html(asset, report = false) + html = file_extension_icon(asset, report) if html.blank? html = ActionController::Base.helpers.content_tag( :i, diff --git a/app/views/reports/elements/_my_module_result_asset_element.html.erb b/app/views/reports/elements/_my_module_result_asset_element.html.erb index c10efe4b6..d80e9f894 100644 --- a/app/views/reports/elements/_my_module_result_asset_element.html.erb +++ b/app/views/reports/elements/_my_module_result_asset_element.html.erb @@ -14,7 +14,7 @@
- + <%= file_extension_icon_html(asset, true) %>
<%= result.name %> diff --git a/app/views/reports/elements/_step_asset_element.html.erb b/app/views/reports/elements/_step_asset_element.html.erb index 19c2ab7c4..87e7ecebf 100644 --- a/app/views/reports/elements/_step_asset_element.html.erb +++ b/app/views/reports/elements/_step_asset_element.html.erb @@ -5,7 +5,7 @@
- + <%= file_extension_icon_html(asset, true) %>
<% if defined? export_all and export_all %>