Mercurial > farol > farol
comparison farol/templates/macros.j2 @ 34:22d89f53e34c
Add macro to display a description for the input fields
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Mon, 06 Oct 2014 14:09:57 +0200 |
parents | 9b0fb5ca7eff |
children | 537d25b1593c |
comparison
equal
deleted
inserted
replaced
33:752b8bfe0baf | 34:22d89f53e34c |
---|---|
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | 23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
24 -#} | 24 -#} |
25 | 25 |
26 {% macro textinput(name, label, placeholder="", value=None, required=False, type="text", extras={}, help='') %} | 26 {% macro textinput(name, label, placeholder="", value=None, required=False, type="text", extras={}, help='') %} |
27 <div class="form-group"> | 27 <div class="form-group"> |
28 <label for="{{ name }}">{{ label }}:{% if required %}<span class="text-danger"> *</span>{% endif %}</label> | 28 {% if caller %} |
29 {% set content=caller () %} | |
30 {% call modal(name + "_modal", label) %} | |
31 {{ content }} | |
32 {% endcall %} | |
33 {% endif %} | |
34 <label for="{{ name }}">{{ label }}: | |
35 {% if required %}<span class="text-danger"> *</span>{% endif %} | |
36 {% if caller %}<a href="#{{ name }}_modal" data-toggle="modal">?</a>{% endif %} | |
37 </label> | |
29 {% if type == "datetime" %}<div class="input-group">{% endif %} | 38 {% if type == "datetime" %}<div class="input-group">{% endif %} |
30 <input | 39 <input |
31 type="{{ type }}" | 40 type="{{ type }}" |
32 {%- if type != 'file' %} class="form-control"{% endif %} | 41 {%- if type != 'file' %} class="form-control"{% endif %} |
33 id="{{ name }}" name="{{ name }}" | 42 id="{{ name }}" name="{{ name }}" |
34 placeholder="{{ placeholder }}" | 43 {%- if placeholder %} placeholder="{{ placeholder }}"{% endif %} |
35 {%- if value %} value="{{ value }}"{% endif %} | 44 {%- if value %} value="{{ value }}"{% endif %} |
36 {%- if required %} required{% endif %} | 45 {%- if required %} required{% endif %} |
37 {{- extras | xmlattr }}> | 46 {{- extras | xmlattr }}> |
38 {% if type == "datetime" %} | 47 {% if type == "datetime" %} |
39 <span class="input-group-btn"> | 48 <span class="input-group-btn"> |
43 {% endif %} | 52 {% endif %} |
44 {% if help %} | 53 {% if help %} |
45 <span class="help-block">{{ help }}</span> | 54 <span class="help-block">{{ help }}</span> |
46 {% endif %} | 55 {% endif %} |
47 </div> | 56 </div> |
57 {% endmacro %} | |
58 | |
59 {% macro modal(id, title, size=None) %} | |
60 <div class="modal fade" id="{{ id }}" tabindex="-1" role="dialog" aria-labelledby="{{ id }}_title" aria-hidden="true"> | |
61 <div class="modal-dialog{{ ' modal-%s' % size if size}}"> | |
62 <div class="modal-content"> | |
63 <div class="modal-header"> | |
64 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | |
65 <h4 class="modal-title" id="{{ id }}_title">{{ title }}</h4> | |
66 </div> | |
67 <div class="modal-body"> | |
68 {{ caller() }} | |
69 </div>{# We don't need a footer yet ... | |
70 <div class="modal-footer"> | |
71 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |
72 <button type="button" class="btn btn-primary">Save changes</button> | |
73 </div>#} | |
74 </div>{# /.modal-content #} | |
75 </div>{# /.modal-dialog #} | |
76 </div>{# /.modal #} | |
48 {% endmacro %} | 77 {% endmacro %} |
49 | 78 |
50 {% macro textarea(name, label, placeholder="", value=None, rows=10, required=False) %} | 79 {% macro textarea(name, label, placeholder="", value=None, rows=10, required=False) %} |
51 <div class="form-group"> | 80 <div class="form-group"> |
52 <label for="{{ name }}">{{ label }}:{% if required %}<span class="text-danger"> *</span>{% endif %}</label> | 81 <label for="{{ name }}">{{ label }}:{% if required %}<span class="text-danger"> *</span>{% endif %}</label> |
105 <div class="col-sm-{{ right }}"> | 134 <div class="col-sm-{{ right }}"> |
106 <p class="form-control-static">{{ value }}</p> | 135 <p class="form-control-static">{{ value }}</p> |
107 </div> | 136 </div> |
108 </div> | 137 </div> |
109 {% endmacro %} | 138 {% endmacro %} |
139 | |
140 {% macro examples(list) %} | |
141 {% if False %} | |
142 <dl> | |
143 <dt>Example{{ 's' if list | length > 1 }}:</dt> | |
144 {% for elem in list %} | |
145 <dd><samp>{{ elem }}</samp></dd> | |
146 {% endfor %} | |
147 </dl> | |
148 {% else %} | |
149 <p><strong>Example{{ 's' if list | length > 1 }}:</strong></p> | |
150 {% if list | length == 1 %} | |
151 <samp>{{ list[0] }}</samp> | |
152 {% else %} | |
153 <ul> | |
154 {%- for elem in list %} | |
155 <li><samp>{{ elem }}</samp></li> | |
156 {%- endfor %} | |
157 </ul> | |
158 {% endif %} | |
159 {% endif %} | |
160 {% endmacro %} |