Skip to content

Commit 8d48d00

Browse files
Add ability to select all fields
1 parent c947c3e commit 8d48d00

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/country_workspace/workspaces/admin/hh_ind.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from admin_extra_buttons.decorators import button
44
from adminfilters.mixin import AdminAutoCompleteSearchMixin
55
from concurrency.utils import fqn
6+
from django import forms
67
from django.contrib import messages
78
from django.contrib.admin.utils import unquote
89
from django.core.exceptions import PermissionDenied
@@ -66,6 +67,15 @@ class BeneficiaryBaseAdmin(AdminAutoCompleteSearchMixin, SelectedProgramMixin, W
6667
list_per_page = 20
6768
object_history_template = "workspace/individual/object_history.html"
6869

70+
@property
71+
def media(self) -> forms.Media:
72+
return super().media + forms.Media(
73+
js=[
74+
"workspace/js/select-all.js",
75+
],
76+
css={},
77+
)
78+
6979
@property
7080
def title_group(self) -> str | None:
7181
return self._get_title_label("group_label")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$(function () {
2+
$("#select-all").change(function () {
3+
$(this).parent("form").children("input:checkbox").not(this).prop('checked', this.checked);
4+
})
5+
})

src/country_workspace/workspaces/templates/workspace/actions/bulk_update_export.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<input type="submit" value="{% translate 'Export' %}" class="default" name="_export">
99
</div>
1010
{% csrf_token %}
11+
<label for="select-all">
12+
<input type="checkbox" id="select-all">Select all
13+
</label>
1114
<table>
1215
{{ form.as_table }}
1316
</table>

0 commit comments

Comments
 (0)