This commit is contained in:
Ross
2025-12-14 21:57:16 +00:00
parent f0ebc0d01a
commit 55df9da8cb
@@ -1,144 +1,98 @@
{% extends 'base.html' %} {% extends 'base.html' %}
<html> {% block head %}
<head>
<title>Rota: {{ rota.name }}</title>
<link href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css" rel="stylesheet">
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
{% include 'rota/partials/flatpickr_includes.html' %} {% include 'rota/partials/flatpickr_includes.html' %}
</head> {% endblock %}
<body> {% block content %}
<section class="section"> <section class="section">
<div class="container"> <div class="container">
<h1 class="title">{{ rota.name }}</h1> <h1 class="title">{{ rota.name }}</h1>
<p> <p><a class="button is-small" href="{% url 'rota:rota_edit' rota.id %}">Edit rota</a></p>
<a class="button is-small" href="{% url 'rota:rota_edit' rota.id %}">Edit rota</a> <p class="subtitle">{{ rota.description }}</p>
</p>
<p>Period: {{ rota.start_date }} → {{ rota.end_date }}</p> <p>Period: {{ rota.start_date }} → {{ rota.end_date }}</p>
<div class="mb-4"> <div class="mb-4">
<p> <p><button class="button is-link" hx-get="{% url 'rota:worker_add' %}?rota_id={{ rota.id }}" hx-target="#modal" hx-swap="innerHTML">Add worker</button></p>
<button class="button is-link" hx-get="{% url 'rota:worker_add' %}?rota_id={{ rota.id }}" hx-target="#modal" hx-swap="innerHTML">Add worker</button> {% include 'rota/partials/worker_list.html' %}
</p> </div>
{% block head %}
<link href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css" rel="stylesheet">
{% include 'rota/partials/flatpickr_includes.html' %}
{% endblock %}
{% block content %}
<section class="section">
<div class="container">
<h1 class="title">{{ rota.name }}</h1>
<p>
<a class="button is-small" href="{% url 'rota:rota_edit' rota.id %}">Edit rota</a>
</p>
<p class="subtitle">{{ rota.description }}</p>
<p>Period: {{ rota.start_date }} → {{ rota.end_date }}</p>
<div class="mb-4"> <div class="mb-4">
<p> <h2 class="subtitle">Historic runs</h2>
<button class="button is-link" hx-get="{% url 'rota:worker_add' %}?rota_id={{ rota.id }}" hx-target="#modal" hx-swap="innerHTML">Add worker</button> <div class="box">
</p> <div style="margin-bottom:0.5em;">
{% include 'rota/partials/worker_list.html' %} <form method="post" action="{% url 'rota:rota_runs_clear' rota.id %}" style="display:inline" onsubmit="return confirm('Delete all historic runs for this rota? This cannot be undone.')">
</div> {% csrf_token %}
<button class="button is-danger is-light is-small" type="submit">Clear all runs</button>
</form>
</div>
<ul>
{% for run in rota.runs.all %}
<li>
<a href="{% url 'rota:rota_run_detail' run.id %}">Run {{ run.id }}</a> — {{ run.get_status_display }}
{% if run.finished_at %} — finished {{ run.finished_at }}{% endif %}
<span class="ml-2"><a class="button is-small is-light" href="{% url 'rota:rota_run_export_html' run.id %}" target="_blank">Export</a></span>
</li>
{% empty %}
<li>No previous runs</li>
{% endfor %}
</ul>
</div>
</div>
<div class="mb-4"> <div class="mb-4">
<h2 class="subtitle">Historic runs</h2> <h2 class="subtitle">Constraint options</h2>
<div class="box"> <div class="box">
<div style="margin-bottom:0.5em;"> <p class="help">Configure typed rota constraint options. Click Edit to open the form showing typed fields and descriptions.</p>
<form method="post" action="{% url 'rota:rota_runs_clear' rota.id %}" style="display:inline" onsubmit="return confirm('Delete all historic runs for this rota? This cannot be undone.')"> <p><button class="button is-link" hx-get="{% url 'rota:rota_options' rota.id %}" hx-target="#modal" hx-swap="innerHTML">Edit constraint options</button></p>
{% csrf_token %} <hr />
<button class="button is-danger is-light is-small" type="submit">Clear all runs</button> <h3 class="subtitle is-6">Configured constraint values</h3>
</form> <div style="max-height:200px; overflow:auto; margin-bottom:0.75em;">
</div> {% if configured_constraints %}
<ul> <table class="table is-fullwidth is-striped is-narrow">
{% for run in rota.runs.all %} <thead><tr><th>Key</th><th>Value</th><th></th></tr></thead>
<li> <tbody>
<a href="{% url 'rota:rota_run_detail' run.id %}">Run {{ run.id }}</a> {% for key, info in configured_constraints.items %}
{{ run.get_status_display }} <tr id="constraint-row-{{ key }}">
{% if run.finished_at %} — finished {{ run.finished_at }}{% endif %} <td style="vertical-align:middle;"><code title="{{ info.description|default:'' }}">{{ key }}</code></td>
<span class="ml-2"> <td style="vertical-align:middle;"><pre style="white-space:pre-wrap; margin:0;">{{ info.pretty }}</pre></td>
<a class="button is-small is-light" href="{% url 'rota:rota_run_export_html' run.id %}" target="_blank">Export</a> <td style="vertical-align:middle;">
</span> <a href="javascript:void(0)" class="button is-small is-light" role="button" hx-get="{% url 'rota:rota_option_edit' rota.id %}?key={{ key }}" hx-target="#modal" hx-swap="innerHTML">Edit</a>
</li> <form method="post" hx-post="{% url 'rota:rota_option_delete' rota.id %}" hx-target="#constraint-row-{{ key }}" hx-swap="outerHTML" style="display:inline">
{% empty %} {% csrf_token %}
<li>No previous runs</li> <input type="hidden" name="key" value="{{ key }}" />
{% endfor %} <input type="hidden" name="inline" value="1" />
</ul> <button class="button is-small is-danger is-light" type="submit">Delete</button>
</div> </form>
</div> </td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="help">No typed constraint options have been configured for this rota.</p>
{% endif %}
</div>
</div>
</div>
<div class="mb-4"> <form method="post">
<h2 class="subtitle">Constraint options</h2> {% csrf_token %}
<div class="box"> <div class="field is-grouped is-grouped-multiline">
<p class="help">Configure typed rota constraint options. Click Edit to open the form showing typed fields and descriptions.</p> <div class="control"><label class="checkbox"><input type="checkbox" name="generate_builder" value="1"> Generate HTML export</label></div>
<p> <div class="control"><label class="checkbox"><input type="checkbox" name="builder_solve" value="1"> Solve when exporting (may be slow)</label></div>
<button class="button is-link" hx-get="{% url 'rota:rota_options' rota.id %}" hx-target="#modal" hx-swap="innerHTML">Edit constraint options</button> <div class="control"><button class="button is-primary" type="submit">Run scheduler (background)</button></div>
</p> </div>
<hr /> </form>
<h3 class="subtitle is-6">Configured constraint values</h3>
<div style="max-height:200px; overflow:auto; margin-bottom:0.75em;">
{% if configured_constraints %}
<table class="table is-fullwidth is-striped is-narrow">
<thead>
<tr><th>Key</th><th>Value</th><th></th></tr>
</thead>
<tbody>
{% for key, info in configured_constraints.items %}
<tr id="constraint-row-{{ key }}">
<td style="vertical-align:middle;"><code title="{{ info.description|default:'' }}">{{ key }}</code></td>
<td style="vertical-align:middle;"><pre style="white-space:pre-wrap; margin:0;">{{ info.pretty }}</pre></td>
<td style="vertical-align:middle;">
<a href="javascript:void(0)" class="button is-small is-light" role="button" hx-get="{% url 'rota:rota_option_edit' rota.id %}?key={{ key }}" hx-target="#modal" hx-swap="innerHTML">Edit</a>
<form method="post" hx-post="{% url 'rota:rota_option_delete' rota.id %}" hx-target="#constraint-row-{{ key }}" hx-swap="outerHTML" style="display:inline">
{% csrf_token %}
<input type="hidden" name="key" value="{{ key }}" />
<input type="hidden" name="inline" value="1" />
<button class="button is-small is-danger is-light" type="submit">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="help">No typed constraint options have been configured for this rota.</p>
{% endif %}
</div>
</div> <hr />
</div>
<form method="post"> <div>
{% csrf_token %} <h2 class="subtitle">Edit shifts</h2>
<div class="field is-grouped is-grouped-multiline"> <p><button class="button is-link" hx-get="{% url 'rota:shift_add' rota.id %}" hx-target="#shift-form" hx-swap="innerHTML">Add shift</button></p>
<div class="control"> <div id="shift-form">{# Load form via HTMX when user clicks 'Add shift' - initial empty state #}</div>
<label class="checkbox"> {% include 'rota/partials/shift_list.html' %}
<input type="checkbox" name="generate_builder" value="1"> Generate HTML export </div>
</label>
</div>
<div class="control">
<label class="checkbox">
<input type="checkbox" name="builder_solve" value="1"> Solve when exporting (may be slow)
</label>
</div>
<div class="control">
<button class="button is-primary" type="submit">Run scheduler (background)</button>
</div>
</div>
</form>
<hr> </div>
</section>
<div> {% endblock %}
<h2 class="subtitle">Edit shifts</h2>
<p>
<button class="button is-link" hx-get="{% url 'rota:shift_add' rota.id %}" hx-target="#shift-form" hx-swap="innerHTML">Add shift</button>
</p>
<div id="shift-form">
{# Load form via HTMX when user clicks 'Add shift' - initial empty state #}
</div>
{% include 'rota/partials/shift_list.html' %}
</div>
</div>
{% endblock %}