File tree Expand file tree Collapse file tree 6 files changed +34
-7
lines changed Expand file tree Collapse file tree 6 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -1236,3 +1236,7 @@ h6 {
1236
1236
# order_by_label {
1237
1237
margin-bottom : 1rem ;
1238
1238
}
1239
+
1240
+ .clickable-table-cell : hover {
1241
+ cursor : pointer;
1242
+ }
Original file line number Diff line number Diff line change 2
2
3
3
import django_filters
4
4
from django .db .models import Q
5
- from django_filters .filters import CharFilter , OrderingFilter
5
+ from django_filters .filters import (
6
+ BaseInFilter ,
7
+ CharFilter ,
8
+ NumberFilter ,
9
+ OrderingFilter ,
10
+ )
11
+ from django_filters .widgets import QueryArrayWidget
6
12
7
13
from signals .models import Signal
8
14
9
15
16
+ class NumberInFilter (BaseInFilter , NumberFilter ):
17
+ pass
18
+
19
+
10
20
class SignalFilter (django_filters .FilterSet ):
11
21
"""
12
22
FilterSet for the Signal model.
13
23
"""
14
24
25
+ id = NumberInFilter (field_name = 'id' , lookup_expr = 'in' , widget = QueryArrayWidget )
15
26
search = CharFilter (method = 'filter_search' )
16
27
order_by = OrderingFilter (
17
28
fields = (
@@ -24,6 +35,7 @@ class SignalFilter(django_filters.FilterSet):
24
35
class Meta :
25
36
model = Signal
26
37
fields : list [str ] = [
38
+ 'id' ,
27
39
'search' ,
28
40
'pathogen' ,
29
41
'active' ,
Original file line number Diff line number Diff line change 10
10
ActiveChoices
11
11
)
12
12
13
- MULTI_SELECT_TOOLTIP_MESSAGE = _ ('Hold down “Control”, or “Command” on a Mac, to select more than one.' )
14
-
15
13
16
14
class SignalFilterForm (forms .ModelForm ):
17
15
"""
18
16
A form for filtering signals.
19
17
"""
18
+ id = forms .ModelMultipleChoiceField (queryset = Signal .objects .all (), widget = forms .MultipleHiddenInput )
20
19
order_by = forms .ChoiceField (choices = [
21
20
('' , '---------' ),
22
21
('name' , 'Name' ),
@@ -35,6 +34,7 @@ class SignalFilterForm(forms.ModelForm):
35
34
class Meta :
36
35
model = Signal
37
36
fields : list [str ] = [
37
+ 'id' ,
38
38
'order_by' ,
39
39
'search' ,
40
40
'pathogen' ,
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ def get_queryset(self) -> Any:
36
36
37
37
def get_url_params (self ):
38
38
url_params_dict = {
39
+ "id" : self .request .GET .get ("id" ),
39
40
"search" : self .request .GET .get ("search" ),
40
41
"pathogen" : int (self .request .GET .get ("pathogen" ))
41
42
if self .request .GET .get ("pathogen" )
Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ <h5 class="modal-title">Time Label</h5>
241
241
</ div >
242
242
< div class ="card-body ">
243
243
< div class ="d-grid gap-2 mt-3 ">
244
- < button type ="submit " class ="btn btn-primary "> {% trans 'Apply Filters' %}</ button >
244
+ < button id =" filter-submit " type ="submit " class ="btn btn-primary "> {% trans 'Apply Filters' %}</ button >
245
245
</ div >
246
246
</ div >
247
247
</ div >
@@ -264,6 +264,7 @@ <h5 class="modal-title">Time Label</h5>
264
264
< table class ="table table-borderless table-hover ">
265
265
< thead >
266
266
< tr >
267
+ < th scope ="col "> </ th >
267
268
< th scope ="col "> Name</ th >
268
269
< th scope ="col "> Data Source</ th >
269
270
< th scope ="col "> Description</ th >
@@ -282,9 +283,11 @@ <h5 class="modal-title">Time Label</h5>
282
283
</ div >
283
284
</ div >
284
285
</ form >
286
+
285
287
< script >
286
288
document . getElementById ( 'id_order_by' ) . addEventListener ( 'change' , function ( ) {
287
289
document . getElementById ( 'filters-form' ) . submit ( ) ;
288
290
} ) ;
289
291
</ script >
292
+
290
293
{% endblock %}
Original file line number Diff line number Diff line change
1
+ {% load crispy_forms_tags %}
2
+
1
3
{% for signal in signals %}
2
4
{% if forloop.last %}
3
5
< tr hx-trigger ="revealed " class ="clickable-table-row " hx-get ="{% url 'signals' %}?page={{ page_obj.number|add:1 }}{{ url_params_str }} "
4
- hx-swap ="afterend " onClick =" location.href='{% url 'signal' pk=signal.id %}'; " >
6
+ hx-swap ="afterend ">
5
7
{% else %}
6
- < tr classs ="clickable-table-row " onClick =" location.href='{% url 'signal' pk=signal.id %}'; " >
8
+ < tr classs ="clickable-table-row ">
7
9
{% endif %}
8
- < td > {{ signal.display_name }}</ td >
10
+ < td >
11
+ < input type ="checkbox " name ="id " value ="{{ signal.id }} ">
12
+ {{ form.id|as_crispy_field }}
13
+ </ td >
14
+ < td onClick ="location.href='{% url 'signal' pk=signal.id %}'; " class ="clickable-table-cell "> {{ signal.display_name }}</ td >
9
15
< td > {{ signal.source }}</ td >
10
16
< td > {{ signal.description }}</ td >
11
17
< td >
28
34
{% endif %}
29
35
</ td >
30
36
</ tr >
37
+
31
38
{% endfor %}
You can’t perform that action at this time.
0 commit comments