home · contact · privacy
Improve todo accounting script.
[misc] / todo_templates / do_todos.html
1 {% extends 'base.html' %}
2
3 {% block css %}
4 td.number, td.checkbox { text-align: center; }
5 td { vertical-align: middle; }
6 td button { padding: 0em; }
7 th.centered { text-align: center; }
8 {% endblock %}
9
10 {% block content %}
11 <h3>do todos</h3>
12
13 <form id="form_to_watch" action="do_todos" method="POST">
14 {% include 'tagfilters.html' %}
15 <br />
16 <input name="hide_done" type="checkbox" {% if hide_done %}checked{% endif %} /> hide done
17 <input type="submit" name="filter" value="filter" />
18 <p>
19 | <a href="do_todos?date={{prev_date}}">prev</a> | {{day.date}} | <a href="do_todos?date={{next_date}}">next</a> | 
20 comment: <input name="day_comment" value="{{day.comment|e}}">
21 <input class="update" type="submit" name="update" value="update">
22 <input type="hidden" name="date" value="{{day.date}}" />
23 </p>
24
25 <table class="alternating">
26 <tr>
27 <th {% if sort=='done' %}class="desc"{% endif %}>
28 <a href="?sort=done">done</a>
29 </th>
30 <th class="centered{% if sort=='default_effort' %} desc{% endif %}">
31 <a href="?sort=default_effort">effort</a>
32 </th>
33 <th {% if sort=='importance' %}class ="desc"{% endif %}>
34 <a href="?sort=importance">importance</a>
35 </th>
36 <th {% if sort=='title' %}class="desc"{% endif %}>
37 <a href="?sort=title">todo</a>
38 </th>
39 <th>comment</th>
40 </tr>
41
42 {% for todo in todos %}
43 <tr>
44 <input name="todo_id" value="{{todo.id_}}" type="hidden" >
45 <td class="checkbox">
46 <input name="done" type="checkbox" value="{{todo.id_}}" {% if todo.done %}checked{% endif %}>
47 </td>
48 <td class="number">
49 <input class="effort_input" name="effort" type="number" step=0.1 size=7 value="{% if todo.day_effort is not none %}{{todo.day_effort}}{% endif %}" placeholder={{"%.1f"|format(todo.task.default_effort.then)}} >
50 </td>
51 <td class="number">
52 <input name="importance" type="number" step=0.1 size=7 value={{todo.importance}} } >
53 </td>
54 <td>
55 <a href="todo?id={{todo.id_}}&return_to=do_todos">{{todo.path}}{{todo.title}}</a>
56 </td>
57 <td>
58 <input name="effort_comment" type="text" size=100 value="{{todo.comment|e}}" />
59 </td>
60 </tr>
61 {% endfor %}
62
63 </table>
64 <input class="update" type="submit" name="update" value="update">
65 </form>
66
67 {% include 'watch_form.html' %}
68 <script>
69 mere_filter_inputs = mere_filter_inputs.concat(['hide_done']);
70 var effort_inputs = document.getElementsByClassName("effort_input");
71 for (let i = 0; i < effort_inputs.length; i++) {
72     let input = effort_inputs[i];
73     let button = document.createElement('button');
74     button.innerHTML = '+' + parseFloat(input.placeholder).toFixed(1);
75     button.onclick = function(event) {
76         event.preventDefault();
77         if (input.value) {
78             input.value = parseFloat(input.value) + parseFloat(input.placeholder);
79         } else {
80             input.value = parseFloat(input.placeholder);
81         }
82         input.value = parseFloat(input.value).toFixed(1);
83         changes_to_commit = true; 
84     };
85     input.insertAdjacentElement('afterend', button);
86 }
87 </script>
88 {% endblock %}