Factorize delete modals
This commit is contained in:
parent
913b7e7c98
commit
b8d417da9b
1 changed files with 44 additions and 54 deletions
|
|
@ -5,6 +5,40 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{% endblock head %}
|
{% endblock head %}
|
||||||
|
{% macro delete_modal(modal_id, confirm_text, action, payload) %}
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-danger"
|
||||||
|
data-bs-toggle="modal"
|
||||||
|
data-bs-target="#{{ modal_id }}">Delete</button>
|
||||||
|
<div class="modal fade"
|
||||||
|
tabindex="-1"
|
||||||
|
id="{{ modal_id }}"
|
||||||
|
aria-labelledby="{{ modal_id }}Label">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h1 class="modal-title fs-5" id="{{ modal_id }}Label">{{ confirm_text }}</h1>
|
||||||
|
<button type="button"
|
||||||
|
class="btn-close"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<form action="{{ action }}" method="post">
|
||||||
|
{% set payload_len = payload | length %}
|
||||||
|
{% for idx in range(end=payload_len / 2) %}
|
||||||
|
<input type="hidden"
|
||||||
|
name="{{ payload | nth(n=idx*2) }}"
|
||||||
|
value="{{ payload | nth(n=idx*2 + 1) }}" />
|
||||||
|
{% endfor %}
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-danger">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro delete_modal %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="title is-1">Mail management</h1>
|
<h1 class="title is-1">Mail management</h1>
|
||||||
|
|
@ -14,33 +48,11 @@
|
||||||
{% for mail in mails %}
|
{% for mail in mails %}
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
{{ mail.mail }}
|
{{ mail.mail }}
|
||||||
<button type="button"
|
{{ self::delete_modal(modal_id="mailDelete" ~ loop.index,
|
||||||
class="btn btn-danger"
|
confirm_text="Delete mail '" ~ mail.mail ~ "'",
|
||||||
data-bs-toggle="modal"
|
action="/mail/delete",
|
||||||
data-bs-target="#mailDelete{{ loop.index }}">Delete</button>
|
payload=["mail", mail.mail])
|
||||||
<div class="modal fade"
|
}}
|
||||||
tabindex="-1"
|
|
||||||
id="mailDelete{{ loop.index }}"
|
|
||||||
aria-labelledby="mailDeleteLabel{{ loop.index }}">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h1 class="modal-title fs-5" id="mailDeleteLabel{{ loop.index }}">Delete mail '{{ mail.mail }}'</h1>
|
|
||||||
<button type="button"
|
|
||||||
class="btn-close"
|
|
||||||
data-bs-dismiss="modal"
|
|
||||||
aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<form action="/mail/delete" method="post">
|
|
||||||
<input type="hidden" name="mail" value="{{ mail.mail }}" />
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
||||||
<button type="submit" class="btn btn-danger">Delete</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -87,33 +99,11 @@
|
||||||
<li class="list-group-item d-flex flex-column">
|
<li class="list-group-item d-flex flex-column">
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
{{ alias.mail }}
|
{{ alias.mail }}
|
||||||
<button type="button"
|
{{ self::delete_modal(modal_id="aliasDelete" ~ loop.index,
|
||||||
class="btn btn-danger"
|
confirm_text="Delete alias '" ~ alias.mail ~ "'",
|
||||||
data-bs-toggle="modal"
|
action="/alias/delete",
|
||||||
data-bs-target="#aliasDelete{{ loop.index }}">Delete</button>
|
payload=["mail", alias.mail])
|
||||||
<div class="modal fade"
|
}}
|
||||||
tabindex="-1"
|
|
||||||
id="aliasDelete{{ loop.index }}"
|
|
||||||
aria-labelledby="aliasDeleteLabel{{ loop.index }}">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h1 class="modal-title fs-5" id="aliasDeleteLabel{{ loop.index }}">Delete alias '{{ alias.mail }}'</h1>
|
|
||||||
<button type="button"
|
|
||||||
class="btn-close"
|
|
||||||
data-bs-dismiss="modal"
|
|
||||||
aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<form action="/alias/delete" method="post">
|
|
||||||
<input type="hidden" name="mail" value="{{ alias.mail }}" />
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
||||||
<button type="submit" class="btn btn-danger">Delete</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-group mt-1">
|
<ul class="list-group mt-1">
|
||||||
{% set alias_idx = loop.index %}
|
{% set alias_idx = loop.index %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue