Skip to content

Commit 1ddc903

Browse files
committed
Add the JS code to handle the "Include all projects" #1524
Signed-off-by: tdruez <[email protected]>
1 parent 760ee90 commit 1ddc903

File tree

5 files changed

+47
-22
lines changed

5 files changed

+47
-22
lines changed

scancodeio/static/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ function setupSelectCheckbox() {
232232
updateButtonAndDropdownState();
233233

234234
// Check if all row checkboxes are checked and update the "Select All" checkbox accordingly
235-
selectAllCheckbox.checked = Array.from(rowCheckboxes).every((cb) => cb.checked);
235+
const allRowCheckboxesChecked = Array.from(rowCheckboxes).every((cb) => cb.checked);
236+
selectAllCheckbox.checked = allRowCheckboxesChecked;
236237
});
237238
});
238239

scanpipe/templates/scanpipe/modals/projects_archive_modal.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
</label>
3535
</div>
3636
{% if page_obj.paginator.num_pages > 1 %}
37-
<hr>
38-
<div class="field">
39-
<label class="checkbox" for="{{ archive_form.select_across.id_for_label }}">
40-
<input type="checkbox" name="{{ archive_form.select_across.name }}" id="{{ archive_form.select_across.id_for_label }}">
41-
Include all {{ paginator.count|intcomma }} projects
42-
</label>
43-
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
37+
<div class="show-on-all-checked">
38+
<hr>
39+
<div class="field include-all-field">
40+
<label class="checkbox" for="{{ archive_form.select_across.id_for_label }}">
41+
<input type="checkbox" name="{{ archive_form.select_across.name }}" id="{{ archive_form.select_across.id_for_label }}">
42+
Include all {{ paginator.count|intcomma }} projects
43+
</label>
44+
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
45+
</div>
4446
</div>
4547
{% endif %}
4648
</section>

scanpipe/templates/scanpipe/modals/projects_download_modal.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
</div>
1616
</div>
1717
{% if page_obj.paginator.num_pages > 1 %}
18-
<hr>
19-
<div class="field">
20-
<label class="checkbox" for="{{ outputs_download_form.select_across.id_for_label }}">
21-
<input type="checkbox" name="{{ outputs_download_form.select_across.name }}" id="{{ outputs_download_form.select_across.id_for_label }}">
22-
Include all {{ paginator.count|intcomma }} projects
23-
</label>
24-
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
18+
<div class="show-on-all-checked">
19+
<hr>
20+
<div class="field">
21+
<label class="checkbox" for="{{ outputs_download_form.select_across.id_for_label }}">
22+
<input type="checkbox" name="{{ outputs_download_form.select_across.name }}" id="{{ outputs_download_form.select_across.id_for_label }}">
23+
Include all {{ paginator.count|intcomma }} projects
24+
</label>
25+
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
26+
</div>
2527
</div>
2628
{% endif %}
2729
</section>

scanpipe/templates/scanpipe/modals/projects_report_modal.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
</div>
1616
</div>
1717
{% if page_obj.paginator.num_pages > 1 %}
18-
<hr>
19-
<div class="field">
20-
<label class="checkbox" for="{{ report_form.select_across.id_for_label }}">
21-
<input type="checkbox" name="{{ report_form.select_across.name }}" id="{{ report_form.select_across.id_for_label }}">
22-
Include all {{ paginator.count|intcomma }} projects
23-
</label>
24-
<p class="help">{{ report_form.select_across.help_text }}</p>
18+
<div class="show-on-all-checked">
19+
<hr>
20+
<div class="field include-all-field">
21+
<label class="checkbox" for="{{ report_form.select_across.id_for_label }}">
22+
<input type="checkbox" name="{{ report_form.select_across.name }}" id="{{ report_form.select_across.id_for_label }}">
23+
Include all {{ paginator.count|intcomma }} projects
24+
</label>
25+
<p class="help">{{ report_form.select_across.help_text }}</p>
26+
</div>
2527
</div>
2628
{% endif %}
2729
</section>

scanpipe/templates/scanpipe/project_list.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@
9898
}
9999
});
100100
});
101+
102+
document.addEventListener("openModal", function(event) {
103+
// Get all elements that should be shown or hidden based on the state of the checkboxes
104+
const elementsForAllRowsChecked = getAll(".show-on-all-checked");
105+
const selectAllCheckbox = document.getElementById("select-all");
106+
const displayValue = selectAllCheckbox.checked ? "block" : "none";
107+
108+
// Iterate through all elements that need to be shown or hidden and apply the display style
109+
elementsForAllRowsChecked.forEach((field) => {
110+
field.style.display = displayValue;
111+
});
112+
});
113+
101114
});
102115
</script>
116+
117+
118+
<script>
119+
120+
</script>
103121
{% endblock %}

0 commit comments

Comments
 (0)