home · contact · privacy
Re-factor Day.todos code.
[plomtask] / templates / day.html
1 {% extends '_base.html' %}
2 {% import '_macros.html' as macros %}
3
4
5
6 {% block css %}
7 th {
8   border: 1px solid black;
9 }
10 td.cond_line_0, td.cond_line_1, td.cond_line_2 {
11   padding: 0;
12   border-top: 1px solid white;
13 }
14 td.cond_line_0 {
15   background-color: #bfbfbf;
16 }
17 td.cond_line_1 {
18   background-color: #dfdfdf;
19 }
20 td.cond_line_2 {
21   background-color: #fffff;
22 }
23 td.cond_line_corner {
24   max-width: 0px;
25   white-space: nowrap;
26   overflow: hidden;
27   text-overflow: clip;
28 }
29 td.todo_line {
30   border-bottom: 1px solid #bfbfbf;
31   height: 1.7em;
32 }
33 tr.inactive > td.todo_line {
34   background-color: #bfbfbf;
35   border-bottom: 1px solid white;
36 }
37 tr.hidden_undone > td, tr.hidden_undone a {
38   color: #9f9f9f;
39 }
40 td.left_border {
41   border-left: 1px solid black;
42 }
43 td.right_border {
44   border-right: 1px solid black;
45 }
46 input.ablers {
47   width: 50em;
48 }
49 {% endblock %}
50
51
52
53 {% macro show_node_undone(node, indent) %}
54 {% if not node.todo.is_done %}
55 <tr {% if node.seen or not node.todo.is_doable %}class="inactive"{% endif %}>
56 {% if not node.seen %}
57 <input type="hidden" name="todo_id" value="{{node.todo.id_}}" />
58 {% endif %}
59
60 {% for condition in conditions_present %}
61 <td class="cond_line_{{loop.index0 % 3}}">
62 {% if condition in node.todo.conditions and not condition.is_active %}
63 O&nbsp;
64 {% elif condition in node.todo.blockers and condition.is_active %}
65 !&nbsp;
66 {% endif %}
67 </td>
68 {% endfor %}
69
70 {% if node.seen %}
71 <td class="todo_line left_border"></td>
72 <td class="todo_line">{% if node.todo.effort %}{{ node.todo.effort }}{% endif %}</td>
73 {% else %}
74 <td class="todo_line left_border"><input name="done" type="checkbox" value="{{node.todo.id_}}" {% if not node.todo.is_doable %}disabled{% endif %}/></td>
75 <td class="todo_line"><input name="effort" type="number" step=0.1 placeholder={{node.todo.effort_then}} value={{node.todo.effort}} /></td>
76 {% endif %}
77 <td class="todo_line right_border">
78 {% for i in range(indent) %}&nbsp; &nbsp; {% endfor %} +
79 {% if node.seen %}({% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.title_then|e}}</a>{% if node.seen %}){% endif %}
80 </td>
81
82 {% for condition in conditions_present|reverse %}
83 <td class="cond_line_{{(conditions_present|length - loop.index) % 3}}">{% if condition in node.todo.enables %}&nbsp;+{% elif condition in node.todo.disables %}&nbsp;!{% endif %}</td>
84 {% endfor %}
85
86 <td colspan=2>
87 {% if node.seen %}
88 {{node.todo.comment|e}}
89 {% else %}
90 <input name="comment" type="text" value="{{node.todo.comment|e}}" />
91 {% endif %}
92 </td>
93
94 </tr>
95 {% endif %}
96
97 {% if not node.seen %}
98 {% for child in node.children %}
99 {{ show_node_undone(child, indent+1) }}
100 {% endfor %}
101 {% endif %}
102
103 {% endmacro %}
104
105
106
107 {% macro show_node_done(node, indent, path) %}
108 {% if node.todo.has_doneness_in_path %}
109 <tr{% if not node.todo.is_done %} class="hidden_undone"{% endif %}>
110 <td class="number">{{ '{:4.1f}'.format(node.todo.performed_effort) }}</td>
111 <td class="number">{{ '{:4.1f}'.format(node.todo.tree_effort) }}</td>
112 <td>
113 {% for i in range(indent) %}&nbsp; &nbsp; {% endfor %} +
114 {% if not node.todo.is_done %}({% endif %}{% if node.seen %}[{% endif %}<a href="todo?id={{node.todo.id_}}">{{node.todo.title_then|e}}</a>{% if node.seen %}]{% endif %}{% if not node.todo.is_done %}){% endif %}{% if node.todo.comment %} · {{node.todo.comment|e}}{% endif %}</td>
115 </tr>
116 {% if not node.seen %}
117 {% for child in node.children %}
118 {{ show_node_done(child, indent+1) }}
119 {% endfor %}
120 {% endif %}
121 {% endif %}
122 {% endmacro %}
123
124
125
126 {% block content %}
127 <h3>{{day.date}} / {{day.weekday}} ({{day.total_effort|round(1)}})</h3>
128 <p>
129 <a href="day?date={{day.prev_date}}">prev</a> | <a href="day?date={{day.next_date}}">next</a>
130 </p>
131 <form action="day?date={{day.date}}" method="POST">
132
133 <p>
134 comment:
135 <input name="day_comment" type="text" value="{{day.comment|e}}" />
136 <input type="submit" value="OK" /></td>
137 </p>
138
139 <h4>to do</h4>
140
141 <p>
142 add: <input type="text" name="new_todo" list="processes">
143 </p>
144 <p>
145 <select name="make_type">
146 <option value="full">make new todos with children</option>
147 <option value="empty"{% if make_type == "empty" %}selected {% endif %}>make new todos without children</option>
148 </select>
149 </p>
150
151 <table>
152
153 <tr>
154 <th colspan={{ conditions_present|length + 3 + conditions_present|length }}>conditions</th>
155 <th>add enabler</th>
156 <th>add disabler</th>
157 </tr>
158
159 {% for condition in conditions_present %}
160 {% set outer_loop = loop %}
161 <tr>
162
163 {% for _ in conditions_present %}
164 {% if outer_loop.index > loop.index %}
165 <td class="cond_line_{{loop.index0 % 3}}">
166 {% elif outer_loop.index < loop.index %}
167 <td class="cond_line_{{outer_loop.index0 % 3}}">
168 {% else %}
169 <td class="cond_line_{{outer_loop.index0 % 3}} cond_line_corner">×
170 {% endif %}
171 </td>
172 {% endfor %}
173
174 <td class="cond_line_{{loop.index0 % 3}}"><input type="checkbox" disabled{% if condition.is_active %} checked{% endif %}></td>
175 <td colspan=2 class="cond_line_{{loop.index0 % 3}}"><a href="condition?id={{condition.id_}}">{{condition.title.at(day.date)|e}}</a></td>
176
177 {% for _ in conditions_present %}
178 {% if outer_loop.index0 + loop.index < conditions_present|length %}
179 <td class="cond_line_{{outer_loop.index0 % 3}}">
180 {% elif outer_loop.index0 + loop.index > conditions_present|length %}
181 <td class="cond_line_{{(conditions_present|length - loop.index) % 3}}">
182 {% else %}
183 <td class="cond_line_{{outer_loop.index0 % 3}} cond_line_corner">&nbsp;×
184 {% endif %}
185 {% endfor %}
186
187 {% set list_name = "todos_for_%s"|format(condition.id_) %}
188 <td><input class="ablers" type="text" name="new_todo" list="{{list_name}}" autocomplete="off" /></td>
189 {{ macros.datalist_of_titles(list_name, enablers_for[condition.id_]) }}
190 </td>
191 {% set list_name = "todos_against_%s"|format(condition.id_) %}
192 <td><input class="ablers" type="text" name="new_todo" list="{{list_name}}" autocomplete="off" /></td>
193 {{ macros.datalist_of_titles(list_name, disablers_for[condition.id_]) }}
194 </td>
195 </tr>
196 {% endfor %}
197
198 <tr>
199 {% for condition in conditions_present %}
200 <td class="cond_line_{{loop.index0 % 3}}"></td>
201 {% endfor %}
202 <th colspan=3>doables</th>
203 {% for condition in conditions_present %}
204 <td class="cond_line_{{(conditions_present|length - loop.index) % 3}}"></td>
205 {% endfor %}
206 <th colspan=2>comments</th>
207 </tr>
208 {% for node in top_nodes %}
209 {{ show_node_undone(node, 0) }}
210 {% endfor %}
211
212 </table>
213
214 <h4>done</h4>
215
216 <table class="alternating">
217 <tr>
218 <th colspan=2>effort</th><th rowspan=2>action · comment</th>
219 </tr>
220 <tr>
221 <th>self</th><th>tree</th>
222 </tr>
223 {% for node in top_nodes %}
224 {{ show_node_done(node, 0, []) }}
225 {% endfor %}
226 </table>
227
228 </form>
229
230 {{ macros.datalist_of_titles("processes", processes) }}
231 {% endblock %}