mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-07 20:40:26 +08:00
Add experiment content report dialog
Adding still has to be implemented
This commit is contained in:
parent
b402d67f24
commit
acc41dae40
7 changed files with 160 additions and 23 deletions
|
@ -176,17 +176,18 @@ function initializeNewElement(newEl) {
|
||||||
parentElementId = parent.data("id");
|
parentElementId = parent.data("id");
|
||||||
modalTitle = parent.data("modal-title");
|
modalTitle = parent.data("modal-title");
|
||||||
|
|
||||||
if (parent.data("type") == "my_module") {
|
// Select correct AJAX URL based on type
|
||||||
// Adding module contents
|
switch (parent.data("type")) {
|
||||||
url = dh.data("add-module-contents-url");
|
case "experiment":
|
||||||
} else if (parent.data("type") == "step") {
|
url = dh.data("add-experiment-contents-url"); break;
|
||||||
// Adding step contents
|
case "my_module":
|
||||||
url = dh.data("add-step-contents-url");
|
url = dh.data("add-module-contents-url"); break;
|
||||||
} else if (_.contains(
|
case "step":
|
||||||
["result_asset", "result_table", "result_text"],
|
url = dh.data("add-step-contents-url"); break;
|
||||||
parent.data("type"))) {
|
case "result_asset":
|
||||||
// Adding result comments
|
case "result_table":
|
||||||
url = dh.data("add-result-contents-url");
|
case "result_text":
|
||||||
|
url = dh.data("add-result-contents-url"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class ReportsController < ApplicationController
|
||||||
:destroy,
|
:destroy,
|
||||||
:save_modal,
|
:save_modal,
|
||||||
:project_contents_modal,
|
:project_contents_modal,
|
||||||
|
:experiment_contents_modal,
|
||||||
:module_contents_modal,
|
:module_contents_modal,
|
||||||
:step_contents_modal,
|
:step_contents_modal,
|
||||||
:result_contents_modal,
|
:result_contents_modal,
|
||||||
|
@ -35,6 +36,7 @@ class ReportsController < ApplicationController
|
||||||
:generate,
|
:generate,
|
||||||
:save_modal,
|
:save_modal,
|
||||||
:project_contents_modal,
|
:project_contents_modal,
|
||||||
|
:experiment_contents_modal,
|
||||||
:module_contents_modal,
|
:module_contents_modal,
|
||||||
:step_contents_modal,
|
:step_contents_modal,
|
||||||
:result_contents_modal,
|
:result_contents_modal,
|
||||||
|
@ -213,27 +215,49 @@ class ReportsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Experiment for adding contents into experiment element
|
||||||
|
def experiment_contents_modal
|
||||||
|
experiment = Experiment.find_by_id(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if experiment.blank?
|
||||||
|
format.json do
|
||||||
|
render json: {}, status: :not_found
|
||||||
|
end
|
||||||
|
else
|
||||||
|
format.json do
|
||||||
|
render json: {
|
||||||
|
html: render_to_string(
|
||||||
|
partial: "reports/new/modal/experiment_contents.html.erb",
|
||||||
|
locals: { project: @project, experiment: experiment }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Modal for adding contents into module element
|
# Modal for adding contents into module element
|
||||||
def module_contents_modal
|
def module_contents_modal
|
||||||
my_module = MyModule.find_by_id(params[:id])
|
my_module = MyModule.find_by_id(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if my_module.blank?
|
if my_module.blank?
|
||||||
format.json {
|
format.json do
|
||||||
render json: {}, status: :not_found
|
render json: {}, status: :not_found
|
||||||
}
|
end
|
||||||
else
|
else
|
||||||
format.json {
|
format.json do
|
||||||
render json: {
|
render json: {
|
||||||
html: render_to_string({
|
html: render_to_string(
|
||||||
partial: "reports/new/modal/module_contents.html.erb",
|
partial: "reports/new/modal/module_contents.html.erb",
|
||||||
locals: { project: @project, my_module: my_module }
|
locals: { project: @project, my_module: my_module }
|
||||||
})
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Modal for adding contents into step element
|
# Modal for adding contents into step element
|
||||||
def step_contents_modal
|
def step_contents_modal
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
class="hidden"
|
class="hidden"
|
||||||
data-project-modal-title="<%=t "projects.reports.elements.modals.project_contents.head_title" %>"
|
data-project-modal-title="<%=t "projects.reports.elements.modals.project_contents.head_title" %>"
|
||||||
data-add-project-contents-url="<%= project_contents_modal_project_reports_url %>"
|
data-add-project-contents-url="<%= project_contents_modal_project_reports_url %>"
|
||||||
|
data-add-experiment-contents-url="<%= experiment_contents_modal_project_reports_url %>"
|
||||||
data-add-module-contents-url="<%= module_contents_modal_project_reports_url %>"
|
data-add-module-contents-url="<%= module_contents_modal_project_reports_url %>"
|
||||||
data-add-step-contents-url="<%= step_contents_modal_project_reports_url %>"
|
data-add-step-contents-url="<%= step_contents_modal_project_reports_url %>"
|
||||||
data-add-result-contents-url="<%= result_contents_modal_project_reports_url %>"
|
data-add-result-contents-url="<%= result_contents_modal_project_reports_url %>"
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
data-project-id="<%= @project.id %>"
|
data-project-id="<%= @project.id %>"
|
||||||
data-save-report-url="<%= save_modal_project_reports_url %>"
|
data-save-report-url="<%= save_modal_project_reports_url %>"
|
||||||
data-report-id="<%= @report.present? ? @report.id : "" %>"
|
data-report-id="<%= @report.present? ? @report.id : "" %>"
|
||||||
data-unsaved-work-text="<%=t "projects.reports.new.unsaved_work" %>"
|
data,unsaved-work-text="<%=t "projects.reports.new.unsaved_work" %>"
|
||||||
data-global-sort-text="<%=t "projects.reports.new.global_sort" %>"
|
data-global-sort-text="<%=t "projects.reports.new.global_sort" %>"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
62
app/views/reports/new/modal/_experiment_contents.html.erb
Normal file
62
app/views/reports/new/modal/_experiment_contents.html.erb
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<%= bootstrap_form_tag remote: true, url: experiment_contents_project_reports_path(project, format: :json), method: :post, html: { id: "add-contents-form" } do |f| %>
|
||||||
|
<%= hidden_field_tag :id, experiment.id %>
|
||||||
|
<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>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Tab panes -->
|
||||||
|
<div class="tab-content">
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="experiment-tab">
|
||||||
|
<%= 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">
|
||||||
|
<%= render partial: "reports/new/modal/module_contents_inner.html.erb", locals: { form: f } %>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="module-steps-tab">
|
||||||
|
<%= render partial: "reports/new/modal/step_contents_inner.html.erb", locals: { form: f } %>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="step-results-tab">
|
||||||
|
<%= 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-check-all");
|
||||||
|
var moduleOthers = moduleTab.find("input:checkbox:not(.module-check-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-check-all");
|
||||||
|
var stepsOthers = stepsTab.find("input:checkbox:not(.step-check-all)");
|
||||||
|
stepsCheckAll.click(function() {
|
||||||
|
stepsOthers.prop("checked", this.checked);
|
||||||
|
});
|
||||||
|
stepsOthers.click(function() {
|
||||||
|
stepsCheckAll.prop("checked", false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<div>
|
||||||
|
<em>
|
||||||
|
<%= t("projects.reports.elements.modals.experiment_contents_inner.instructions") %>
|
||||||
|
</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if experiment.my_modules.count > 0 %>
|
||||||
|
<%= form.check_box :experiment, label: experiment.name, class: "experiment-all-cb" %>
|
||||||
|
<ul class="no-style 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>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<!-- Tasks without groups -->
|
||||||
|
<% modules_without_group = experiment.modules_without_group %>
|
||||||
|
<% if modules_without_group.present? and modules_without_group.count > 0 %>
|
||||||
|
<ul class="no-style experiment-contents-list">
|
||||||
|
<% modules_without_group.each do |my_module| %>
|
||||||
|
<li>
|
||||||
|
<%= form.check_box "modules[#{my_module.id}]", label: my_module.name %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<% else %>
|
||||||
|
<div>
|
||||||
|
<em>
|
||||||
|
<%= t("projects.reports.elements.modals.experiment_contents_inner.no_modules") %>
|
||||||
|
</em>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -275,11 +275,6 @@ en:
|
||||||
module_tab: "Task content"
|
module_tab: "Task content"
|
||||||
steps_tab: "Protocols content"
|
steps_tab: "Protocols content"
|
||||||
results_tab: "Results content"
|
results_tab: "Results content"
|
||||||
experiment_contents:
|
|
||||||
head_title: "Add contents to experiment %{experiment}"
|
|
||||||
module_tab: "Task content"
|
|
||||||
steps_tab: "Protocols content"
|
|
||||||
results_tab: "Results content"
|
|
||||||
module_contents_inner:
|
module_contents_inner:
|
||||||
instructions: "Choose what information from task/s to include in the report"
|
instructions: "Choose what information from task/s to include in the report"
|
||||||
header: "Report elements"
|
header: "Report elements"
|
||||||
|
@ -292,6 +287,15 @@ en:
|
||||||
no_results: "Task contains no results"
|
no_results: "Task contains no results"
|
||||||
activity: "Activity"
|
activity: "Activity"
|
||||||
samples: "Samples"
|
samples: "Samples"
|
||||||
|
experiment_contents:
|
||||||
|
head_title: "Add contents to experiment %{experiment}"
|
||||||
|
experiment_tab: "Experiment content"
|
||||||
|
module_tab: "Task content"
|
||||||
|
steps_tab: "Protocols content"
|
||||||
|
results_tab: "Results content"
|
||||||
|
experiment_contents_inner:
|
||||||
|
instructions: "Select tasks to include in the report"
|
||||||
|
no_modules: "The experiment contains no tasks"
|
||||||
step_contents:
|
step_contents:
|
||||||
head_title: "Add contents to step %{step}"
|
head_title: "Add contents to step %{step}"
|
||||||
step_tab: "Step content"
|
step_tab: "Step content"
|
||||||
|
|
|
@ -66,6 +66,12 @@ Rails.application.routes.draw do
|
||||||
post 'new/project_contents',
|
post 'new/project_contents',
|
||||||
to: 'reports#project_contents',
|
to: 'reports#project_contents',
|
||||||
as: :project_contents
|
as: :project_contents
|
||||||
|
get 'new/experiment_contents_modal',
|
||||||
|
to: 'reports#experiment_contents_modal',
|
||||||
|
as: :experiment_contents_modal
|
||||||
|
post 'new/experiment_contents',
|
||||||
|
to: 'reports#experiment_contents',
|
||||||
|
as: :experiment_contents
|
||||||
get 'new/module_contents_modal',
|
get 'new/module_contents_modal',
|
||||||
to: 'reports#module_contents_modal',
|
to: 'reports#module_contents_modal',
|
||||||
as: :module_contents_modal
|
as: :module_contents_modal
|
||||||
|
|
Loading…
Add table
Reference in a new issue