mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 19:24:10 +08:00
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:
parent
7556a54213
commit
c961b493fc
2 changed files with 16 additions and 7 deletions
|
@ -982,7 +982,7 @@ function reportHandsonTableConverter() {
|
||||||
|
|
||||||
// Template values
|
// Template values
|
||||||
reportData.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;
|
if (field.value.length === 0) return;
|
||||||
|
|
||||||
reportData.template_values[field.name] = {
|
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) {
|
$.each($('.report-template-values-container .sci-checkbox'), function(i, checkbox) {
|
||||||
if (checkbox.name.includes('[]')) {
|
if (checkbox.name.includes('[]')) {
|
||||||
let name = checkbox.name.replace('[]', '');
|
let name = checkbox.name.replace('[]', '');
|
||||||
|
@ -1307,10 +1316,7 @@ function reportHandsonTableConverter() {
|
||||||
$('.report-template-values-container').html(result.html);
|
$('.report-template-values-container').html(result.html);
|
||||||
$('.report-template-value-dropdown').each(function() {
|
$('.report-template-value-dropdown').each(function() {
|
||||||
dropdownSelector.init($(this), {
|
dropdownSelector.init($(this), {
|
||||||
singleSelect: false,
|
noEmptyOption: true
|
||||||
closeOnSelect: true,
|
|
||||||
noEmptyOption: true,
|
|
||||||
selectAppearance: 'simple'
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,8 +56,11 @@ class ReportsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_template_values
|
def new_template_values
|
||||||
template = Extends::REPORT_TEMPLATES[params[:template].to_sym]
|
if Extends::REPORT_TEMPLATES.key?(params[:template]&.to_sym)
|
||||||
return render_404 if template.blank?
|
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.where(project: @project).find_by(id: params[:report_id])
|
||||||
report ||= current_team.reports.new(project: @project)
|
report ||= current_team.reports.new(project: @project)
|
||||||
|
|
Loading…
Reference in a new issue