Merge branch 'release/1.30.0'

This commit is contained in:
Martin Artnik 2024-06-26 11:42:17 +02:00
commit cb2f0b1bcd
4 changed files with 31 additions and 25 deletions

View file

@ -237,7 +237,9 @@ var MarvinJsEditorApi = (function() {
enabled: function() {
return ($('#MarvinJsModal').length > 0);
},
isRemote: function() {
return marvinJsMode === 'remote';
},
open: function(config) {
if (!MarvinJsEditor.enabled()) {
$('#MarvinJsPromoModal').modal('show');
@ -322,19 +324,22 @@ $(document).on('click', '.gene-sequence-edit-button', function() {
function initMarvinJs() {
MarvinJsEditor = MarvinJsEditorApi();
if (MarvinJsEditor.enabled()) {
if (typeof (ChemicalizeMarvinJs) === 'undefined') {
setTimeout(initMarvinJs, 100);
return;
}
// MarvinJS is disabled, nothing to initialize
if (!MarvinJsEditor.enabled()) return;
if ($('#marvinjs-editor')[0].dataset.marvinjsMode === 'remote') {
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
marvin.setDisplaySettings({ toolbars: 'reporting' });
marvinJsRemoteEditor = marvin;
});
}
// wait for remote MarvinJS to initialize
if (MarvinJsEditor.isRemote() && typeof (ChemicalizeMarvinJs) === 'undefined') {
setTimeout(initMarvinJs, 100);
return;
}
if (MarvinJsEditor.isRemote()) {
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
marvin.setDisplaySettings({ toolbars: 'reporting' });
marvinJsRemoteEditor = marvin;
});
}
MarvinJsEditor.initNewButton('.new-marvinjs-upload-button');
}

View file

@ -59,7 +59,7 @@ module Reports
end
def generate_pdf_content
@has_cover = Rails.root.join('app', 'views', 'reports', 'templates', @template, 'cover.html.erb').exist?
@num_of_cover_pages = cover_pages_count
render_header_footer_and_report
@ -83,7 +83,7 @@ module Reports
template: 'reports/report',
layout: false,
assigns: { settings: @report.settings },
locals: { report: @report, user: @user, has_cover: @has_cover }
locals: { report: @report, user: @user, num_of_cover_pages: @num_of_cover_pages }
)
end
@ -130,8 +130,6 @@ module Reports
current_margin = extract_margins_from_header ||
{ top: '2cm', bottom: '2cm', left: '1cm', right: '1.5cm' }
cover_pages_shift = cover_page_shift_from_template
Grover.new(
@report_html,
format: 'A4',
@ -142,7 +140,7 @@ module Reports
footer_template: @footer_html,
style_tag_options: @style_tag_options,
script_tag_options: @script_tag_options,
page_ranges: "#{cover_pages_shift}-999999",
page_ranges: "#{@num_of_cover_pages + 1}-999999",
emulate_media: 'screen',
display_url: Rails.application.routes.default_url_options[:host]
).to_pdf(@file.path)
@ -150,7 +148,7 @@ module Reports
def process_attach_pdf_report_and_notify
@file.rewind
@file = prepend_title_page if @has_cover
@file = prepend_title_page if @num_of_cover_pages.positive?
@file = append_result_asset_previews if @report.settings.dig(:task, :file_results_previews)
@report.pdf_file.attach(io: @file, filename: 'report.pdf')
@ -337,16 +335,16 @@ module Reports
margins
end
def cover_page_shift_from_template
def cover_pages_count
cover_file_path = Rails.root.join('app', 'views', 'reports', 'templates', @template, 'cover.html.erb')
return 1 unless cover_file_path.exist?
return 0 unless cover_file_path.exist?
content = File.read(cover_file_path)
cover_pages_comment = content.match(/<!--\s*cover_pages_count:(\d+)\s*-->/)
return 2 unless cover_pages_comment
return 1 unless cover_pages_comment
cover_pages_comment[1].to_i + 1
cover_pages_comment[1].to_i
end
end
end

View file

@ -4,8 +4,8 @@
<meta charset="UTF-8">
</head>
<body class="print-report-body">
<% if has_cover %>
<div style="break-after: page;"></div>
<% num_of_cover_pages.times do %>
<div style="min-height: 100vh; break-after: page;"></div>
<% end %>
<div class="print-report">
<% report.root_elements.each do |el| %>

View file

@ -192,7 +192,10 @@ Devise.setup do |config|
# ==> Configuration for :validatable
# Range for password length.
config.password_length = 8..72
password_min_length = ENV['PASSWORD_MIN_LENGTH'].to_i
password_max_length = 72
password_min_length = 8 unless password_min_length.positive? && password_min_length < password_max_length
config.password_length = password_min_length..password_max_length
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly