Refactor HTML structure and indentation in trainees bulk update template for improved readability

This commit is contained in:
Ross
2025-10-27 14:35:59 +00:00
parent 668007b899
commit be94ed8d0f
@@ -1,20 +1,20 @@
{% extends 'generic/base.html' %}
{% block content %}
<h2>Bulk update trainees (paste spreadsheet text)</h2>
<h2>Bulk update trainees (paste spreadsheet text)</h2>
<p>Paste the spreadsheet rows below. Headings like "Year 1 - Group 1" are used to set the grade (Year N -> STN). Rows should contain "Name <tab or 2+spaces> Supervisor".</p>
<p>Paste the spreadsheet rows below. Headings like "Year 1 - Group 1" are used to set the grade (Year N -> STN). Rows should contain "Name <tab or 2+spaces> Supervisor".</p>
<form method="post">
<form method="post">
{% csrf_token %}
<textarea name="data" rows="18" style="width:100%">{% if request.POST.data %}{{ request.POST.data }}{% endif %}</textarea>
<div style="margin-top:8px">
<button type="submit" name="action" value="preview" class="btn btn-primary">Preview</button>
<button type="submit" name="action" value="apply" class="btn btn-danger" onclick="return confirm('This will apply updates to matched trainee profiles. Are you sure?')">Apply updates</button>
</div>
</form>
</form>
{% if preview %}
{% if preview %}
<h3>Preview ({{ preview|length }} rows)</h3>
<table class="table table-sm">
<thead>
@@ -57,19 +57,19 @@
{% endfor %}
</tbody>
</table>
{% endif %}
{% endif %}
{% if report %}
{% if report %}
<h3>Apply report</h3>
<p>Updated: {{ report.updated }}; Skipped (no user matched): {{ report.skipped }}</p>
{% endif %}
{% endif %}
{% endblock %}
{% block extra_scripts %}
<script>
{% block js %}
<script>
// Called from the HTMX-rendered results fragment to set the manual selection
function setManualUser(rowIndex, id, text) {
function setManualUser(rowIndex, id, text) {
const hiddenInput = document.getElementById('manual_user_' + rowIndex);
const resultsDiv = document.getElementById('user-results-' + rowIndex);
if (hiddenInput) {
@@ -78,9 +78,9 @@ function setManualUser(rowIndex, id, text) {
if (resultsDiv) {
resultsDiv.innerHTML = '<div>Selected: ' + escapeHtml(text) + '</div>';
}
}
}
function escapeHtml(unsafe) {
function escapeHtml(unsafe) {
if (!unsafe) return '';
return String(unsafe)
.replace(/&/g, "&amp;")
@@ -88,6 +88,6 @@ function escapeHtml(unsafe) {
.replace(/>/g, "&gt;")
.replace(/\"/g, "&quot;")
.replace(/'/g, "&#039;");
}
</script>
}
</script>
{% endblock %}