From 8a915c8acf567a3d611a044c152030fefa35b8f9 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 28 Apr 2021 14:37:16 +0200 Subject: [PATCH] Fix assets inclusion into report [SCI-5680] --- .../project_members_input_component.html.erb | 4 +-- app/helpers/reports_helper.rb | 4 ++- app/views/reports/report.pdf.erb | 32 +++++++++---------- config/initializers/assets.rb | 2 ++ config/initializers/wicked_pdf.rb | 17 ---------- 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/app/components/reports/project_members_input_component.html.erb b/app/components/reports/project_members_input_component.html.erb index 0a431c94d..a1b478836 100644 --- a/app/components/reports/project_members_input_component.html.erb +++ b/app/components/reports/project_members_input_component.html.erb @@ -4,8 +4,8 @@ <%= select_tag @name, options_from_collection_for_select(@project_members, :id, :name), placeholder: @placeholder, class: 'sci-input-field report-template-value-dropdown', data: { type: 'ProjectMembersInputComponent' } %> <% else %> - <% @project_members.where(id: @value).pluck(@displayed_field).each do |field| %> - <%= field %> + <% @project_members.where(id: @value).each do |member| %> + <%= member.public_send(@displayed_field) %>
<% end %> <% end %> diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index f22834b9e..9d949e83a 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -174,7 +174,9 @@ module ReportsHelper end def report_experiment_descriptions(report) - report.report_elements.experiment.pluck(:description) + report.report_elements.experiment.collect do |experiment_element| + experiment_element.experiment.description + end end def assigned_to_report_repository_items(report, repository_name) diff --git a/app/views/reports/report.pdf.erb b/app/views/reports/report.pdf.erb index fd74e5bd7..470e80a62 100644 --- a/app/views/reports/report.pdf.erb +++ b/app/views/reports/report.pdf.erb @@ -2,24 +2,24 @@ - <%= stylesheet_link_tag wicked_pdf_asset_base64("application") %> - <%= stylesheet_link_tag wicked_pdf_asset_base64("reports_pdf") %> + <%= wicked_pdf_stylesheet_link_tag "application" %> + <%= wicked_pdf_stylesheet_link_tag "reports_pdf" %> <%= bootstrap_cdn_link_tag %> <%= font_awesome_cdn_link_tag %> - <%= javascript_include_tag wicked_pdf_asset_base64("jquery") %> - <%= javascript_include_tag wicked_pdf_asset_base64("handsontable.full.min") %> + <%= wicked_pdf_javascript_include_tag "jquery" %> + <%= wicked_pdf_javascript_include_tag "handsontable.full.min" %> - <%= javascript_include_tag wicked_pdf_asset_base64("lodash") %> - <%= javascript_include_tag wicked_pdf_asset_base64("numeral") %> - <%= javascript_include_tag wicked_pdf_asset_base64("numeric") %> - <%= javascript_include_tag wicked_pdf_asset_base64("md5") %> - <%= javascript_include_tag wicked_pdf_asset_base64("jstat") %> - <%= javascript_include_tag wicked_pdf_asset_base64("formula") %> - <%= javascript_include_tag wicked_pdf_asset_base64("parser") %> - <%= javascript_include_tag wicked_pdf_asset_base64("ruleJS") %> - <%= javascript_include_tag wicked_pdf_asset_base64("big.min") %> - <%= javascript_include_tag wicked_pdf_asset_base64("handsontable.formula") %> - <%= stylesheet_link_tag wicked_pdf_asset_base64("handsontable.formula") %> + <%= wicked_pdf_javascript_include_tag "lodash" %> + <%= wicked_pdf_javascript_include_tag "numeral" %> + <%= wicked_pdf_javascript_include_tag "numeric" %> + <%= wicked_pdf_javascript_include_tag "md5" %> + <%= wicked_pdf_javascript_include_tag "jstat" %> + <%= wicked_pdf_javascript_include_tag "formula" %> + <%= wicked_pdf_javascript_include_tag "parser" %> + <%= wicked_pdf_javascript_include_tag "ruleJS" %> + <%= wicked_pdf_javascript_include_tag "big.min" %> + <%= wicked_pdf_javascript_include_tag "handsontable.formula" %> + <%= wicked_pdf_stylesheet_link_tag "handsontable.formula" %> - <%= javascript_include_tag wicked_pdf_asset_base64("reports/content") %> + <%= wicked_pdf_javascript_include_tag "reports/content" %> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 775d4111c..0f3615f93 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -86,8 +86,10 @@ Rails.application.config.assets.precompile += %w(repositories/show.js) Rails.application.config.assets.precompile += %w(sidebar_toggle.js) Rails.application.config.assets.precompile += %w(reports/reports_datatable.js) Rails.application.config.assets.precompile += %w(reports/save_pdf_to_inventory.js) +Rails.application.config.assets.precompile += %w(reports/content.js) # Libraries needed for Handsontable formulas +Rails.application.config.assets.precompile += %w(jquery.js) Rails.application.config.assets.precompile += %w(lodash.js) Rails.application.config.assets.precompile += %w(numeral.js) Rails.application.config.assets.precompile += %w(numeric.js) diff --git a/config/initializers/wicked_pdf.rb b/config/initializers/wicked_pdf.rb index e712c029b..4b6c9295a 100644 --- a/config/initializers/wicked_pdf.rb +++ b/config/initializers/wicked_pdf.rb @@ -6,20 +6,3 @@ ENV['PATH'].split(':').each do |path| exe_path = File.join(path, 'wkhtmltopdf') WickedPdf.config[:exe_path] = File.join(path, 'wkhtmltopdf') if File.file?(exe_path) end - -# WickedPdfHelper patch that fixes issue with including application.css -# in environments like Heroku where assets.compile option is disabled and -# it is not acceptable to enable it. -# if Rails.env.production? && Rails.configuration.assets.compile == false -# WickedPdf::WickedPdfHelper::Assets.module_eval do -# def read_asset(source) -# manifest = Rails.application.assets_manifest -# path = File.join(manifest.dir, manifest.assets[source]) -# File.read(path) -# end -# -# def asset_exists?(source) -# Rails.application.assets_manifest.assets.key?(source) -# end -# end -# end