mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-04 10:14:44 +02:00
Toasts now work with turbo
This commit is contained in:
parent
3df6e18a83
commit
390deca544
6 changed files with 57 additions and 41 deletions
23
templates/_toast.html.twig
Normal file
23
templates/_toast.html.twig
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% set flash_title = label|replace({'success': 'flash.success', 'error': 'flash.error'
|
||||
, 'warning': 'flash.warning', 'notice': 'flash.notice', 'info': 'flash.info'}) %}
|
||||
{% set flash_symbol = label|replace({'success': 'fa-check-circle', 'error': 'fa-exclamation-triangle'
|
||||
, 'warning': 'fa-exclamation-circle', 'notice': 'fa-flag', 'info': 'fa-flag'}) %}
|
||||
|
||||
{% set flash_bg = label|replace({'success': 'bg-success text-white',
|
||||
'error': 'bg-danger text-white', 'warning': 'bg-warning text-white',
|
||||
'notice': 'bg-info text-white', 'info': 'bg-light'})%}
|
||||
|
||||
<div class="toast shadow" role="alert" aria-live="assertive" aria-atomic="true" data-delay="5000" {{ stimulus_controller('common/toast') }}>
|
||||
<div class="toast-header {{ flash_bg }}">
|
||||
{# <img src="..." class="rounded mr-2" alt="...">#}
|
||||
<i class="fas fa-fw {{ flash_symbol }} mr-2"></i>
|
||||
<strong class="mr-auto">{{ flash_title|trans }}</strong>
|
||||
<small class="{% if "text-white" in flash_bg %}text-white{% else %}text-muted{% endif %}">{{ "now" | format_datetime("short", "short") }}</small>
|
||||
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="toast-body {{ flash_bg }}">
|
||||
{{ message | trans }}
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue