changeset 160:a7ce1660aaaf

Add a checkbox macro
author Benoît Allard <benoit.allard@greenbone.net>
date Tue, 30 Dec 2014 14:10:50 +0100
parents d66532e1909e
children 57b65e7765c1
files farol/templates/document/edit_revision.j2 farol/templates/macros.j2
diffstat 2 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/farol/templates/document/edit_revision.j2	Mon Nov 17 16:51:00 2014 +0100
+++ b/farol/templates/document/edit_revision.j2	Tue Dec 30 14:10:50 2014 +0100
@@ -24,7 +24,7 @@
 -#}
 
 {% extends "base.j2" %}
-{% from "macros.j2" import textinput, textarea, examples %}
+{% from "macros.j2" import textinput, textarea, examples, checkbox %}
 {% block title %}Edit Revision{% endblock %}
 
 {% block content %}
@@ -49,13 +49,7 @@
   {{ examples(['initial public release']) }}
   {% endcall %}
   {% if action == 'Add' %}
-    <div class="form-group">
-      <div class="checkbox">
-        <label>
-          <input name="update_tracking" type="checkbox" checked> Update Tracking Information
-        </label>
-      </div>
-    </div>
+    {{ checkbox('update_tracking', "Update Tracking Information", True) }}
   {% endif %}
   <button class="btn btn-primary" type="submit">{{ action or 'Update' }}</button>
   <a class="btn btn-danger" href="{{ url_for('.view') }}">Cancel</a>
--- a/farol/templates/macros.j2	Mon Nov 17 16:51:00 2014 +0100
+++ b/farol/templates/macros.j2	Tue Dec 30 14:10:50 2014 +0100
@@ -106,6 +106,16 @@
 </div>
 {% endmacro %}
 
+{% macro checkbox(name, label, checked=False) %}
+<div class="form-group">
+  <div class="checkbox">
+    <label>
+      <input name="{{ name }}" type="checkbox"{{ ' checked' if checked }}> {{ label }}
+    </label>
+  </div>
+</div>
+{% endmacro %}
+
 {% macro panel(type="default", heading=None, badge=None, title=0, collapsible=True, extended=False) %}
 {% if not heading %}
   {% set collapsible = False %}

http://farol.wald.intevation.org