Files
django-htmx-presenatation/project/main/templates/main/components/inline_table_row.html
2024-05-15 22:15:27 +02:00

44 lines
1.6 KiB
HTML

{% macro inline_table_row(person, is_editing) %}
<tr hx-target="this" hx-swap="outerHTML">
{% if is_editing %}
<td>
<input class="form-control" name="name" value="{{ person.name }}">
</td>
<td>
<input class="form-control" name="address" value="{{ person.address }}">
</td>
<td>
<input class="form-control" name="city" value="{{ person.city }}">
</td>
<td>
<button
class="btn btn-outline-success"
hx-get="{{ url("table-inline-edit-row", pk=person.pk) }}"
hx-vals='{"action": "save"}'
>
<i class="bi bi-check-circle-fill"></i>
</button>
<button
class="btn btn-outline-danger"
hx-get="{{ url("table-inline-edit-row", pk=person.pk) }}"
hx-vals='{"action": "cancel"}'
>
<i class="bi bi-x-circle-fill"></i>
</button>
</td>
{% else %}
<td>{{ person.name }}</td>
<td>{{ person.address }}</td>
<td>{{ person.city }}</td>
<td>
<button
class="btn btn-outline-primary"
hx-get="{{ url("table-inline-edit-row", pk=person.pk) }}"
>
<i class="bi bi-pencil-square"></i>
</button>
</td>
{% endif %}
</tr>
{% endmacro %}