Skip to content

Commit 5825caa

Browse files
committed
Issue 544: allow show Unknowns in filtered Term listing.
- change filter status ranges, defaults - simplify query to use new filter values
1 parent a4e295d commit 5825caa

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

lute/templates/term/index.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@
3838
<td>Status range</td>
3939
<td>
4040
<select id="filtStatusMin">
41-
<option value=0>(all)</option>
42-
<option value=1>New (1)</option>
43-
<option value=2>New (2)</option>
44-
<option value=3>Learn (3)</option>
45-
<option value=4>Learn (4)</option>
46-
<option value=5>Learned</option>
47-
<option value=99>Well Known</option>
41+
<option value="0" selected>Unknown</option>
42+
<option value="1">New (1)</option>
43+
<option value="2">New (2)</option>
44+
<option value="3">Learn (3)</option>
45+
<option value="4">Learn (4)</option>
46+
<option value="5">Learned</option>
47+
<option value="99">Well Known</option>
4848
</select>
4949
to
5050
<select id="filtStatusMax">
51-
<option value=0>(all)</option>
52-
<option value=1>New (1)</option>
53-
<option value=2>New (2)</option>
54-
<option value=3>Learn (3)</option>
55-
<option value=4>Learn (4)</option>
56-
<option value=5>Learned</option>
57-
<option value=99>Well Known</option>
51+
<option value="0">Unknown</option>
52+
<option value="1">New (1)</option>
53+
<option value="2">New (2)</option>
54+
<option value="3">Learn (3)</option>
55+
<option value="4">Learn (4)</option>
56+
<option value="5">Learned</option>
57+
<option value="99" selected>Well Known</option>
5858
</select>
5959
</td>
6060
</tr>
@@ -351,8 +351,8 @@
351351
$('#filtAgeMin').val(parseInt(store.filtAgeMin));
352352
if ((store.filtAgeMax ?? '') != '')
353353
$('#filtAgeMax').val(parseInt(store.filtAgeMax));
354-
$('#filtStatusMin').val(parseInt(store.filtStatusMin));
355-
$('#filtStatusMax').val(parseInt(store.filtStatusMax));
354+
$('#filtStatusMin').val(parseInt(store.filtStatusMin ?? '1'));
355+
$('#filtStatusMax').val(parseInt(store.filtStatusMax ?? '99'));
356356
$('#filtIncludeIgnored').prop('checked', store.filtIncludeIgnored);
357357
};
358358

@@ -371,8 +371,8 @@
371371
$('#filtParentsOnly').prop('checked', false);
372372
$('#filtAgeMin').val('');
373373
$('#filtAgeMax').val('');
374-
$('#filtStatusMin').val(0);
375-
$('#filtStatusMax').val(0);
374+
$('#filtStatusMin').val(1);
375+
$('#filtStatusMax').val(99);
376376
$('#filtIncludeIgnored').prop('checked', false);
377377
handle_filter_update();
378378
};

lute/term/datatables.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,15 @@ def get_data_tables_list(parameters, session):
7878
if age_max:
7979
wheres.append(f"{sql_age_calc} <= {int(age_max)}")
8080

81-
status_wheres = ["StID not in (0, 98)"]
82-
status_min = int(parameters["filtStatusMin"])
83-
status_max = int(parameters["filtStatusMax"])
84-
if status_min > 0:
85-
status_wheres.append(f"StID >= {status_min}")
86-
if status_max > 0:
87-
status_wheres.append(f"StID <= {status_max}")
88-
status_wheres = " AND ".join(status_wheres)
81+
st_range = ["StID != 98"]
82+
status_min = int(parameters.get("filtStatusMin", "0"))
83+
status_max = int(parameters.get("filtStatusMax", "99"))
84+
st_range.append(f"StID >= {status_min}")
85+
st_range.append(f"StID <= {status_max}")
86+
st_where = " AND ".join(st_range)
8987
if parameters["filtIncludeIgnored"] == "true":
90-
status_wheres = f"({status_wheres} OR StID = 98)"
91-
wheres.append(status_wheres)
88+
st_where = f"({st_where} OR StID = 98)"
89+
wheres.append(st_where)
9290

9391
# Phew.
9492
return DataTablesSqliteQuery.get_data(

0 commit comments

Comments
 (0)