Implement alias editing views and templates

This commit is contained in:
2022-08-01 18:47:29 +01:00
parent 5a66236828
commit 6b0851ab6f
8 changed files with 152 additions and 61 deletions

View File

@@ -36,6 +36,16 @@
</tbody>
</table>
</div>
</div>
<div hx-target="#modals-here">
<button hx-get="{% url 'threshold_irc_aliases_edit' %}" class="button is-primary is-fullwidth">
<span class="icon" data-tooltip="Edit">
<i class="fa-solid fa-pencil" aria-hidden="true"></i>
</span>
</button>
</div>
{% endif %}
<div id="modals-here">
</div>
</div>

View File

@@ -0,0 +1,73 @@
{% load index %}
{% load static %}
{% load joinsep %}
<script src="{% static 'modal.js' %}"></script>
<div class="modal is-active is-clipped">
<div class="modal-background"></div>
<div class="modal-content">
<div class="box">
<h4 class="subtitle is-4">Edit aliases</h4>
<form
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'threshold_irc_aliases_edit' %}"
hx-target="#aliases"
hx-swap="outerHTML">
<div class="content" style="max-height: 30em; overflow: auto;">
<div class="table-container">
<table class="table is-fullwidth is-hoverable">
<thead>
<th>num</th>
<th>nick</th>
<th>realname</th>
<th>emails</th>
</thead>
<tbody>
{% for alias in aliases %}
<tr>
<td>
{{ alias.num }}
</td>
<td>
<div class="field">
<input class="input" type="text" name="{{ alias.num }}|nick" value="{{ alias.nick }}">
</div>
</td>
<td>
<div class="field">
<input class="input" type="text" name="{{ alias.num }}|realname" value="{{ alias.realname }}">
</div>
</td>
<td>
<div class="field">
<textarea class="textarea" name="{{ alias.num }}|emails">{{ alias.emails|joinsep:'\n' }}</textarea>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<button
class="button is-primary modal-close-button">
Cancel
</button>
<button class="button is-primary modal-close-button">Submit</button>
</form>
</div>
<button class="modal-close is-large" aria-label="close"></button>
</div>
</div>