home · contact · privacy
Simplify and improve previous bugfix.
[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 <form action="{{item_name}}_{{attribute_name}}s?id={{item.id_}}" method="POST">
43 <table>
44
45 <tr>
46 <th>{{item_name}}</th>
47 <td><a href="{{item_name}}?id={{item.id_}}">{{item.title.newest|e}}</a></td>
48 </tr>
49
50
51 {% for date in attribute.history.keys() | sort(reverse=True) %}
52 <tr>
53 <td><input name="at:{{date}}" class="timestamp" value="{{date|truncate(19, True, '', 0)}}"></td>
54 <td>{% if as_pre %}<pre>{% endif %}{{attribute.history[date]}}{% if as_pre %}</pre>{% endif %}</td>
55 </tr>
56 {% endfor %}
57
58 </table>
59 <input class="btn-harmless" type="submit" name="update" value="update" />
60 </form>
61 {% endmacro %}