From f59afccd32d45e60c48d451e6b8304a817627c62 Mon Sep 17 00:00:00 2001 From: Christian Heller <c.heller@plomlompom.de> Date: Sat, 18 May 2024 07:02:41 +0200 Subject: [PATCH] Add erroneously uncommited template macros file. --- templates/_macros.html | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 templates/_macros.html diff --git a/templates/_macros.html b/templates/_macros.html new file mode 100644 index 0000000..25d94c5 --- /dev/null +++ b/templates/_macros.html @@ -0,0 +1,55 @@ +{% macro edit_buttons() %} +<input class="btn-harmless" type="submit" name="update" value="update" /> +<div class="btn-to-right"> +<input class="btn-dangerous" type="submit" name="delete" value="delete" /> +</div> +{% endmacro %} + + + +{% macro datalist_of_titles(title, candidates) %} +<datalist id="{{title}}"> +{% for candidate in candidates %} +<option value="{{candidate.id_}}">{{candidate.title.newest|e}}</option> +{% endfor %} +</datalist> +{% endmacro %} + + + +{% macro simple_checkbox_table(title, items, type_name, list_name, add_string="add") %} +<table> +{% for item in items %} +<tr> +<td> +<input type="checkbox" name="{{title}}" value="{{item.id_}}" checked /> +</td> +<td> +<a href="{{type_name}}?id={{item.id_}}">{{item.title.newest|e}}</a> +</td> +</tr> +{% endfor %} +</table> +{{add_string}}: <input name="{{title}}" list="{{list_name}}" autocomplete="off" /> +{% endmacro %} + + + +{% macro history_page(item_name, item, attribute_name, attribute, as_pre=false) %} +<h3>{{item_name}} {{attribute_name}} history</h3> +<table> + +<tr> +<th>{{item_name}}</th> +<td><a href="{{item_name}}?id={{item.id_}}">{{item.title.newest|e}}</a></td> +</tr> + +{% for date in attribute.history.keys() | sort(reverse=True) %} +<tr> +<th>{{date | truncate(19, True, '') }}</th> +<td>{% if as_pre %}<pre>{% endif %}{{attribute.history[date]}}{% if as_pre %}</pre>{% endif %}</td> +</tr> +{% endfor %} + +</table> +{% endmacro %} -- 2.30.2