Skip to content

Commit a6f7c86

Browse files
authored
Add a select_across checkbox on the ProjectReportForm #1524 (#1534)
Signed-off-by: tdruez <[email protected]>
1 parent 54e63b6 commit a6f7c86

File tree

15 files changed

+309
-86
lines changed

15 files changed

+309
-86
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ v34.9.4 (unreleased)
5454
multiple projects at once using labels and searching by project name.
5555
https://github.com/aboutcode-org/scancode.io/issues/1524
5656

57+
- Add the ability to "select across" in Projects list when using the "select all"
58+
checkbox on paginated list.
59+
https://github.com/aboutcode-org/scancode.io/issues/1524
60+
5761
v34.9.3 (2024-12-31)
5862
--------------------
5963

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/forms.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,21 @@ def save(self, project):
238238
return input_source
239239

240240

241-
class ArchiveProjectForm(forms.Form):
241+
class BaseProjectActionForm(forms.Form):
242+
select_across = forms.BooleanField(
243+
label="",
244+
required=False,
245+
initial=0,
246+
help_text="All project matching current search and filters will be included.",
247+
)
248+
url_query = forms.CharField(
249+
widget=forms.HiddenInput,
250+
required=False,
251+
help_text="Stores the current URL filters.",
252+
)
253+
254+
255+
class ArchiveProjectForm(BaseProjectActionForm):
242256
remove_input = forms.BooleanField(
243257
label="Remove inputs",
244258
initial=True,
@@ -255,8 +269,15 @@ class ArchiveProjectForm(forms.Form):
255269
required=False,
256270
)
257271

272+
def get_action_kwargs(self):
273+
return {
274+
"remove_input": self.cleaned_data["remove_input"],
275+
"remove_codebase": self.cleaned_data["remove_codebase"],
276+
"remove_output": self.cleaned_data["remove_output"],
277+
}
278+
258279

259-
class ProjectOutputDownloadForm(forms.Form):
280+
class ProjectOutputDownloadForm(BaseProjectActionForm):
260281
output_format = forms.ChoiceField(
261282
label="Choose the output format to include in the ZIP file",
262283
choices=[
@@ -272,7 +293,7 @@ class ProjectOutputDownloadForm(forms.Form):
272293
)
273294

274295

275-
class ProjectReportForm(forms.Form):
296+
class ProjectReportForm(BaseProjectActionForm):
276297
model_name = forms.ChoiceField(
277298
label="Choose the object type to include in the XLSX file",
278299
choices=[

scanpipe/pipes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def collect_and_create_codebase_resources(project, batch_size=5000):
113113
Collect and create codebase resources including the "to/" and "from/" context using
114114
the resource tag field.
115115
116-
The default ``batch_size`` can be overriden, although the benefits of a value
116+
The default ``batch_size`` can be overridden, although the benefits of a value
117117
greater than 5000 objects are usually not significant.
118118
"""
119119
model_class = CodebaseResource

scanpipe/templates/registration/login.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<div class="field">
2222
<label class="label">Username</label>
2323
<div class="control has-icons-left">
24-
<!-- {{ form.username }}-->
2524
<input class="input" type="text" name="username" autofocus autocomplete="username" maxlength="150" required id="id_username">
2625
<span class="icon is-small is-left">
2726
<i class="fa-solid fa-user"></i>
@@ -32,7 +31,6 @@
3231
<div class="field mb-5">
3332
<label class="label">Password</label>
3433
<div class="control has-icons-left">
35-
<!-- {{ form.password }}-->
3634
<input class="input" type="password" name="password" autocomplete="current-password" required id="id_password">
3735
<span class="icon is-small is-left">
3836
<i class="fa-solid fa-lock"></i>

scanpipe/templates/scanpipe/modals/project_archive_modal.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,24 @@
1414
<p class="mb-2">
1515
The selected directories will be removed:
1616
</p>
17-
<ul class="mb-5">
18-
{{ archive_form.as_ul }}
19-
</ul>
17+
<div class="field">
18+
<label class="label">
19+
{{ archive_form.remove_input }}
20+
{{ archive_form.remove_input.label }}
21+
</label>
22+
</div>
23+
<div class="field">
24+
<label class="label">
25+
{{ archive_form.remove_codebase }}
26+
{{ archive_form.remove_codebase.label }}
27+
</label>
28+
</div>
29+
<div class="field">
30+
<label class="label">
31+
{{ archive_form.remove_output }}
32+
{{ archive_form.remove_output.label }}
33+
</label>
34+
</div>
2035
<p>
2136
Are you sure you want to do this?
2237
</p>

scanpipe/templates/scanpipe/modals/projects_archive_modal.html

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load humanize %}
12
<div class="modal" id="modal-projects-archive">
23
<div class="modal-background"></div>
34
<div class="modal-card">
@@ -9,18 +10,43 @@
910
<section class="modal-card-body">
1011
<div class="notification is-warning has-text-weight-semibold">
1112
The selected projects will be marked as archived and will become read-only.
12-
Those will not appear in the project list by default anymore.
13+
Those will not appear in the project list by default anymore.<br>
1314
</div>
1415
<p class="mb-2">
1516
The selected directories will be removed:
1617
</p>
17-
<ul class="mb-5">
18-
{{ archive_form.as_ul }}
19-
</ul>
20-
<p>
21-
Are you sure you want to do this?
22-
</p>
18+
<div class="field">
19+
<label class="label">
20+
{{ archive_form.remove_input }}
21+
{{ archive_form.remove_input.label }}
22+
</label>
23+
</div>
24+
<div class="field">
25+
<label class="label">
26+
{{ archive_form.remove_codebase }}
27+
{{ archive_form.remove_codebase.label }}
28+
</label>
29+
</div>
30+
<div class="field">
31+
<label class="label">
32+
{{ archive_form.remove_output }}
33+
{{ archive_form.remove_output.label }}
34+
</label>
35+
</div>
36+
{% if page_obj.paginator.num_pages > 1 %}
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>
46+
</div>
47+
{% endif %}
2348
</section>
49+
<input type="hidden" name="{{ archive_form.url_query.name }}" value="{{ request.GET.urlencode }}">
2450
<input type="hidden" name="action" value="archive">
2551
<footer class="modal-card-foot is-flex is-justify-content-space-between">
2652
<button class="button has-text-weight-semibold" type="reset">No, Cancel</button>

scanpipe/templates/scanpipe/modals/projects_delete_modal.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load humanize %}
12
<div class="modal" id="modal-projects-delete">
23
<div class="modal-background"></div>
34
<div class="modal-card">
@@ -21,6 +22,7 @@
2122
</p>
2223
</section>
2324
<form action="{% url 'project_action' %}" method="post" id="delete-projects-form">{% csrf_token %}
25+
<input type="hidden" name="{{ action_form.url_query.name }}" value="{{ request.GET.urlencode }}">
2426
<input type="hidden" name="action" value="delete">
2527
<footer class="modal-card-foot is-flex is-justify-content-space-between">
2628
<button class="button has-text-weight-semibold" type="reset">No, Cancel</button>

scanpipe/templates/scanpipe/modals/projects_download_modal.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load humanize %}
12
<div class="modal" id="modal-projects-download">
23
<div class="modal-background"></div>
34
<div class="modal-card">
@@ -7,10 +8,26 @@
78
</header>
89
<form action="{% url 'project_action' %}" method="post" id="download-projects-form">{% csrf_token %}
910
<section class="modal-card-body">
10-
<ul class="mb-3">
11-
{{ outputs_download_form.as_ul }}
12-
</ul>
11+
<div class="field">
12+
<label class="label">{{ outputs_download_form.output_format.label }}</label>
13+
<div class="control">
14+
{{ outputs_download_form.output_format }}
15+
</div>
16+
</div>
17+
{% if page_obj.paginator.num_pages > 1 %}
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>
27+
</div>
28+
{% endif %}
1329
</section>
30+
<input type="hidden" name="{{ outputs_download_form.url_query.name }}" value="{{ request.GET.urlencode }}">
1431
<input type="hidden" name="action" value="download">
1532
<footer class="modal-card-foot is-flex is-justify-content-space-between">
1633
<button class="button has-text-weight-semibold" type="reset">Cancel</button>

scanpipe/templates/scanpipe/modals/projects_report_modal.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load humanize %}
12
<div class="modal" id="modal-projects-report">
23
<div class="modal-background"></div>
34
<div class="modal-card">
@@ -7,10 +8,26 @@
78
</header>
89
<form action="{% url 'project_action' %}" method="post" id="report-projects-form">{% csrf_token %}
910
<section class="modal-card-body">
10-
<ul class="mb-3">
11-
{{ report_form.as_ul }}
12-
</ul>
11+
<div class="field">
12+
<label class="label">{{ report_form.model_name.label }}</label>
13+
<div class="control">
14+
{{ report_form.model_name }}
15+
</div>
16+
</div>
17+
{% if page_obj.paginator.num_pages > 1 %}
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>
27+
</div>
28+
{% endif %}
1329
</section>
30+
<input type="hidden" name="{{ report_form.url_query.name }}" value="{{ request.GET.urlencode }}">
1431
<input type="hidden" name="action" value="report">
1532
<footer class="modal-card-foot is-flex is-justify-content-space-between">
1633
<button class="button has-text-weight-semibold" type="reset">Cancel</button>

0 commit comments

Comments
 (0)