Browse Source

Add missing flashed messages

pull/40/head
Dashie der otter 9 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 :
40 40
 
41 41
 ** Design
42 42
 *** Stats.jinja2, DXCC table too large
43
-*** We need to bring back the flash messages, the new Bootstrap-Flask replacement doesn't have it :(
44 43
 *** Required form fields should have a red border or something
45 44
 *** Replace lot of buttons by an icon
46 45
 *** 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 @@
1
+{% macro flashed_messages(messages=None, container=True, transform={
2
+  'critical': 'danger',
3
+  'error': 'danger',
4
+  'info': 'info',
5
+  'warning': 'warning',
6
+  'debug': 'info',
7
+  'notset': 'info',
8
+  'message': 'info',
9
+}, default_category=None, dismissible=False) -%}
10
+{% with messages = messages or get_flashed_messages(with_categories=True) -%}
11
+{% if messages -%} {# don't output anything if there are no messages #}
12
+
13
+{% if container -%}
14
+<!-- begin message block -->
15
+<div class="container flashed-messages">
16
+  <div class="row">
17
+    <div class="col-md-12">
18
+{% endif -%}
19
+
20
+{% for cat, msg in messages %}      <div class="alert alert-{{transform.get(cat.lower(), default_category or cat)}}{% if dismissible %} alert-dismissible{% endif %}" role="alert">
21
+{% if dismissible %}        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{% endif %}
22
+        {{msg}}
23
+      </div>
24
+{%- endfor -%}
25
+
26
+{% if container %}
27
+    </div>
28
+  </div>
29
+</div>
30
+<!-- end message block -->
31
+{% endif -%}
32
+
33
+{% endif -%}
34
+{% endwith -%}
35
+{% endmacro -%}
36
+
37
+
38
+{% macro icon(type=None, extra_classes=[]) -%}
39
+<span{{ ({'class': (['glyphicon', 'glyphicon-' + type] + extra_classes)|join(' ')})|xmlattr}}{{kwargs|xmlattr}}></span>
40
+{%- endmacro %}
41
+
42
+
43
+{% macro form_button(url, content, method='post', class='btn-link') -%}
44
+<form style="display: inline;" action='{{url}}' method='{{method}}'><button class="{{class|safe}}">{{content}}</button></form>
45
+{%- endmacro %}

+ 5
- 1
templates/layout.jinja2 View File

@@ -1,4 +1,4 @@
1
-{% import "bootstrap/utils.html" as butils %}
1
+{% import "bootstrap/flash.html" as bf %}
2 2
 
3 3
 <!DOCTYPE html>
4 4
 <html lang="en">
@@ -156,6 +156,10 @@
156 156
     </nav>
157 157
 
158 158
     <main role="main" class="container">
159
+        <div class="row justify-content-center">
160
+            <div class="col-6">{{ bf.flashed_messages(container=False) }}</div>
161
+        </div>
162
+
159 163
         {% block content %}{% endblock %}
160 164
     </main><!-- /.container -->
161 165
 

Loading…
Cancel
Save