home · contact · privacy
Improve accounting scripts.
[misc] / todo_templates / day.html
index 5c63670824768e55b2c8bb397ef5a79cca199719..6231aea24b5b75f2e4a22d8af44d37373b4f9509 100644 (file)
@@ -1,11 +1,12 @@
 {% extends 'base.html' %}
 {% block css %}
 table.alternating tr:nth-child(even) {
-    background-color: #f2f2f2;
+    background-color: #e2e2e2;
 }
 table.alternating tr:nth-child(odd) {
     background-color: #ffffff;
 }
+th.desc { background: linear-gradient(to bottom, white, grey); }
 td.checkbox, td.number { height: 0.1em; padding: 0em; text-align: center; }
 td.checkbox { width: 0.1em }
 td button { height: 1.5em; padding: 0em; margin: 0em }
@@ -21,49 +22,69 @@ input[type="number"] { text-align: right; }
 </p>
 </form>
 
-<form id="form_to_watch" action="{{action|e}}" method="POST">
 <h3>edit day</h3>
+<form id="form_to_watch" action="{{action|e}}" method="POST">
 <p>
-<a href="{{db.prefix}}/day?selected_date={{prev_date}}">prev</a> | {{db.selected_date}} | <a href="{{db.prefix}}/day?selected_date={{next_date}}">next</a> | 
-{{ db.selected_day.todos_sum|round(2) }} ({{ db.selected_day.todos_sum2|round(2)}}) |
+| <a href="{{db.prefix}}/day?selected_date={{prev_date}}">prev</a> | {{db.selected_date}} | <a href="{{db.prefix}}/day?selected_date={{next_date}}">next</a> | 
 comment: <input name="day_comment" value="{{ db.selected_day.comment|e }}">
 <input type="submit" value="update">
 <input type="hidden" name="selected_date" value="{{ db.selected_date }}" />
 </p>
+<details>
+<summary>done: {{ db.selected_day.todos_sum|round(2) }} ({{ db.selected_day.todos_sum2|round(2)}})</summary>
 <table class="alternating">
-<tr><th>task</th><th class="checkbox">choose?</th><th class="checkbox">done?</th><th>weight</th><th>edit?</th><th>day tags</th><th>comment</th></tr>
-{% for uuid, t in db.tasks.items() | sort(attribute='1.title') %}
-{% if t.visible and (uuid not in db.selected_day.todos.keys() or db.selected_day.todos[uuid].visible) %}
+{% for todo in done_tasks %}
 <tr>
-<input name="t_uuid" value="{{ uuid }}" type="hidden" >
-<td><details><summary>] <a href="{{db.prefix}}/task?id={{ uuid }}" />{{ t.current_title|e }}</a></summary>tags: {% for tag in t.tags | sort %}<a href="{{db.prefix}}/day?t_and={{tag|e}}">{{ tag }}</a> {% endfor %}</details></td>
-{% if uuid in db.selected_day.todos.keys() %}
-<td class="checkbox"><input name="choose" type="checkbox" value="{{ uuid }}" checked></td>
-<td class="checkbox"><input name="done" type="checkbox" value="{{ uuid }}" {% if db.selected_day.todos[uuid].done %}checked{% endif %}></td>
-<td class="number"><input class="day_weight_input" name="day_weight" type="number" step=0.1 size=8 value="{% if db.selected_day.todos[uuid].day_weight is not none %}{{ db.selected_day.todos[uuid].day_weight }}{% endif %}" placeholder={{ t.current_default_weight }} ></td>
-<td><a href="{{db.prefix}}/todo?task={{uuid}}&date={{ db.selected_date }}">edit</a></td>
-<td>{% for tag in db.selected_day.todos[uuid].day_tags | sort %}<a href="{{db.prefix}}/tags?t_and={{tag|e}}">{{ tag }}</a> {% endfor %}</td>
-<td>{{ db.selected_day.todos[uuid].comment|e }}</td>
+<td>{{todo.task.current_title|e}}</td>
+<td>{{todo.effort}}</td>
+<td>{{todo.comment}}</td>
+</tr>
+{% endfor %}
+</table>
+</details>
+<table class="alternating">
+<tr>
+<th {% if sort=='title' %}class="desc"{% endif %}><a href="?sort=title">task</a></th>
+<th {% if sort=='chosen' %}class="desc"{% endif %}><a href="?sort=chosen">todo</a></th>
+<th {% if sort=='done' %}class="desc"{% endif %}><a href="?sort=done">done</a></th>
+<th {% if sort=='default_effort' %}class="desc"{% endif %}><a href="?sort=default_effort">effort</a></th>
+<th {% if sort=='importance' %}class="desc"{% endif %}><a href="?sort=importance">importance</a></th>
+<th>edit?</th><th>day tags</th>
+<th {% if sort=='comment' %}class="desc"{% endif %}><a href="?sort=comment">comment</a></th></tr>
+{% for row in task_rows %}
+<tr>
+<input name="t_uuid" value="{{ row.uuid }}" type="hidden" >
+<td><details><summary>] <a href="{{db.prefix}}/task?id={{ row.uuid }}&referer=day" />{{ row.task.current_title|e }}</a></summary>tags: {% for tag in row.task.tags | sort %}<a href="{{db.prefix}}/day?t_and={{tag|e}}">{{ tag }}</a> {% endfor %}</details></td>
+{% if row.todo %}
+<td class="checkbox"><input name="choose" type="checkbox" value="{{ row.uuid }}" checked></td>
+<td class="checkbox"><input name="done" type="checkbox" value="{{ row.uuid }}" {% if row.todo.done %}checked{% endif %}></td>
+<td class="number"><input class="day_effort_input" name="day_effort" type="number" step=0.1 size=8 value="{% if row.todo.day_effort is not none %}{{ row.todo.day_effort }}{% endif %}" placeholder={{ row.task.current_default_effort }} ></td>
+<td class="number"><input name="importance" type="number" step=0.1 size=8 value="{{row.todo.importance}}" ></td>
+<td><a href="{{db.prefix}}/todo?task={{row.uuid}}&date={{db.selected_date}}&referer=day">edit</a></td>
+<td>{% for tag in row.todo.day_tags | sort %}<a href="{{db.prefix}}/tags?t_and={{tag|e}}">{{ tag }}</a> {% endfor %}</td>
+<td>{{ row.todo.comment|e }}</td>
 {% else %}
-<td class="checkbox"><input name="choose" type="checkbox" value="{{ uuid }}"</td>
-<td class="checkbox"><input name="done" type="checkbox" value="{{ uuid }}"></td>
-<td class="number"><input name="day_weight" type="number" step=0.1 size=8 placeholder={{ t.current_default_weight }} ></td>
+<td class="checkbox"><input name="choose" type="checkbox" value="{{ row.uuid }}"</td>
+<td class="checkbox"><input name="done" type="checkbox" value="{{ row.uuid }}"></td>
+<td class="number"><input class="day_effort_input" name="day_effort" type="number" step=0.1 size=8 placeholder={{ row.task.current_default_effort }} ></td>
+<td class="number"><input name="importance" type="number" step=0.1 size=8 value="1.0" ></td>
+<td><a href="{{db.prefix}}/todo?task={{row.uuid}}&date={{db.selected_date}}&referer=day">edit</a></td>
 <td></td>
 <td></td>
 <td></td>
 {% endif %}
 </tr>
-{% endif %}
 {% endfor %}
 </table>
 <input type="submit" value="update">
 </form>
+{% include 'watch_form.html' %}
 <script>
-var day_weight_inputs = document.getElementsByClassName("day_weight_input");
-for (let i = 0; i < day_weight_inputs.length; i++) {
-    let input = day_weight_inputs[i];
+var day_effort_inputs = document.getElementsByClassName("day_effort_input");
+for (let i = 0; i < day_effort_inputs.length; i++) {
+    let input = day_effort_inputs[i];
     let button = document.createElement('button');
-    button.innerHTML = '+1×';
+    button.innerHTML = '+' + input.placeholder;
     button.onclick = function(event) {
         event.preventDefault();
         if (input.value) {
@@ -72,9 +93,9 @@ for (let i = 0; i < day_weight_inputs.length; i++) {
             input.value = parseFloat(input.placeholder);
         }
         input.value = parseFloat(input.value).toFixed(1);
+        formHasChanged = true; 
     };
     input.insertAdjacentElement('afterend', button);
 }
 </script>
-{% include 'watch_form.html' %}
 {% endblock %}