Small fixes in reports templates [SCI-5723] (#3327)

* Small fixes in reports templates [SCI-5723]

* Update template name validation [SCI-5723]
This commit is contained in:
aignatov-bio 2021-05-18 15:19:51 +02:00 committed by GitHub
parent 7556a54213
commit c961b493fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View file

@ -982,7 +982,7 @@ function reportHandsonTableConverter() {
// Template values
reportData.template_values = {};
$.each($('.report-template-values-container').find('.sci-input-field, select'), function(i, field) {
$.each($('.report-template-values-container').find('.sci-input-field'), function(i, field) {
if (field.value.length === 0) return;
reportData.template_values[field.name] = {
@ -991,6 +991,15 @@ function reportHandsonTableConverter() {
};
});
$.each($('.report-template-values-container').find('select'), function(i, field) {
if (dropdownSelector.getValues(field).length === 0) return;
reportData.template_values[field.name] = {
value: dropdownSelector.getValues(field),
view_component: field.dataset.type
};
});
$.each($('.report-template-values-container .sci-checkbox'), function(i, checkbox) {
if (checkbox.name.includes('[]')) {
let name = checkbox.name.replace('[]', '');
@ -1307,10 +1316,7 @@ function reportHandsonTableConverter() {
$('.report-template-values-container').html(result.html);
$('.report-template-value-dropdown').each(function() {
dropdownSelector.init($(this), {
singleSelect: false,
closeOnSelect: true,
noEmptyOption: true,
selectAppearance: 'simple'
noEmptyOption: true
});
});
});

View file

@ -56,8 +56,11 @@ class ReportsController < ApplicationController
end
def new_template_values
template = Extends::REPORT_TEMPLATES[params[:template].to_sym]
return render_404 if template.blank?
if Extends::REPORT_TEMPLATES.key?(params[:template]&.to_sym)
template = params[:template]
else
return render_404
end
report = current_team.reports.where(project: @project).find_by(id: params[:report_id])
report ||= current_team.reports.new(project: @project)