diff --git a/app/models/project.rb b/app/models/project.rb index 73ffb8f4a..4e14304e7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -246,6 +246,8 @@ class Project < ApplicationRecord parsed_page_html = Nokogiri::HTML(page_html_string) parsed_html = parsed_page_html.at_css('#report-content') + # Style tables (mimick frontend processing) + tables = parsed_html.css('.hot-table-contents') .zip(parsed_html.css('.hot-table-container')) tables.each do |table_input, table_container| diff --git a/app/models/team_zip_export.rb b/app/models/team_zip_export.rb index 2ad9ea4ad..73bdb8286 100644 --- a/app/models/team_zip_export.rb +++ b/app/models/team_zip_export.rb @@ -129,6 +129,18 @@ class TeamZipExport < ZipExport ) file = FileUtils.touch("#{project_path}/#{html_name}").first File.open(file, 'wb') { |f| f.write(project_report_pdf) } + + # Add Handsontable and dependent JS files (mimick frontend formula + # processing). + required_js = %w(handsontable.full.min.js lodash.js numeral.js numeric.js + md5.js jstat.js formula.js parser.js ruleJS.js + handsontable.formula.js big.min.js) + required_js.each do |filename| + filepath = File.join(Rails.root, + "vendor/assets/javascripts/#{filename}/") + dest_folder = "#{project_path}/" + FileUtils.cp(filepath, dest_folder) + end end # Change current dir outside tmp_dir, since tmp_dir will be deleted diff --git a/app/views/team_zip_exports/report.html.erb b/app/views/team_zip_exports/report.html.erb index 0c40c95d7..2a8d3f81c 100644 --- a/app/views/team_zip_exports/report.html.erb +++ b/app/views/team_zip_exports/report.html.erb @@ -10,6 +10,41 @@ .force_encoding(Encoding::UTF_8) .html_safe %> + + + + + + + + + + + + + + + + + + <%= title %> @@ -17,4 +52,4 @@ <%= content.force_encoding(Encoding::UTF_8).html_safe %> - \ No newline at end of file +