Files
physicalCombinatorics/src/physcom_web/templates/domains/_metrics_table.html

73 lines
3.0 KiB
HTML

<table id="metrics-table">
<thead>
<tr>
<th>Metric</th>
<th>Unit</th>
<th>Weight</th>
<th>Norm Min</th>
<th>Norm Max</th>
<th>Direction</th>
<th></th>
</tr>
</thead>
<tbody>
{% for mb in domain.metric_bounds %}
<tr>
<td>{{ mb.metric_name }}</td>
<td>{{ mb.unit or '—' }}</td>
<td>{{ mb.weight }}</td>
<td>{{ mb.norm_min|si }}</td>
<td>{{ mb.norm_max|si }}</td>
<td>{{ '↓ lower' if mb.lower_is_better else '↑ higher' }}</td>
<td class="actions">
<button class="btn btn-sm"
onclick="this.closest('tr').nextElementSibling.style.display='table-row'; this.closest('tr').style.display='none'">
Edit
</button>
<form method="post"
hx-post="{{ url_for('domains.metric_delete', domain_id=domain.id, metric_id=mb.metric_id) }}"
hx-target="#metrics-section" hx-swap="innerHTML"
class="inline-form">
<button type="submit" class="btn btn-sm btn-danger">Del</button>
</form>
</td>
</tr>
<tr class="edit-row" style="display:none">
<form method="post"
hx-post="{{ url_for('domains.metric_edit', domain_id=domain.id, metric_id=mb.metric_id) }}"
hx-target="#metrics-section" hx-swap="innerHTML">
<td>{{ mb.metric_name }}</td>
<td><input name="unit" value="{{ mb.unit or '' }}"></td>
<td><input name="weight" type="number" step="any" value="{{ mb.weight }}" required></td>
<td><input name="norm_min" type="number" step="any" value="{{ mb.norm_min }}" required></td>
<td><input name="norm_max" type="number" step="any" value="{{ mb.norm_max }}" required></td>
<td><label><input type="checkbox" name="lower_is_better" value="1" {{ 'checked' if mb.lower_is_better }}> lower is better</label></td>
<td>
<button type="submit" class="btn btn-sm btn-primary">Save</button>
<button type="button" class="btn btn-sm"
onclick="this.closest('tr').style.display='none'; this.closest('tr').previousElementSibling.style.display=''">
Cancel
</button>
</td>
</form>
</tr>
{% endfor %}
</tbody>
</table>
<h3>Add Metric</h3>
<form method="post"
hx-post="{{ url_for('domains.metric_add', domain_id=domain.id) }}"
hx-target="#metrics-section" hx-swap="innerHTML"
class="dep-add-form">
<div class="form-row">
<input name="metric_name" placeholder="metric name" required>
<input name="unit" placeholder="unit">
<input name="weight" type="number" step="any" placeholder="weight" value="1.0" required>
<input name="norm_min" type="number" step="any" placeholder="norm min" value="0.0" required>
<input name="norm_max" type="number" step="any" placeholder="norm max" value="1.0" required>
<label><input type="checkbox" name="lower_is_better" value="1"> lower is better</label>
<button type="submit" class="btn btn-primary">Add</button>
</div>
</form>