home · contact · privacy
Improve multiple template layouts and refactor CSS.
[plomtask] / templates / _macros.html
1 {% macro edit_buttons() %}
2 <input class="btn-harmless" type="submit" name="update" value="update" />
3 <div class="btn-to-right">
4 <input class="btn-dangerous" type="submit" name="delete" value="delete" />
5 </div>
6 {% endmacro %}
7
8
9
10 {% macro datalist_of_titles(title, candidates) %}
11 <datalist id="{{title}}">
12 {% for candidate in candidates %}
13 <option value="{{candidate.id_}}">{{candidate.title.newest|e}}</option>
14 {% endfor %}
15 </datalist>
16 {% endmacro %}
17
18
19
20 {% macro simple_checkbox_table(title, items, type_name, list_name, add_string="add", historical=false) %}
21 {% if items|length > 0 %}
22 <table>
23 {% for item in items %}
24 <tr>
25 <td>
26 <input type="checkbox" name="{{title}}" value="{{item.id_}}" checked />
27 </td>
28 <td>
29 <a href="{{type_name}}?id={{item.id_}}">{% if historical is true %}{{item.title_then}}{% else %}{{item.title.newest|e}}{% endif %}</a>
30 </td>
31 </tr>
32 {% endfor %}
33 </table>
34 {% endif %}
35 {{add_string}}: <input name="{{title}}" type="text" list="{{list_name}}" autocomplete="off" />
36 {% endmacro %}
37
38
39
40 {% macro history_page(item_name, item, attribute_name, attribute, as_pre=false) %}
41 <h3>{{item_name}} {{attribute_name}} history</h3>
42 <table>
43
44 <tr>
45 <th>{{item_name}}</th>
46 <td><a href="{{item_name}}?id={{item.id_}}">{{item.title.newest|e}}</a></td>
47 </tr>
48
49 {% for date in attribute.history.keys() | sort(reverse=True) %}
50 <tr>
51 <th>{{date | truncate(19, True, '') }}</th>
52 <td>{% if as_pre %}<pre>{% endif %}{{attribute.history[date]}}{% if as_pre %}</pre>{% endif %}</td>
53 </tr>
54 {% endfor %}
55
56 </table>
57 {% endmacro %}