From a307a160332ad5e1fc9957894ebd94826f10d8e0 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 4 May 2021 16:05:19 +0200 Subject: [PATCH] Fix handsontable assets inclusion in report templates [SCI-5692] --- app/assets/stylesheets/application.scss | 2 +- app/controllers/reports_controller.rb | 4 +- app/jobs/reports/pdf_job.rb | 6 +- app/views/my_modules/results.html.erb | 2 +- app/views/protocols/_steps.html.erb | 2 +- app/views/protocols/index.html.erb | 2 +- .../_protocol_preview_modal_body.html.erb | 2 +- .../_my_module_protocol_element.html.erb | 1 + app/views/reports/new_old.html.erb | 2 +- app/views/reports/report.pdf.erb | 2 +- .../_project_template_selector.html.erb | 2 +- .../results/partials/_protocol_text.html.erb | 2 +- app/views/team_zip_exports/report.html.erb | 2 +- config/initializers/assets.rb | 4 +- .../assets/javascripts/handsontable.full.js | 75997 ++++++++++++++++ .../javascripts/handsontable.full.min.js | 41 - .../assets/stylesheets/handsontable.full.css | 1555 + .../stylesheets/handsontable.full.min.css | 37 - 18 files changed, 77570 insertions(+), 95 deletions(-) create mode 100644 vendor/assets/javascripts/handsontable.full.js delete mode 100644 vendor/assets/javascripts/handsontable.full.min.js create mode 100644 vendor/assets/stylesheets/handsontable.full.css delete mode 100644 vendor/assets/stylesheets/handsontable.full.min.css diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 66995630e..4d3af531f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -21,7 +21,7 @@ @import "shared_styles/elements/*"; -@import "handsontable.full.min"; +@import "handsontable.full"; @import "emojionearea.min"; @import "ajax-bootstrap-select.min"; @import "extend/bootstrap"; diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 897e21727..40745eb0c 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -186,7 +186,7 @@ class ReportsController < ApplicationController respond_to do |format| format.json do @report.update!(pdf_file_processing: true) - Reports::PdfJob.perform_later(@report, @report.settings[:template], current_user) + Reports::PdfJob.perform_later(@report, current_user) render json: { message: I18n.t('projects.reports.index.generation.accepted_message') } @@ -548,6 +548,6 @@ class ReportsController < ApplicationController end def generate_pdf_report - Reports::PdfJob.perform_later(@report, @report.settings[:template], current_user) if @report.persisted? + Reports::PdfJob.perform_later(@report, current_user) if @report.persisted? end end diff --git a/app/jobs/reports/pdf_job.rb b/app/jobs/reports/pdf_job.rb index 897ccea02..1a9204d96 100644 --- a/app/jobs/reports/pdf_job.rb +++ b/app/jobs/reports/pdf_job.rb @@ -17,12 +17,12 @@ module Reports PREVIEW_EXTENSIONS = %w(docx pdf).freeze - def perform(report, template, user) + def perform(report, user) file = Tempfile.new(['report', '.pdf'], binmode: true) begin - template_name = Extends::REPORT_TEMPLATES[template.to_sym] + template_name = Extends::REPORT_TEMPLATES[report.settings[:template]&.to_sym] - raise StandardError if template_name.blank? + raise StandardError, 'Report template not found!' if template_name.blank? ActionController::Renderer::RACK_KEY_TRANSLATION['warden'] ||= 'warden' proxy = Warden::Proxy.new({}, Warden::Manager.new({})) diff --git a/app/views/my_modules/results.html.erb b/app/views/my_modules/results.html.erb index f4a0e6de8..cb85a9d28 100644 --- a/app/views/my_modules/results.html.erb +++ b/app/views/my_modules/results.html.erb @@ -69,7 +69,7 @@ -<%= javascript_include_tag "handsontable.full.min" %> +<%= javascript_include_tag "handsontable.full" %> <%= render partial: "shared/formulas_libraries.html.erb" %> diff --git a/app/views/protocols/_steps.html.erb b/app/views/protocols/_steps.html.erb index da20d5b82..d954e6827 100644 --- a/app/views/protocols/_steps.html.erb +++ b/app/views/protocols/_steps.html.erb @@ -27,7 +27,7 @@ <% end %> -<%= javascript_include_tag "handsontable.full.min" %> +<%= javascript_include_tag "handsontable.full" %> <%= render partial: "shared/formulas_libraries.html.erb" %> diff --git a/app/views/protocols/index.html.erb b/app/views/protocols/index.html.erb index a03aff6b6..a1c09644d 100644 --- a/app/views/protocols/index.html.erb +++ b/app/views/protocols/index.html.erb @@ -130,7 +130,7 @@ <%= render partial: "protocols/import_export/import_elements.html.erb" %> -<%= javascript_include_tag "handsontable.full.min" %> +<%= javascript_include_tag "handsontable.full" %> <%= render partial: "shared/formulas_libraries.html.erb" %> diff --git a/app/views/protocols/index/_protocol_preview_modal_body.html.erb b/app/views/protocols/index/_protocol_preview_modal_body.html.erb index 81a14427c..17b1aded4 100644 --- a/app/views/protocols/index/_protocol_preview_modal_body.html.erb +++ b/app/views/protocols/index/_protocol_preview_modal_body.html.erb @@ -13,7 +13,7 @@ -<%= javascript_include_tag "handsontable.full.min" %> +<%= javascript_include_tag "handsontable.full" %> <%= javascript_include_tag "lodash" %> <%= javascript_include_tag "numeral" %> <%= javascript_include_tag "numeric" %> diff --git a/app/views/reports/elements/_my_module_protocol_element.html.erb b/app/views/reports/elements/_my_module_protocol_element.html.erb index 386616867..ff75047c8 100644 --- a/app/views/reports/elements/_my_module_protocol_element.html.erb +++ b/app/views/reports/elements/_my_module_protocol_element.html.erb @@ -1,3 +1,4 @@ +<% protocol ||= my_module.protocol %> <% my_module = protocol.my_module %> <% for_export_all = defined?(export_all) && export_all %>
diff --git a/app/views/reports/new_old.html.erb b/app/views/reports/new_old.html.erb index f7f04750a..c68ac9e45 100644 --- a/app/views/reports/new_old.html.erb +++ b/app/views/reports/new_old.html.erb @@ -79,7 +79,7 @@ <%= render partial: 'reports/new/save_PDF_to_inventory_modal' %> -<%= javascript_include_tag "handsontable.full.min" %> +<%= javascript_include_tag "handsontable.full" %> <%= render partial: "shared/formulas_libraries.html.erb" %> diff --git a/app/views/reports/report.pdf.erb b/app/views/reports/report.pdf.erb index 470e80a62..ac4ed1ebc 100644 --- a/app/views/reports/report.pdf.erb +++ b/app/views/reports/report.pdf.erb @@ -7,7 +7,7 @@ <%= bootstrap_cdn_link_tag %> <%= font_awesome_cdn_link_tag %> <%= wicked_pdf_javascript_include_tag "jquery" %> - <%= wicked_pdf_javascript_include_tag "handsontable.full.min" %> + <%= wicked_pdf_javascript_include_tag "handsontable.full" %> <%= wicked_pdf_javascript_include_tag "lodash" %> <%= wicked_pdf_javascript_include_tag "numeral" %> diff --git a/app/views/reports/wizard/_project_template_selector.html.erb b/app/views/reports/wizard/_project_template_selector.html.erb index 0cf371d7d..8a29af680 100644 --- a/app/views/reports/wizard/_project_template_selector.html.erb +++ b/app/views/reports/wizard/_project_template_selector.html.erb @@ -12,7 +12,7 @@
<%= label_tag :templateSelector, t('projects.reports.wizard.first_step.select_template') %> <%= select_tag :templateSelector, - options_for_select(@templates, report.settings[:template]), + options_for_select(@templates.invert, report.settings[:template]), data: { placeholder: t('projects.reports.wizard.first_step.select_template'), values_editor_path: reports_new_template_values_path(report_id: report.id) diff --git a/app/views/search/results/partials/_protocol_text.html.erb b/app/views/search/results/partials/_protocol_text.html.erb index 8851e6f68..a14a85707 100644 --- a/app/views/search/results/partials/_protocol_text.html.erb +++ b/app/views/search/results/partials/_protocol_text.html.erb @@ -20,7 +20,7 @@ <% if can_read_protocol_in_module?(protocol) || can_read_protocol_in_repository?(protocol) %> <%= link_to text, '#', 'data-action': 'protocol-preview', 'data-url': preview_protocol_path(protocol) %> - <%= javascript_include_tag "handsontable.full.min" %> + <%= javascript_include_tag "handsontable.full" %> <%= render partial: "shared/formulas_libraries.html.erb" %> diff --git a/app/views/team_zip_exports/report.html.erb b/app/views/team_zip_exports/report.html.erb index ecf2cd8d9..88c629db9 100644 --- a/app/views/team_zip_exports/report.html.erb +++ b/app/views/team_zip_exports/report.html.erb @@ -12,7 +12,7 @@ - <% ['handsontable.full.min.js', 'lodash.js', 'numeral.js', 'numeric.js', + <% ['handsontable.full.js', 'lodash.js', 'numeral.js', 'numeric.js', 'md5.js', 'jstat.js', 'formula.js', 'parser.js', 'ruleJS.js', 'handsontable.formula.js', 'big.min.js' ].each do |js_asset| %>