mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 03:06:28 +08:00
Fix default empty options for report wizard first page [SCI-5724]
This commit is contained in:
parent
5c57056796
commit
697809ff6a
5 changed files with 41 additions and 9 deletions
|
@ -1232,20 +1232,35 @@ function reportHandsonTableConverter() {
|
|||
});
|
||||
}
|
||||
|
||||
function reCheckContinueButton() {
|
||||
if (dropdownSelector.getValues('#projectSelector').length > 0
|
||||
&& dropdownSelector.getValues('#templateSelector').length > 0) {
|
||||
$('.continue-button').attr('disabled', false);
|
||||
} else {
|
||||
$('.continue-button').attr('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
function initDropdowns() {
|
||||
dropdownSelector.init('#projectSelector', {
|
||||
singleSelect: true,
|
||||
closeOnSelect: true,
|
||||
noEmptyOption: true,
|
||||
selectAppearance: 'simple',
|
||||
onChange: function() {
|
||||
onSelect: function() {
|
||||
let projectContents = $('#new-report-step-2').find('.project-contents');
|
||||
let loadedProjectId = parseInt(projectContents.attr('data-project-id'), 10);
|
||||
let projectId = parseInt(dropdownSelector.getValues('#projectSelector'), 10);
|
||||
if (!Number.isNaN(loadedProjectId) && loadedProjectId !== projectId) {
|
||||
$('#projectReportWarningModal').modal('show');
|
||||
}
|
||||
$('.continue-button').attr('disabled', false);
|
||||
if (dropdownSelector.getValues('#projectSelector').length > 0) {
|
||||
dropdownSelector.enableSelector('#templateSelector');
|
||||
} else {
|
||||
dropdownSelector.selectValues('#templateSelector', '');
|
||||
dropdownSelector.disableSelector('#templateSelector');
|
||||
}
|
||||
reCheckContinueButton();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1255,9 +1270,15 @@ function reportHandsonTableConverter() {
|
|||
noEmptyOption: true,
|
||||
selectAppearance: 'simple',
|
||||
disableSearch: true,
|
||||
onChange: function() {
|
||||
onSelect: function() {
|
||||
if (dropdownSelector.getValues('#templateSelector').length === 0) {
|
||||
$('.report-template-values-container').html('').addClass('hidden');
|
||||
reCheckContinueButton();
|
||||
return;
|
||||
}
|
||||
|
||||
let filledFieldsCount = $('.report-template-values-container')
|
||||
.find('input.sci-input-field, textarea.sci-input-field').filter(function () {
|
||||
.find('input.sci-input-field, textarea.sci-input-field').filter(function() {
|
||||
return !!this.value;
|
||||
}).length;
|
||||
|
||||
|
@ -1266,8 +1287,13 @@ function reportHandsonTableConverter() {
|
|||
} else {
|
||||
$('#templateReportWarningModal').modal('show');
|
||||
}
|
||||
reCheckContinueButton();
|
||||
}
|
||||
});
|
||||
|
||||
if (dropdownSelector.getValues('#templateSelector').length > 0) {
|
||||
loadTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
function loadTemplate() {
|
||||
|
@ -1279,6 +1305,7 @@ function reportHandsonTableConverter() {
|
|||
|
||||
$('#templateSelector').data('selected-template', template);
|
||||
$.get($('#templateSelector').data('valuesEditorPath'), params, function(result) {
|
||||
$('.report-template-values-container').removeClass('hidden');
|
||||
$('.report-template-values-container').html(result.html);
|
||||
$('.report-template-value-dropdown').each(function() {
|
||||
dropdownSelector.init($(this), {
|
||||
|
|
|
@ -145,7 +145,9 @@ var dropdownSelector = (function() {
|
|||
function disableEnableDropdown(selector, container, mode) {
|
||||
var searchFieldValue = container.find('.search-field');
|
||||
if (mode) {
|
||||
updateCurrentData(container, []);
|
||||
if ($(selector).data('ajax-url')) {
|
||||
updateCurrentData(container, []);
|
||||
}
|
||||
updateTags(selector, container, { skipChange: true });
|
||||
searchFieldValue.attr('placeholder', selector.data('disable-placeholder') || '');
|
||||
container.addClass('disabled').removeClass('open')
|
||||
|
|
|
@ -35,7 +35,6 @@ class Report < ApplicationRecord
|
|||
dependent: :delete_all
|
||||
|
||||
DEFAULT_SETTINGS = {
|
||||
template: 'scinote_template',
|
||||
all_tasks: true,
|
||||
task: {
|
||||
protocol: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="project-selector-container">
|
||||
<%= render partial: 'reports/wizard/project_template_selector', locals: {report: report} %>
|
||||
</div>
|
||||
<div class="report-template-values-container">
|
||||
<div class="report-template-values-container <%= 'hidden' if report.new_record? %>">
|
||||
</div>
|
||||
|
|
|
@ -6,16 +6,20 @@
|
|||
<div class="col-md-6">
|
||||
<div class='project-selector'>
|
||||
<%= label_tag :projectSelector, t('projects.reports.wizard.first_step.select_project') %>
|
||||
<%= select_tag :projectSelector, options_from_collection_for_select(@visible_projects, :id, :name, report.project_id), data: { placeholder: t('projects.reports.wizard.first_step.select_project') } %>
|
||||
<%= select_tag :projectSelector,
|
||||
options_from_collection_for_select(@visible_projects, :id, :name, report.project_id),
|
||||
prompt: t('projects.reports.wizard.first_step.select_project') %>
|
||||
</div>
|
||||
|
||||
<div class='template-selector'>
|
||||
<%= label_tag :templateSelector, t('projects.reports.wizard.first_step.select_template') %>
|
||||
<%= select_tag :templateSelector,
|
||||
options_for_select(@templates.invert, report.settings[:template]),
|
||||
prompt: t('projects.reports.wizard.first_step.select_template'),
|
||||
data: {
|
||||
disable_on_load: report.settings[:template].blank?,
|
||||
placeholder: t('projects.reports.wizard.first_step.select_template'),
|
||||
selected_template: report.settings[:template] || @templates.first[0],
|
||||
selected_template: report.settings[:template],
|
||||
values_editor_path: reports_new_template_values_path(report_id: report.id)
|
||||
} %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue