Jul 27 - Update code for scheduled tasks 2
This commit is contained in:
@@ -49,7 +49,26 @@
|
||||
{{ form.next_due_date.label(class="form-label fw-semibold") }}
|
||||
{{ form.next_due_date(class="form-control", type="date") }}
|
||||
{% for e in form.next_due_date.errors %}<div class="text-danger small">{{ e }}</div>{% endfor %}
|
||||
<div class="form-text">Snapped forward to the first matching day.</div>
|
||||
<div class="form-text">
|
||||
Snapped forward to the first matching day.
|
||||
Advances automatically after each completed inspection.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── End date (phase44) ──
|
||||
Hidden for one-time schedules, which end by deactivating when
|
||||
completed. syncFrequency() toggles it; the route forces the column
|
||||
to NULL when frequency == 'once', so a stale DOM value cannot
|
||||
survive a frequency change. #}
|
||||
<div class="row" id="end_date_row" hidden>
|
||||
<div class="col-md-6 mb-3">
|
||||
{{ form.end_date.label(class="form-label fw-semibold") }}
|
||||
{{ form.end_date(class="form-control", type="date") }}
|
||||
{% for e in form.end_date.errors %}<div class="text-danger small">{{ e }}</div>{% endfor %}
|
||||
<div class="form-text">
|
||||
Optional. The last date this schedule may run — leave blank to repeat indefinitely.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -201,6 +220,7 @@
|
||||
document.querySelector('[name="frequency"]');
|
||||
var weekly = document.getElementById('weekly_block');
|
||||
var monthly = document.getElementById('monthly_block');
|
||||
var endRow = document.getElementById('end_date_row');
|
||||
if (!freq || !weekly || !monthly) { return; }
|
||||
|
||||
var domRadio = document.getElementById('month_mode_day');
|
||||
@@ -217,6 +237,8 @@
|
||||
function syncFrequency() {
|
||||
weekly.hidden = freq.value !== 'weekly';
|
||||
monthly.hidden = freq.value !== 'monthly';
|
||||
// End date is a recurring-only concept.
|
||||
if (endRow) { endRow.hidden = freq.value === 'once'; }
|
||||
syncMonthMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<th>Inspector</th>
|
||||
<th>Frequency</th>
|
||||
<th>Next Due</th>
|
||||
<th>Ends</th>
|
||||
<th>Status</th>
|
||||
<th class="text-end"></th>
|
||||
</tr>
|
||||
@@ -52,9 +53,22 @@
|
||||
<span class="badge bg-warning text-dark ms-1">Due soon</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-nowrap">
|
||||
{% if s.frequency == 'once' %}
|
||||
<span class="text-muted">—</span>
|
||||
{% elif s.end_date %}
|
||||
{{ s.end_date.strftime('%b %d, %Y') }}
|
||||
{% else %}
|
||||
<span class="text-muted" title="Repeats indefinitely">No end</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{# Three states, not two: "Ended" distinguishes a schedule that ran
|
||||
its course from one a manager switched off. #}
|
||||
{% if s.active %}
|
||||
<span class="badge bg-success">Active</span>
|
||||
{% elif s.is_expired %}
|
||||
<span class="badge bg-dark" title="Passed its end date">Ended</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Inactive</span>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user