mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 12:09:17 +08:00
Readded result content modal for report creation and updated checkbox hierarchy logic accordingly. [fixes SCI-487]
This commit is contained in:
parent
2c6f888cbc
commit
20265ddd69
6 changed files with 117 additions and 9 deletions
|
@ -203,6 +203,12 @@ function initializeNewElement(newEl) {
|
|||
url = dh.data("add-experiment-contents-url"); break;
|
||||
case "my_module":
|
||||
url = dh.data("add-module-contents-url"); break;
|
||||
case "step":
|
||||
url = dh.data("add-step-contents-url"); break;
|
||||
case "result_asset":
|
||||
case "result_table":
|
||||
case "result_text":
|
||||
url = dh.data("add-result-contents-url"); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -228,10 +228,14 @@ $.fn.checkboxTreeLogic = function(dependencies, checkAll) {
|
|||
}
|
||||
|
||||
// Disable/enable dependent checkboxes
|
||||
$.each(dependencies, function(k, $v) {
|
||||
var enable = $checkboxTree.find('#' + k).closest('li')
|
||||
.find('input:checkbox:checked').length
|
||||
$v.closest('li').find('input:checkbox').prop('disabled', !enable);
|
||||
$.each(dependencies, function(responsibleParentID, $dependentParent) {
|
||||
var $responsibleParent = $checkboxTree.find('#' + responsibleParentID);
|
||||
if ($responsibleParent.length) {
|
||||
var enable = $responsibleParent.closest('li')
|
||||
.find('input:checkbox:checked').length
|
||||
$dependentParent.closest('li').find('input:checkbox')
|
||||
.prop('disabled', !enable);
|
||||
}
|
||||
});
|
||||
}).trigger('change');
|
||||
};
|
||||
|
|
|
@ -49,7 +49,7 @@ label {
|
|||
&[for="_experiment_all"],
|
||||
&[for="_module_all"],
|
||||
&[for="_step_all"],
|
||||
&[for="result_all"] {
|
||||
&[for="_result_all"] {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,12 @@ class ReportsController < ApplicationController
|
|||
:project_contents_modal,
|
||||
:experiment_contents_modal,
|
||||
:module_contents_modal,
|
||||
:step_contents_modal,
|
||||
:result_contents_modal,
|
||||
:project_contents,
|
||||
:module_contents
|
||||
:module_contents,
|
||||
:step_contents,
|
||||
:result_contents
|
||||
]
|
||||
|
||||
before_action :check_view_permissions, only: :index
|
||||
|
@ -36,8 +40,12 @@ class ReportsController < ApplicationController
|
|||
:project_contents_modal,
|
||||
:experiment_contents_modal,
|
||||
:module_contents_modal,
|
||||
:step_contents_modal,
|
||||
:result_contents_modal,
|
||||
:project_contents,
|
||||
:module_contents
|
||||
:module_contents,
|
||||
:step_contents,
|
||||
:result_contents
|
||||
]
|
||||
before_action :check_destroy_permissions, only: :destroy
|
||||
|
||||
|
@ -267,6 +275,50 @@ class ReportsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# Modal for adding contents into step element
|
||||
def step_contents_modal
|
||||
step = Step.find_by_id(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if step.blank?
|
||||
format.json do
|
||||
render json: {}, status: :not_found
|
||||
end
|
||||
else
|
||||
format.json do
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
partial: 'reports/new/modal/step_contents.html.erb',
|
||||
locals: { project: @project, step: step }
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Modal for adding contents into result element
|
||||
def result_contents_modal
|
||||
result = Result.find_by_id(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if result.blank?
|
||||
format.json do
|
||||
render json: {}, status: :not_found
|
||||
end
|
||||
else
|
||||
format.json do
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
partial: 'reports/new/modal/result_contents.html.erb',
|
||||
locals: { project: @project, result: result }
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def project_contents
|
||||
respond_to do |format|
|
||||
elements = generate_project_contents_json
|
||||
|
@ -335,6 +387,52 @@ class ReportsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def step_contents
|
||||
step = Step.find_by_id(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if step.blank?
|
||||
format.json { render json: {}, status: :not_found }
|
||||
else
|
||||
elements = generate_step_contents_json(step)
|
||||
|
||||
if elements_empty? elements
|
||||
format.json { render json: {}, status: :no_content }
|
||||
else
|
||||
format.json {
|
||||
render json: {
|
||||
status: :ok,
|
||||
elements: elements
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def result_contents
|
||||
result = Result.find_by_id(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if result.blank?
|
||||
format.json { render json: {}, status: :not_found }
|
||||
else
|
||||
elements = generate_result_contents_json(result)
|
||||
|
||||
if elements_empty? elements
|
||||
format.json { render json: {}, status: :no_content }
|
||||
else
|
||||
format.json {
|
||||
render json: {
|
||||
status: :ok,
|
||||
elements: elements
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_vars
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
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-step-contents-url="<%= step_contents_modal_project_reports_url %>"
|
||||
data-add-result-contents-url="<%= result_contents_modal_project_reports_url %>"
|
||||
data-stylesheet-url="<%= stylesheet_path "application" %>"
|
||||
data-print-title="<%=t "projects.reports.print_title", project: @project.name %>"
|
||||
data-project-id="<%= @project.id %>"
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
<li>
|
||||
<%= form.label :result_all, t("projects.reports.elements.modals.result_contents_inner.check_all"), class: "checkbox" %>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<%= form.check_box :result_comments, label: t("projects.reports.elements.modals.result_contents_inner.comments") %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue