Skip to content

Commit 5d12302

Browse files
committed
Merge branch 'issue_544_include_unknowns_in_term_listing' into develop
2 parents e76803f + 0265ddb commit 5d12302

File tree

3 files changed

+33
-35
lines changed

3 files changed

+33
-35
lines changed

lute/templates/term/index.html

Lines changed: 19 additions & 23 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>
@@ -344,18 +344,15 @@
344344
store = JSON.parse(fs);
345345
$('#filterControls').css('display', store.filtDisplay);
346346

347-
if (store.filtDisplay == 'none')
348-
return;
349-
350347
$('#showHideFilters').prop('src', "{{ url_for('static', filename='icn/minus-button.png') }}");
351348
$('#filtLanguage').val(parseInt(store.filtLanguage ?? '0'));
352349
$('#filtParentsOnly').prop('checked', store.filtParentsOnly ?? false);
353350
if ((store.filtAgeMin ?? '') != '')
354351
$('#filtAgeMin').val(parseInt(store.filtAgeMin));
355352
if ((store.filtAgeMax ?? '') != '')
356353
$('#filtAgeMax').val(parseInt(store.filtAgeMax));
357-
$('#filtStatusMin').val(parseInt(store.filtStatusMin));
358-
$('#filtStatusMax').val(parseInt(store.filtStatusMax));
354+
$('#filtStatusMin').val(parseInt(store.filtStatusMin ?? '1'));
355+
$('#filtStatusMax').val(parseInt(store.filtStatusMax ?? '99'));
359356
$('#filtIncludeIgnored').prop('checked', store.filtIncludeIgnored);
360357
};
361358

@@ -364,8 +361,7 @@
364361
const is_hidden = (fc.css('display') == 'none');
365362
const new_src = is_hidden ? "{{ url_for('static', filename='icn/minus-button.png') }}" : "{{ url_for('static', filename='icn/plus-button.png') }}";
366363
$('#showHideFilters').prop('src', new_src);
367-
if (! is_hidden)
368-
handle_clear_filters();
364+
handle_clear_filters();
369365
fc.css('display', is_hidden ? 'block' : 'none');
370366
handle_filter_update();
371367
};
@@ -375,8 +371,8 @@
375371
$('#filtParentsOnly').prop('checked', false);
376372
$('#filtAgeMin').val('');
377373
$('#filtAgeMax').val('');
378-
$('#filtStatusMin').val(0);
379-
$('#filtStatusMax').val(0);
374+
$('#filtStatusMin').val(1);
375+
$('#filtStatusMax').val(99);
380376
$('#filtIncludeIgnored').prop('checked', false);
381377
handle_filter_update();
382378
};

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(

tests/acceptance/lute_test_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ def get_term_table_content(self):
259259
self.visit("/")
260260
self.browser.find_by_css("#menu_terms").mouse_over()
261261
self.browser.find_by_id("term_index").first.click()
262-
css = "#termtable tbody tr"
262+
263+
# clear any filters!
264+
self.browser.find_by_id("showHideFilters").first.click()
263265

264266
# The last column of the table is the "date added", but that's
265267
# a hassle to check, so ignore it.
@@ -271,8 +273,10 @@ def _to_string(row):
271273
return ret
272274
return "; ".join(rowtext[:-1]).strip()
273275

276+
css = "#termtable tbody tr"
274277
rows = list(self.browser.find_by_css(css))
275-
return "\n".join([_to_string(row) for row in rows])
278+
rowstring = [_to_string(row) for row in rows]
279+
return "\n".join(rowstring)
276280

277281
################################3
278282
# Reading/rendering

0 commit comments

Comments
 (0)