mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-24 17:06:14 +08:00
67 lines
3 KiB
Plaintext
67 lines
3 KiB
Plaintext
<%= bootstrap_form_tag remote: true, url: project_contents_project_reports_path(project, format: :json), method: :post, html: { id: "add-contents-form" } do |f| %>
|
|
<%= hidden_field_tag :id, project.id %>
|
|
<div>
|
|
<!-- Nav tabs -->
|
|
<ul class="nav nav-tabs" role="tablist">
|
|
<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>
|
|
<% 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>
|
|
<span class="hidden-xs"><%= t("projects.reports.elements.modals.project_contents.content_tab") %></span>
|
|
</a>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
|
|
<!-- Tab panes -->
|
|
<div class="tab-content">
|
|
<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/project_contents_inner.html.erb", locals: { form: f, project: project } %>
|
|
</div>
|
|
<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 checkboxTree() {
|
|
$(".checkbox-tree input:checkbox").change(function() {
|
|
// Update descendent checkboxes
|
|
var $checkbox = $(this);
|
|
var checkboxChecked = $checkbox.prop("checked");
|
|
var $childCheckboxes = $checkbox.closest("li").find("ul input:checkbox");
|
|
$childCheckboxes.each(function() {
|
|
$(this).prop('checked', checkboxChecked);
|
|
});
|
|
|
|
// Update ancestor checkboxes
|
|
// Loop until top checkbox is reached or until parent checkbox isn't there
|
|
while ($checkbox.length !== 0 && !$checkbox.hasClass("checkbox-tree")) {
|
|
var $checkboxesContainer = $checkbox.closest("ul");
|
|
var $parentCheckbox = $checkboxesContainer.siblings().find("input:checkbox");
|
|
var $checkboxes = $checkboxesContainer.find("input:checkbox");
|
|
var $checkedCheckboxes = $checkboxes.filter(':checked');
|
|
|
|
$parentCheckbox.prop('checked',
|
|
$checkboxes.length == $checkedCheckboxes.length);
|
|
$checkbox = $parentCheckbox;
|
|
}
|
|
});
|
|
}
|
|
checkboxTree();
|
|
</script>
|