Browse Source

Add missing flashed messages

pull/40/head
Dashie der otter 11 months ago
parent
commit
976a7573c2
Signed by: Dashie <dashie@sigpipe.me> GPG Key ID: C2D57B325840B755
3 changed files with 50 additions and 2 deletions
  1. 0
    1
      TODO.org
  2. 45
    0
      templates/bootstrap/flash.html
  3. 5
    1
      templates/layout.jinja2

+ 0
- 1
TODO.org View File

@@ -40,7 +40,6 @@ eQSL.cc :

** Design
*** Stats.jinja2, DXCC table too large
*** We need to bring back the flash messages, the new Bootstrap-Flask replacement doesn't have it :(
*** Required form fields should have a red border or something
*** Replace lot of buttons by an icon
*** How to move the submit button on bottom of the stack ? (using extended wtf flask_security register form)

+ 45
- 0
templates/bootstrap/flash.html View File

@@ -0,0 +1,45 @@
{% macro flashed_messages(messages=None, container=True, transform={
'critical': 'danger',
'error': 'danger',
'info': 'info',
'warning': 'warning',
'debug': 'info',
'notset': 'info',
'message': 'info',
}, default_category=None, dismissible=False) -%}
{% with messages = messages or get_flashed_messages(with_categories=True) -%}
{% if messages -%} {# don't output anything if there are no messages #}

{% if container -%}
<!-- begin message block -->
<div class="container flashed-messages">
<div class="row">
<div class="col-md-12">
{% endif -%}

{% for cat, msg in messages %} <div class="alert alert-{{transform.get(cat.lower(), default_category or cat)}}{% if dismissible %} alert-dismissible{% endif %}" role="alert">
{% if dismissible %} <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{% endif %}
{{msg}}
</div>
{%- endfor -%}

{% if container %}
</div>
</div>
</div>
<!-- end message block -->
{% endif -%}

{% endif -%}
{% endwith -%}
{% endmacro -%}


{% macro icon(type=None, extra_classes=[]) -%}
<span{{ ({'class': (['glyphicon', 'glyphicon-' + type] + extra_classes)|join(' ')})|xmlattr}}{{kwargs|xmlattr}}></span>
{%- endmacro %}


{% macro form_button(url, content, method='post', class='btn-link') -%}
<form style="display: inline;" action='{{url}}' method='{{method}}'><button class="{{class|safe}}">{{content}}</button></form>
{%- endmacro %}

+ 5
- 1
templates/layout.jinja2 View File

@@ -1,4 +1,4 @@
{% import "bootstrap/utils.html" as butils %}
{% import "bootstrap/flash.html" as bf %}

<!DOCTYPE html>
<html lang="en">
@@ -156,6 +156,10 @@
</nav>

<main role="main" class="container">
<div class="row justify-content-center">
<div class="col-6">{{ bf.flashed_messages(container=False) }}</div>
</div>

{% block content %}{% endblock %}
</main><!-- /.container -->


Loading…
Cancel
Save