mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Merge pull request #1473 from mz3944/mz-SCI-2918
In html project export there is formula instead of result in table [SCI-2918]
This commit is contained in:
commit
a315808d58
3 changed files with 50 additions and 1 deletions
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,6 +10,41 @@
|
|||
.force_encoding(Encoding::UTF_8)
|
||||
.html_safe %>
|
||||
</style>
|
||||
|
||||
<script src="handsontable.full.min.js"></script>
|
||||
|
||||
<!-- Libraries for formulas -->
|
||||
<script src="lodash.js"></script>
|
||||
<script src="numeral.js"></script>
|
||||
<script src="numeric.js"></script>
|
||||
<script src="md5.js"></script>
|
||||
<script src="jstat.js"></script>
|
||||
<script src="formula.js"></script>
|
||||
<script src="parser.js"></script>
|
||||
<script src="ruleJS.js"></script>
|
||||
<script src="handsontable.formula.js"></script>
|
||||
<script src="big.min.js"></script>
|
||||
|
||||
<!-- Init Handsontables -->
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var tables = document.getElementsByClassName('hot-table-container');
|
||||
var tableVals = document.getElementsByClassName('hot-table-contents');
|
||||
|
||||
for (i = 0; i < tables.length; i++) {
|
||||
tables[i].innerHTML=''
|
||||
new Handsontable(tables[i], {
|
||||
data: JSON.parse(tableVals[i].value).data,
|
||||
rowHeaders: true,
|
||||
colHeaders: true,
|
||||
filters: true,
|
||||
dropdownMenu: true,
|
||||
formulas: true
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<title><%= title %></title>
|
||||
</head>
|
||||
<body class='print-report-body'>
|
||||
|
@ -17,4 +52,4 @@
|
|||
<%= content.force_encoding(Encoding::UTF_8).html_safe %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue