Enhance constraint display in rota detail view with default value indication and improved layout

This commit is contained in:
Ross
2025-12-17 16:28:57 +00:00
parent 105b37feae
commit e2c3eecc63
2 changed files with 21 additions and 2 deletions
@@ -42,7 +42,19 @@
{% 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;">
{% if info.typed and info.default is not None %}
{% if info.value == info.default %}
<pre class="has-text-grey" style="white-space:pre-wrap; margin:0;">{{ info.pretty }}</pre>
<span class="tag is-light is-small" title="Using typed default">default</span>
{% else %}
<pre style="white-space:pre-wrap; margin:0;">{{ info.pretty }}</pre>
<div class="help is-size-7" style="margin-top:0.25rem;color:#666;">Default: <code style="white-space:pre-wrap">{{ info.default }}</code></div>
{% endif %}
{% else %}
<pre style="white-space:pre-wrap; margin:0;">{{ info.pretty }}</pre>
{% endif %}
</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">
+8 -1
View File
@@ -176,7 +176,14 @@ def rota_detail(request, rota_id):
desc = available_constraints_rich.get(k, {}).get("description")
except Exception:
desc = None
configured_constraints[k] = {"value": v, "pretty": pretty, "typed": (k in available_constraints_rich), "description": desc}
default_val = available_constraints_rich.get(k, {}).get("default")
configured_constraints[k] = {
"value": v,
"pretty": pretty,
"typed": (k in available_constraints_rich),
"description": desc,
"default": default_val,
}
except Exception:
configured_constraints = {}