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