mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +08:00
Refactoring of specific modals for adding content to report and fixing their inconsistencies. [fixes SCI-487]
This commit is contained in:
parent
b97cb91840
commit
dbb79ebab1
9 changed files with 82 additions and 166 deletions
|
@ -3,80 +3,34 @@
|
|||
<div>
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#experiment-tab" aria-controls="experiment-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.experiment_contents.experiment_tab") %></a></li>
|
||||
<li role="presentation"><a href="#module-tab" aria-controls="module-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.experiment_contents.module_tab") %></a></li>
|
||||
<li role="presentation"><a href="#module-steps-tab" aria-controls="module-steps-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.experiment_contents.steps_tab") %></a></li>
|
||||
<li role="presentation"><a href="#step-results-tab" aria-controls="step-results-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.experiment_contents.results_tab") %></a></li>
|
||||
<li role="presentation" class="active">
|
||||
<a href="#tasks-tab" aria-controls="tasks-tab" role="tab" data-toggle="tab">
|
||||
<span class="glyphicon glyphicon-credit-card visible-xs"></span>
|
||||
<span class="hidden-xs"><%= t("projects.reports.elements.modals.project_contents.tasks_tab") %></span>
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#content-tab" aria-controls="content-tab" role="tab" data-toggle="tab">
|
||||
<span class="glyphicon glyphicon-link visible-xs"></span>
|
||||
<span class="hidden-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="experiment-tab">
|
||||
<div role="tabpanel" class="tab-pane active" id="tasks-tab">
|
||||
<h5 class="visible-xs"><%= t("projects.reports.elements.modals.project_contents.tasks_tab") %></h5>
|
||||
<%= render partial: "reports/new/modal/experiment_contents_inner.html.erb", locals: { form: f, experiment: experiment } %>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="module-tab">
|
||||
<div role="tabpanel" class="tab-pane" id="content-tab">
|
||||
<h5 class="visible-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></h5>
|
||||
<%= render partial: "reports/new/modal/module_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="module-steps-tab">
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/step_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="step-results-tab">
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/result_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script type="javascript">
|
||||
$(function() {
|
||||
var form = $("#add-contents-form");
|
||||
var experimentTab = form.find("#experiment-tab");
|
||||
var moduleTab = form.find("#module-tab");
|
||||
var stepsTab = form.find("#module-steps-tab");
|
||||
|
||||
var experimentCheckAlls = experimentTab.find(".experiment-all-cb");
|
||||
var experimentAll = experimentTab.find("input:checkbox");
|
||||
experimentCheckAlls.click(function() {
|
||||
var nextUl = $(this).closest("div.checkbox").next();
|
||||
if (nextUl.length && nextUl.is("ul.experiment-contents-list")) {
|
||||
nextUl.find("input:checkbox").prop("checked", this.checked);
|
||||
}
|
||||
});
|
||||
experimentAll.click(function() {
|
||||
var parentLists = $(this).parents("ul.experiment-contents-list");
|
||||
|
||||
if (parentLists.length) {
|
||||
var prevEl = parentLists.prev();
|
||||
if (prevEl.length && prevEl.is("div.checkbox")) {
|
||||
prevEl.find("input:checkbox").prop("checked", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var moduleCheckAll = moduleTab.find("#_module_content_all");
|
||||
var moduleOthers = moduleTab.find("input:checkbox:not(#_module_content_all)");
|
||||
var moduleResultsAll = moduleTab.find(".results-all");
|
||||
var moduleResults = moduleTab.find(".result-cb");
|
||||
moduleCheckAll.click(function() {
|
||||
moduleOthers.prop("checked", this.checked);
|
||||
});
|
||||
moduleOthers.click(function() {
|
||||
moduleCheckAll.prop("checked", false);
|
||||
});
|
||||
moduleResultsAll.click(function() {
|
||||
moduleResults.prop("checked", this.checked);
|
||||
});
|
||||
moduleResults.click(function() {
|
||||
moduleResultsAll.prop("checked", false);
|
||||
});
|
||||
|
||||
var stepsCheckAll = stepsTab.find("#_step_content_all");
|
||||
var stepsOthers = stepsTab.find("input:checkbox:not(#_step_content_all)");
|
||||
stepsCheckAll.click(function() {
|
||||
stepsOthers.prop("checked", this.checked);
|
||||
});
|
||||
stepsOthers.click(function() {
|
||||
stepsCheckAll.prop("checked", false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -4,30 +4,37 @@
|
|||
</em>
|
||||
</div>
|
||||
|
||||
<% if experiment.my_modules.count > 0 %>
|
||||
<%= form.check_box :experiment, label: experiment.name, class: "experiment-all-cb" %>
|
||||
<ul class="experiment-contents-list">
|
||||
<% experiment.my_module_groups.each do |my_module_group| %>
|
||||
<% if my_module_group.my_modules.present? then %>
|
||||
<% my_module_group.ordered_modules.each do |my_module| %>
|
||||
<li>
|
||||
<%= form.check_box "modules[#{my_module.id}]", label: my_module.name %>
|
||||
</li>
|
||||
<% if experiment.my_modules.present? %>
|
||||
<div class="checkbox-tree">
|
||||
<ul>
|
||||
<li>
|
||||
<%= form.check_box :experiment_content_all, label: experiment.name %>
|
||||
<ul>
|
||||
|
||||
<% experiment.my_module_groups.each do |my_module_group| %>
|
||||
<% if my_module_group.my_modules.present? then %>
|
||||
<% my_module_group.ordered_modules.each do |my_module| %>
|
||||
<li>
|
||||
<%= form.check_box "modules[#{my_module.id}]", label: my_module.name %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<!-- Tasks without groups -->
|
||||
<% modules_without_group = experiment.modules_without_group %>
|
||||
<% if modules_without_group.present? and modules_without_group.count > 0 %>
|
||||
<% modules_without_group.each do |my_module| %>
|
||||
<li>
|
||||
<%= form.check_box "modules[#{my_module.id}]", label: my_module.name %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!-- Tasks without groups -->
|
||||
<% modules_without_group = experiment.modules_without_group %>
|
||||
<% if modules_without_group.present? and modules_without_group.present? %>
|
||||
<% modules_without_group.each do |my_module| %>
|
||||
<li>
|
||||
<%= form.check_box "modules[#{my_module.id}]", label: my_module.name %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<% else %>
|
||||
<div>
|
||||
<em>
|
||||
|
|
|
@ -3,56 +3,24 @@
|
|||
<div>
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#module-tab" aria-controls="module-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.module_contents.module_tab") %></a></li>
|
||||
<li role="presentation"><a href="#module-steps-tab" aria-controls="module-steps-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.module_contents.steps_tab") %></a></li>
|
||||
<li role="presentation"><a href="#step-results-tab" aria-controls="step-results-tab" role="tab" data-toggle="tab"><%= t("projects.reports.elements.modals.module_contents.results_tab") %></a></li>
|
||||
<li role="presentation" class="active">
|
||||
<a href="#content-tab" aria-controls="content-tab" role="tab" data-toggle="tab">
|
||||
<span class="glyphicon glyphicon-link visible-xs"></span>
|
||||
<span class="hidden-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="module-tab">
|
||||
<%= render partial: "reports/new/modal/module_contents_inner.html.erb", locals: { form: f, my_module: my_module } %>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="module-steps-tab">
|
||||
<div role="tabpanel" class="tab-pane active" id="content-tab">
|
||||
<h5 class="visible-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></h5>
|
||||
<%= render partial: "reports/new/modal/module_contents_inner.html.erb", locals: { form: f } %>
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/step_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="step-results-tab">
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/result_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script type="javascript">
|
||||
$(function() {
|
||||
var form = $("#add-contents-form");
|
||||
var moduleTab = form.find("#module-tab");
|
||||
var stepsTab = form.find("#module-steps-tab");
|
||||
|
||||
var moduleCheckAll = moduleTab.find("#_module_content_all");
|
||||
var moduleOthers = moduleTab.find("input:checkbox:not(#_module_content_all)");
|
||||
var moduleResultsAll = moduleTab.find(".results-all");
|
||||
var moduleResults = moduleTab.find(".result-cb");
|
||||
moduleCheckAll.click(function() {
|
||||
moduleOthers.prop("checked", this.checked);
|
||||
});
|
||||
moduleOthers.click(function() {
|
||||
moduleCheckAll.prop("checked", false);
|
||||
});
|
||||
moduleResultsAll.click(function() {
|
||||
moduleResults.prop("checked", this.checked);
|
||||
});
|
||||
moduleResults.click(function() {
|
||||
moduleResultsAll.prop("checked", false);
|
||||
});
|
||||
|
||||
var stepsCheckAll = stepsTab.find("#_step_content_all");
|
||||
var stepsOthers = stepsTab.find("input:checkbox:not(#_step_content_all)");
|
||||
stepsCheckAll.click(function() {
|
||||
stepsOthers.prop("checked", this.checked);
|
||||
});
|
||||
stepsOthers.click(function() {
|
||||
stepsCheckAll.prop("checked", false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<%= form.check_box :module_content_all, label: t("projects.reports.elements.modals.module_contents_inner.check_all") %>
|
||||
<ul>
|
||||
|
||||
<% if my_module_undefined or my_module.protocol.steps.count > 0 %>
|
||||
<% if my_module_undefined or my_module.protocol.steps.present? %>
|
||||
<li>
|
||||
<%= form.check_box :module_steps, label: t("projects.reports.elements.modals.module_contents_inner.steps") %>
|
||||
</li>
|
||||
|
@ -26,24 +26,24 @@
|
|||
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.active? }).present? %>
|
||||
<li>
|
||||
<%= form.check_box :module_results, label: t("projects.reports.elements.modals.module_contents_inner.results"), class: "results-all" %>
|
||||
<%= form.check_box :module_results, label: t("projects.reports.elements.modals.module_contents_inner.results") %>
|
||||
<ul>
|
||||
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_asset && r.active? }).count > 0 %>
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_asset && r.active? }).present? %>
|
||||
<li>
|
||||
<%= form.check_box :module_result_assets, label: t("projects.reports.elements.modals.module_contents_inner.result_assets"), class: "result-cb" %>
|
||||
<%= form.check_box :module_result_assets, label: t("projects.reports.elements.modals.module_contents_inner.result_assets") %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_table && r.active? }).count > 0 %>
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_table && r.active? }).present? %>
|
||||
<li>
|
||||
<%= form.check_box :module_result_tables, label: t("projects.reports.elements.modals.module_contents_inner.result_tables"), class: "result-cb" %>
|
||||
<%= form.check_box :module_result_tables, label: t("projects.reports.elements.modals.module_contents_inner.result_tables") %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_text && r.active? }).count > 0 %>
|
||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_text && r.active? }).present? %>
|
||||
<li>
|
||||
<%= form.check_box :module_result_texts, label: t("projects.reports.elements.modals.module_contents_inner.result_texts"), class: "result-cb" %>
|
||||
<%= form.check_box :module_result_texts, label: t("projects.reports.elements.modals.module_contents_inner.result_texts") %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<span class="hidden-xs"><%= t("projects.reports.elements.modals.project_contents.tasks_tab") %></span>
|
||||
</a>
|
||||
</li>
|
||||
<% if project.project_my_modules.is_archived(false).count > 0 %>
|
||||
<% if project.project_my_modules.is_archived(false).present? %>
|
||||
<li role="presentation">
|
||||
<a href="#content-tab" aria-controls="content-tab" role="tab" data-toggle="tab">
|
||||
<span class="glyphicon glyphicon-link visible-xs"></span>
|
||||
|
@ -25,22 +25,20 @@
|
|||
<h5 class="visible-xs"><%= t("projects.reports.elements.modals.project_contents.tasks_tab") %></h5>
|
||||
<%= render partial: "reports/new/modal/project_contents_inner.html.erb", locals: { form: f, project: project } %>
|
||||
</div>
|
||||
<% if project.project_my_modules.is_archived(false).count > 0 %>
|
||||
<div role="tabpanel" class="tab-pane" id="content-tab">
|
||||
<h5 class="visible-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></h5>
|
||||
<%= render partial: "reports/new/modal/module_contents_inner.html.erb", locals: { form: f } %>
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/step_contents_inner.html.erb", locals: { form: f } %>
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/result_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div role="tabpanel" class="tab-pane" id="content-tab">
|
||||
<h5 class="visible-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></h5>
|
||||
<%= render partial: "reports/new/modal/module_contents_inner.html.erb", locals: { form: f } %>
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/step_contents_inner.html.erb", locals: { form: f } %>
|
||||
<hr>
|
||||
<%= render partial: "reports/new/modal/result_contents_inner.html.erb", locals: { form: f } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script type="javascript">
|
||||
function checkboxTree2() {
|
||||
function checkboxTree() {
|
||||
$(".checkbox-tree input:checkbox").change(function() {
|
||||
// Update descendent checkboxes
|
||||
var $checkbox = $(this);
|
||||
|
@ -64,5 +62,5 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
checkboxTree2();
|
||||
checkboxTree();
|
||||
</script>
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
<li>
|
||||
<%= form.check_box :project, label: project.name %>
|
||||
<ul>
|
||||
|
||||
<% project.experiments.is_archived(false).each do |experiment| %>
|
||||
<% next unless experiment.my_modules.is_archived(false).present? %>
|
||||
<li>
|
||||
<%= form.check_box "experiment_#{experiment.id}", label: experiment.name %>
|
||||
<ul>
|
||||
|
||||
<% experiment.my_module_groups.each do |my_module_group| %>
|
||||
<% next unless my_module_group.my_modules.is_archived(false).present? %>
|
||||
<% my_module_group.ordered_modules.is_archived(false).each do |my_module| %>
|
||||
|
@ -33,9 +35,11 @@
|
|||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<div class="checkbox-tree">
|
||||
<ul>
|
||||
<li><!-- result_content_all needed?-->
|
||||
<li>
|
||||
<%= form.label :result_content_all, t("projects.reports.elements.modals.result_contents_inner.check_all"), class: "checkbox" %>
|
||||
<ul>
|
||||
|
||||
|
|
|
@ -1,19 +1,4 @@
|
|||
<%= bootstrap_form_tag remote: true, url: step_contents_project_reports_path(project, format: :json), method: :post, html: { id: "add-contents-form" } do |f| %>
|
||||
<%= hidden_field_tag :id, step.id %>
|
||||
|
||||
<%= render partial: "reports/new/modal/step_contents_inner.html.erb", locals: { form: f, step: step } %>
|
||||
<% end %>
|
||||
|
||||
<script type="javascript">
|
||||
$(function() {
|
||||
var form = $("#add-contents-form");
|
||||
var checkAll = form.find("#_step_content_all");
|
||||
var others = form.find("input:checkbox:not(#_step_content_all)");
|
||||
checkAll.click(function() {
|
||||
others.prop("checked", this.checked);
|
||||
});
|
||||
others.click(function() {
|
||||
checkAll.prop("checked", false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -292,7 +292,7 @@ en:
|
|||
instructions: "Choose what information from task/s to include in the report"
|
||||
check_all: "All tasks content"
|
||||
steps: "Completed protocol steps"
|
||||
no_steps: "Task contains no protocols"
|
||||
no_steps: "Task has no steps"
|
||||
results: "Results"
|
||||
result_assets: "Files"
|
||||
result_tables: "Tables"
|
||||
|
|
Loading…
Add table
Reference in a new issue