firefly-iii/resources/views/partials/flashes.twig
2017-03-18 11:02:02 +01:00

83 lines
3.2 KiB
Twig

{# SUCCESS MESSAGE (ALWAYS SINGULAR) #}
{% if Session.has('success') %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
</button>
<strong>{{ 'flash_success'|_ }}</strong> {{ session('success') }}
</div>
{% endif %}
{# INFO MESSAGE (CAN BE MULTIPLE) #}
{% if Session.has('info') %}
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
</button>
{# MULTIPLE INFO MESSAGE #}
{% if session('info') is iterable and session('info')|length > 1 %}
<strong>
{{ Lang.choice('firefly.flash_info_multiple', session('info')|length, {count: session('info')|length}) }}:</strong>
<ul class="list-unstyled">
{% for inf in session('info') %}
<li>{{ inf|raw }}</li>
{% endfor %}
</ul>
{% endif %}
{# SET OF MULTIPLE INFO MESSAGES, BUT THERE IS JUST ONE #}
{% if session('info') is iterable and session('info')|length == 1 %}
<strong>{{ 'flash_info'|_ }}:</strong> {{ session('info')[0]|raw }}
{% endif %}
{# SINGLE INFO MESSAGE #}
{% if session('info') is not iterable %}
<strong>{{ 'flash_info'|_ }}:</strong> {{ session('info')|raw }}
{% endif %}
</div>
{% endif %}
{# WARNING MESSAGE (ALWAYS SINGULAR) #}
{% if Session.has('warning') %}
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
</button>
<strong>{{ 'flash_warning'|_ }}</strong> {{ session('warning') }}
</div>
{% endif %}
{# ERROR MESSAGE (CAN BE MULTIPLE) #}
{% if Session.has('error') %}
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
</button>
{# MULTIPLE ERRORS (BAD) #}
{% if session('error') is iterable and session('error')|length > 1 %}
<strong>
{{ Lang.choice('firefly.flash_error_multiple', session('error')|length, {count: session('error')|length}) }}:
</strong>
<ul class="list-unstyled">
{% for err in session('error') %}
<li>{{ err }}</li>
{% endfor %}
</ul>
{% endif %}
{# SET OF MULTIPLE ERRORS, BUT THERE IS JUST ONE #}
{% if session('error') is iterable and session('error')|length == 1 %}
<strong>{{ 'flash_error'|_ }}</strong>
{{ session('error')[0]|raw }}
{% endif %}
{# SINGLE ERROR #}
{% if session('error') is not iterable %}
<strong>{{ 'flash_error'|_ }}</strong> {{ session('error')|raw }}
{% endif %}
</div>
{% endif %}