From f8118b1ed8615870b490566cf649d191f5877932 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 15 May 2024 10:18:51 +0200
Subject: [PATCH] Improve visual/textual calendar structuring.

---
 plomtask/days.py        | 11 +++++++++++
 templates/calendar.html | 31 ++++++++++++++++++++++++++++---
 templates/day.html      |  2 +-
 templates/todo.html     |  2 ++
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/plomtask/days.py b/plomtask/days.py
index 0e07bf7..5e97560 100644
--- a/plomtask/days.py
+++ b/plomtask/days.py
@@ -78,6 +78,17 @@ class Day(BaseModel[str]):
         assert isinstance(self.id_, str)
         return self.id_
 
+    @property
+    def first_of_month(self) -> bool:
+        """Return what month self.date is part of."""
+        assert isinstance(self.id_, str)
+        return self.id_[-2:] == '01'
+
+    @property
+    def month_name(self) -> str:
+        """Return what month self.date is part of."""
+        return self.datetime.strftime('%B')
+
     @property
     def weekday(self) -> str:
         """Return what weekday matches self.date."""
diff --git a/templates/calendar.html b/templates/calendar.html
index 3acdbc6..715131a 100644
--- a/templates/calendar.html
+++ b/templates/calendar.html
@@ -1,14 +1,39 @@
 {% extends 'base.html' %}
 
+{% block css %}
+tr.week_row td { height: 0.1em; background-color: black; padding: 0; margin: 0; }
+tr.month_row td { border: 0.1em solid black; text-align: center; }
+{% endblock %}
+
+
+
 {% block content %}
 <form action="calendar" method="GET">
 from <input name="start" value="{{start}}" />
 to <input name="end" value="{{end}}" />
 <input type="submit" value="OK" />
 </form>
-<ul>
+<table>
 {% for day in days %}
-<li><a href="day?date={{day.date}}">{{day.date}}</a> ({{day.weekday}}) {{day.comment|e}}
+
+{% if day.first_of_month %}
+<tr class="month_row">
+<td colspan=3>{{ day.month_name }}</td>
+</tr>
+{% endif %}
+
+{% if day.weekday == "Monday" %}
+<tr class="week_row">
+<td colspan=3></td>
+</tr>
+{% endif %}
+
+<tr>
+<td>{{day.weekday|truncate(2,True,'',0)}}</td>
+<td><a href="day?date={{day.date}}">{{day.date}}</a></td>
+<td>{{day.comment|e}}</td>
+</tr>
+
 {% endfor %}
-</ul>
+</table>
 {% endblock %}
diff --git a/templates/day.html b/templates/day.html
index f6e2265..a0823f3 100644
--- a/templates/day.html
+++ b/templates/day.html
@@ -149,7 +149,7 @@ add todo: <input name="new_todo" list="processes" autocomplete="off" />
 {% endif %}
 {% endfor %}
 
-<td><input name="new_todo" list="todos_for_{{condition.id_}}" /></td>
+<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>
diff --git a/templates/todo.html b/templates/todo.html
index f50b635..9395ada 100644
--- a/templates/todo.html
+++ b/templates/todo.html
@@ -1,5 +1,7 @@
 {% extends 'base.html' %}
 
+
+
 {% block content %}
 <h3>Todo: {{todo.process.title.newest|e}}</h3>
 <form action="todo?id={{todo.id_}}" method="POST">
-- 
2.30.2