home · contact · privacy
Simplify Todo steps tree calculation/display.
[plomtask] / templates / day.html
index efa1c9bb1e78fc5ea455c5a678b4727fb22efdd3..f13eb5c309750d01a7f366c2a85255ccb44d4bd9 100644 (file)
 {% extends 'base.html' %}
 
 
-{% macro show_node(node, indent) %}
-{% if node.is_todo %}
-{% for i in range(indent) %}  {% endfor %} +
-{% if node.seen %}({% else %}{% endif %}<a href="todo?id={{node.item.id_}}">{{node.item.process.title.newest|e}}</a>{% if node.seen %}){% else %}{% endif %}
-{% else %}
-{% for i in range(indent) %}&nbsp;{% endfor %} +
-{% if node.seen %}({% else %}{% endif %}<a href="condition?id={{node.item.id_}}">{{node.item.title.newest|e}}</a>{% if node.seen %}){% else %}{% endif %}
-{% endif %}
-{% endmacro %}
 
+{% block css %}
+td, th, tr, table {
+  padding: 0;
+  margin: 0;
+}
+th {
+  border: 1px solid black;
+}
+td.min_width {
+  min-width: 1em;
+}
+td.cond_line_0 {
+  background-color: #ffbbbb;
+}
+td.cond_line_1 {
+  background-color: #bbffbb;
+}
+td.cond_line_2 {
+  background-color: #bbbbff;
+}
+td.todo_line {
+  border-bottom: 1px solid #bbbbbb;
+}
+{% endblock %}
 
-{% macro undone_with_children(node, indent) %}
-{% if not node.hide %}
+
+
+{% macro show_node_undone(node, indent) %}
+{% if not node.todo.is_done %}
 <tr>
-<td>
-{% if node.is_todo %}
-<input name="done" value="{{node.item.id_}}" type="checkbox" {% if node.seen or not node.item.is_doable %}disabled{% endif %} {% if node.item.is_done %} checked {% endif %} />
-{% endif %}
-</td>
-<td>
-{{ show_node(node, indent) }}
+
+{% for condition in conditions_present %}
+<td class="cond_line_{{loop.index0 % 3}} {% if not condition.is_active %}min_width{% endif %}">{% if condition in node.todo.conditions %}{% if not condition.is_active %}O{% endif %}{% endif %}</td>
+{% endfor %}
+
+<td class="todo_line">-&gt;</td>
+<td class="todo_line"><input type="checkbox" {% if node.todo.is_done %}checked disabled{% endif %} {% if not node.todo.is_doable %}disabled{% endif %}/></td>
+<td class="todo_line">
+{% for i in range(indent) %}&nbsp; {% endfor %} +
+{% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.process.title.newest|e}}</a>{% if node.seen %}){% endif %}
 </td>
+<td class="todo_line">-&gt;</td>
+
+{% for condition in conditions_present|reverse %}
+<td class="cond_line_{{(conditions_present|length - loop.index) % 3}} {% if condition in node.todo.enables or condition in node.todo.disables %}min_width{% endif %}">{% if condition in node.todo.enables %}+{% elif condition in node.todo.disables %}!{% endif %}</td>
+{% endfor %}
+
+<td><input name="comment" /></td>
+
 </tr>
 {% endif %}
+
+{% if not node.seen %}
 {% for child in node.children %}
-{{ undone_with_children(child, indent+1) }}
+{{ show_node_undone(child, indent+1) }}
 {% endfor %}
+{% endif %}
+
 {% endmacro %}
 
 
-{% macro done_with_children(node, indent) %}
-{% if not node.hide %}
+
+{% macro show_node_done(node, indent, path) %}
+{% if node.todo.is_done %}
+
 <tr>
+{% if path|length > 0 and not path[-1].todo.is_done %}
 <td>
-{{ show_node(node, indent) }}
+({% for path_node in path %}<a href="todo?id={{path_node.todo.id_}}">{{path_node.todo.process.title.newest|e}}</a> &lt;- {% endfor %})
 </td>
 </tr>
+
+<tr>
+<td>
+&nbsp; +
+{% else %}
+<td>
+{% for i in range(indent) %}&nbsp; {% endfor %} +
+{% endif %}
+{% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.process.title.newest|e}}</a>{% if node.seen %}){% endif %}
+</td>
+</tr>
+
 {% endif %}
+{% if not node.seen %}
 {% for child in node.children %}
-{{ done_with_children(child, indent+1) }}
+{{ show_node_done(child, indent+1, path + [node]) }}
 {% endfor %}
+{% endif %}
+
 {% endmacro %}
 
 
+
 {% block content %}
 <h3>{{day.date}} / {{day.weekday}}</h3>
 <p>
@@ -59,30 +110,78 @@ add todo: <input name="new_todo" list="processes" autocomplete="off" />
 <option value="{{process.id_}}">{{process.title.newest|e}}</option>
 {% endfor %}
 </datalist>
-<h4>conditions</h4>
-<ul>
-{% for node in condition_listings %}
-<li>[{% if node.condition.is_active %}x{% else %} {% endif %}] <a href="condition?id={{node.condition.id_}}">{{node.condition.title.newest|e}}</a>
-({% for enabler in node.enablers %}
-&lt; {{enabler.process.title.newest|e}};
+
+<h4>todo</h4>
+
+<table>
+
+<tr>
+<th colspan={{ conditions_present|length}}>c</th>
+<th colspan=4>states</th>
+<th colspan={{ conditions_present|length}}>t</th>
+<th>add enabler</th>
+</tr>
+
+{% for condition in conditions_present %}
+{% set outer_loop = loop %}
+<tr>
+
+{% for _ in conditions_present %}
+{% if outer_loop.index > loop.index %}
+<td class="cond_line_{{loop.index0 % 3}}">
+{% else %}
+<td class="cond_line_{{outer_loop.index0 % 3}}">
+{% endif %}
+{% if outer_loop.index == loop.index  %}
+{% endif %}
+</td>
 {% endfor %}
-{% for disabler in node.disablers %}
-! {{disabler.process.title.newest|e}};
-{% endfor %})
+
+<td class="cond_line_{{loop.index0 % 3}}">[{% if condition.is_active %}X{% else %}&nbsp;{% endif %}]</td>
+<td colspan=3 class="cond_line_{{loop.index0 % 3}}"><a href="condition?id={{condition.id_}}">{{condition.title.newest|e}}</a></td>
+
+{% for _ in conditions_present %}
+{% if outer_loop.index0 + loop.index0 < conditions_present|length %}
+<td class="cond_line_{{outer_loop.index0 % 3}}">
+{% else %}
+<td class="cond_line_{{(conditions_present|length - loop.index) % 3}}">
+{% endif %}
 {% endfor %}
-</ul>
-<h4>to do</h4>
-<table>
-{% for node in todo_trees %}
-{{ undone_with_children(node, indent=0) }}
+
+<td><input list="todos_for_{{condition.id_}}" /></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 />
+</td>
+</tr>
+{% endfor %}
+
+<tr>
+{% for condition in conditions_present %}
+<td class="cond_line_{{loop.index0 % 3}}"></td>
+{% endfor %}
+<th colspan={{ 4 }}>doables</th>
+{% for condition in conditions_present %}
+<td class="cond_line_{{(conditions_present|length - loop.index) % 3}}"></td>
+{% endfor %}
+<th>comments</th>
+</tr>
+{% for node in top_nodes %}
+{{ show_node_undone(node, 0) }}
+{% endfor %}
+
 </table>
+
 <h4>done</h4>
+
 <table>
-{% for node in done_trees %}
-{{ done_with_children(node, indent=0) }}
+{% for node in top_nodes %}
+{{ show_node_done(node, 0, []) }}
 {% endfor %}
 </table>
+
 </form>
 {% endblock %}