Fix assets inclusion into report [SCI-5680]

This commit is contained in:
Oleksii Kriuchykhin 2021-04-28 14:37:16 +02:00
parent 7c75f170d0
commit 8a915c8acf
5 changed files with 23 additions and 36 deletions

View file

@ -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' } %>
</div>
<% 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) %>
<br>
<% end %>
<% end %>

View file

@ -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)

View file

@ -2,24 +2,24 @@
<html>
<head>
<meta charset='utf-8' />
<%= 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" %>
<!-- Libraries for formulas -->
<%= 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" %>
</head>
<body class="print-report-body">
<div class="print-report">
@ -29,6 +29,6 @@
<% end %>
</div>
<%= javascript_include_tag wicked_pdf_asset_base64("reports/content") %>
<%= wicked_pdf_javascript_include_tag "reports/content" %>
</body>
</html>

View file

@ -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)

View file

@ -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