feat: pay-type dropdown on /workers/ filter row
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d949a01550
commit
fb8952a323
@ -33,7 +33,7 @@
|
||||
<div class="card mb-3">
|
||||
<div class="card-body p-3">
|
||||
<form method="get" class="row g-2 align-items-end">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small fw-semibold mb-1">Search</label>
|
||||
<input type="text" name="q" value="{{ q }}" class="form-control"
|
||||
placeholder="Name, ID number, or phone...">
|
||||
@ -48,7 +48,7 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small fw-semibold mb-1">Status</label>
|
||||
<select name="status" class="form-select">
|
||||
<option value="active" {% if status == 'active' %}selected{% endif %}>Active only</option>
|
||||
@ -56,6 +56,17 @@
|
||||
<option value="all" {% if status == 'all' %}selected{% endif %}>All workers</option>
|
||||
</select>
|
||||
</div>
|
||||
{# === Pay-type filter === #}
|
||||
{# DB values are 'daily'/'fixed' (Path-A); label is friendly. #}
|
||||
{# Empty value = 'All pay types' (unchanged default view). #}
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small fw-semibold mb-1">Pay type</label>
|
||||
<select name="pay_type" class="form-select">
|
||||
<option value="" {% if not pay_type_filter %}selected{% endif %}>All pay types</option>
|
||||
<option value="daily" {% if pay_type_filter == 'daily' %}selected{% endif %}>Daily workers</option>
|
||||
<option value="fixed" {% if pay_type_filter == 'fixed' %}selected{% endif %}>Managers (Salaried)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<i class="fas fa-search me-1"></i>Filter
|
||||
@ -127,7 +138,7 @@
|
||||
{% else %}
|
||||
<p class="text-center py-5 mb-0" style="color: var(--text-secondary);">
|
||||
No workers{% if q %} match "<strong>{{ q }}</strong>"{% endif %}.
|
||||
{% if q or status != 'active' or team_filter %}<br><a href="{% url 'worker_list' %}">Clear filters</a>{% endif %}
|
||||
{% if q or status != 'active' or team_filter or pay_type_filter %}<br><a href="{% url 'worker_list' %}">Clear filters</a>{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@ -3294,6 +3294,18 @@ class WorkerListPayTypeFilterTests(TestCase):
|
||||
self.assertIn('Mary Manager', names)
|
||||
self.assertEqual(resp.context['pay_type_filter'], 'banana')
|
||||
|
||||
def test_list_renders_pay_type_dropdown_with_selection(self):
|
||||
# The filter row must render a pay-type <select> and mark the
|
||||
# active option selected so the dropdown reflects the URL.
|
||||
resp = self.client.get('/workers/?pay_type=fixed')
|
||||
self.assertContains(resp, 'name="pay_type"')
|
||||
self.assertContains(resp, 'Managers (Salaried)')
|
||||
# The 'fixed' option must be the selected one.
|
||||
self.assertContains(
|
||||
resp, '<option value="fixed" selected>Managers (Salaried)</option>',
|
||||
html=False,
|
||||
)
|
||||
|
||||
|
||||
class WorkHistoryTeamFilterTests(TestCase):
|
||||
"""The /history/ page accepts ?team=<id> to narrow to logs tagged
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user