--- /dev/null
+<!DOCTYPE html>
+<html>
+<meta charset="UTF-8">
+<style>
+body {
+ font-family: monospace;
+ text-align: left;
+ padding: 0;
+}
+input.btn-harmless {
+ color: green;
+}
+input.btn-dangerous {
+ color: red;
+}
+div.btn-to-right {
+ float: right;
+ text-align: right;
+}
+td, th, tr, table {
+ vertical-align: top;
+ padding: 0;
+}
+{% block css %}
+{% endblock %}
+</style>
+<body>
+<a href="processes">processes</a>
+<a href="conditions">conditions</a>
+<a href="day">today</a>
+<a href="calendar">calendar</a>
+<hr>
+{% block content %}
+{% endblock %}
+</body>
+</html>
+++ /dev/null
-<!DOCTYPE html>
-<html>
-<meta charset="UTF-8">
-<style>
-body {
- font-family: monospace;
- text-align: left;
- padding: 0;
-}
-input.btn-harmless {
- color: green;
-}
-input.btn-dangerous {
- color: red;
-}
-div.btn-to-right {
- float: right;
- text-align: right;
-}
-td, th, tr, table {
- vertical-align: top;
- padding: 0;
-}
-{% block css %}
-{% endblock %}
-</style>
-<body>
-<a href="processes">processes</a>
-<a href="conditions">conditions</a>
-<a href="day">today</a>
-<a href="calendar">calendar</a>
-<hr>
-{% block content %}
-{% endblock %}
-</body>
-</html>
-{% extends 'base.html' %}
+{% extends '_base.html' %}
+
+
{% block css %}
tr.week_row td {
-{% extends 'base.html' %}
+{% extends '_base.html' %}
+{% import '_macros.html' as macros %}
<tr/>
</table>
-<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>
+{{ macros.edit_buttons() }}
{% endblock %}
-{% extends 'base.html' %}
+{% extends '_base.html' %}
{% block content %}
<a href="condition">add</a>
-{% extends 'base.html' %}
+{% extends '_base.html' %}
+{% import '_macros.html' as macros %}
comment: <input name="day_comment" value="{{day.comment|e}}" />
<input type="submit" value="OK" /><br />
add todo: <input name="new_todo" list="processes" autocomplete="off" />
-<datalist id="processes">
-{% for process in processes %}
-<option value="{{process.id_}}">{{process.title.newest|e}}</option>
-{% endfor %}
-</datalist>
<h4>todo</h4>
<td class="cond_line_{{(conditions_present|length - loop.index) % 3}}">
{% endif %}
{% endfor %}
-
-<td><input name="new_todo" list="todos_for_{{condition.id_}}" autocomplete="off" /></td>
-<datalist name="new_todo" id="todos_for_{{condition.id_}}" />
-{% for process in enablers_for[condition.id_] %}
-<option value="{{process.id_}}">{{process.title.newest|e}}</option>
-{% endfor %}
-</datalist />
+{% set list_name = "todos_for_%s"|format(condition.id_) %}
+<td><input name="new_todo" list="{{list_name}}" autocomplete="off" /></td>
+{{ macros.datalist_of_direct_titles(list_name, enablers_for[condition.id_]) }}
</td>
</tr>
{% endfor %}
</table>
</form>
-{% endblock %}
+{{ macros.datalist_of_direct_titles("processes", processes) }}
+{% endblock %}
-{% extends 'base.html' %}
+{% extends '_base.html' %}
+
+
{% block content %}
<p>{{msg}}</p>
-{% extends 'base.html' %}
+{% extends '_base.html' %}
+{% import '_macros.html' as macros %}
<tr>
<th>conditions</th>
-<td>
-<table>
-{% for condition in process.conditions %}
-<tr>
-<td>
-<input type="checkbox" name="condition" value="{{condition.id_}}" checked />
-</td>
-<td>
-<a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a>
-</td>
-</tr>
-{% endfor %}
-</table>
-add: <input name="condition" list="condition_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("condition", process.conditions, "condition", "condition_candidates") }}</td>
</tr>
<tr>
<th>enables</th>
-<td>
-<table>
-{% for condition in process.enables %}
-<tr>
-<td>
-<input type="checkbox" name="enables" value="{{condition.id_}}" checked />
-</td>
-<td>
-<a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a>
-</td>
-</tr>
-{% endfor %}
-</table>
-add: <input name="enables" list="condition_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("enables", process.enables, "condition", "condition_candidates") }}</td>
</tr>
<tr>
<th>disables</th>
-<td>
-<table>
-{% for condition in process.disables %}
-<tr>
-<td>
-<input type="checkbox" name="disables" value="{{condition.id_}}" checked />
-</td>
-<td>
-<a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a>
-</td>
-</tr>
-{% endfor %}
-</table>
-add: <input name="disables" list="condition_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("disables", process.disables, "condition", "condition_candidates") }}</td>
</tr>
<tr>
<tr>
</table>
-<datalist id="condition_candidates">
-{% for condition_candidate in condition_candidates %}
-<option value="{{condition_candidate.id_}}">{{condition_candidate.title.newest|e}}</option>
-{% endfor %}
-</datalist>
-<datalist id="step_candidates">
-{% for candidate in step_candidates %}
-<option value="{{candidate.id_}}">{{candidate.title.newest|e}}</option>
-{% endfor %}
-</datalist>
-
-<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>
+{{ macros.edit_buttons() }}
</form>
+
+{{ macros.datalist_of_direct_titles("condition_candidates", condition_candidates) }}
+{{ macros.datalist_of_direct_titles("step_candidates", step_candidates) }}
{% endblock %}
-{% extends 'base.html' %}
+{% extends '_base.html' %}
{% block content %}
<a href="process">add</a>
-{% extends 'base.html' %}
+{% extends '_base.html' %}
+{% import '_macros.html' as macros %}
<tr>
<th>conditions</th>
-<td>
-<table>
-{% for condition in todo.conditions %}
-<tr>
-<td>
-<input type="checkbox" name="condition" value="{{condition.id_}}" checked />
-</td>
-<td>
-<a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a>
-</td>
-</tr>
-{% endfor %}
-</table>
-add: <input name="condition" list="condition_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates") }}</td>
</tr>
<tr>
<th>enables</th>
-<td>
-<table>
-{% for condition in todo.enables %}
-<tr>
-<td>
-<input type="checkbox" name="enables" value="{{condition.id_}}" checked />
-</td>
-<td>
-<a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a>
-</td>
-</tr>
-{% endfor %}
-</table>
-add: <input name="enables" list="condition_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("enables", todo.enables, "condition", "condition_candidates") }}</td>
</tr>
<tr>
<th>disables</th>
-<td>
-<table>
-{% for condition in todo.disables%}
-<tr>
-<td>
-<input type="checkbox" name="disables" value="{{condition.id_}}" checked />
-</td>
-<td>
-<a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a>
-</td>
-</tr>
-{% endfor %}
-</table>
-add: <input name="disables" list="condition_candidates" autocomplete="off" />
-</td>
+<td>{{ macros.simple_checkbox_table("disables", todo.disables, "condition", "condition_candidates") }}</td>
</tr>
<tr>
</tr>
</table>
-<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>
+{{ macros.edit_buttons() }}
</form>
-<datalist id="condition_candidates">
-{% for condition_candidate in condition_candidates %}
-<option value="{{condition_candidate.id_}}">{{condition_candidate.title.newest|e}}</option>
-{% endfor %}
-</datalist>
-<datalist id="todo_candidates">
-{% for candidate in todo_candidates %}
-<option value="{{candidate.id_}}">{{candidate.process.title.newest|e}} ({{candidate.id_}})</option>
-{% endfor %}
-</datalist>
+{{ macros.datalist_of_direct_titles("condition_candidates", condition_candidates) }}
+{{ macros.datalist_of_indirect_titles("todo_candidates", todo_candidates) }}
{% endblock %}