home · contact · privacy
Improve accounting scripts.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 23 Feb 2024 04:13:04 +0000 (05:13 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 23 Feb 2024 04:13:04 +0000 (05:13 +0100)
ledger.py
todo.py
todo_templates/base.html
todo_templates/calendar.html
todo_templates/day_todos.html [new file with mode: 0644]
todo_templates/do_todos.html [deleted file]
todo_templates/pick_tasks.html [deleted file]
todo_templates/task.html
todo_templates/tasks.html
todo_templates/todo.html

index 958852aa56b0e747c1c2ad36f78f0d054f255310..d8b504a74398ce18315a4430b345ac7a1eaf417a 100755 (executable)
--- a/ledger.py
+++ b/ledger.py
@@ -4,6 +4,7 @@ from datetime import datetime, timedelta
 from urllib.parse import parse_qs, urlparse
 from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader 
 from plomlib import PlomDB, PlomException, run_server, PlomHandler 
+from os.path import split as path_split
 
 db_path = '/home/plom/org/ledger2024.dat'
 server_port = 8082
@@ -468,6 +469,7 @@ class LedgerDB(PlomDB):
         date_today = str(datetime.now())[:10]
         if copy:
             content.date = date_today 
+            index = -1
         elif -1 == index and (content is None or [] == content):
             content = Booking(date=date_today, validate=False)
         if 'textarea' == edit_mode and content:
@@ -476,7 +478,13 @@ class LedgerDB(PlomDB):
             for booking in self.bookings:
                 for transfer_line in booking.transfer_lines:
                     accounts.add(transfer_line.account)
-        return j2env.get_template('edit.html').render(content=content, index=index, error_msg=error_msg, edit_mode=edit_mode, accounts=accounts, adding=(copy or -1 == index))
+        return j2env.get_template('edit.html').render(
+                content=content,
+                index=index,
+                error_msg=error_msg,
+                edit_mode=edit_mode,
+                accounts=accounts,
+                adding=-1 == index)
 
     def move_up(self, index):
         return self.move(index, -1) 
@@ -519,14 +527,15 @@ class LedgerHandler(PlomHandler):
         db = LedgerDB(prefix, ignore_editable_exceptions=True)
         index = 0
         parsed_url = urlparse(self.path)
+        site = path_split(parsed_url.path)[1]
         for string in {'update', 'add', 'check', 'mirror', 'fill_sink', 'textarea', 'table', 'move_up', 'move_down', 'add_taxes', 'replace'}:
             if string in postvars.keys():
                 submit_button = string
                 break
-        if f'{prefix}/ledger' == parsed_url.path and submit_button in {'move_up', 'move_down'}:
+        if 'ledger' == site and submit_button in {'move_up', 'move_down'}:
             mover = getattr(db, submit_button)
             index = mover(int(postvars[submit_button][0]))
-        elif prefix + '/edit' == parsed_url.path:
+        elif 'edit' == site:
             index = int(postvars['index'][0])
             edit_mode = postvars['edit_mode'][0]
             validate = submit_button in {'update', 'add', 'copy', 'check'}
@@ -542,7 +551,6 @@ class LedgerHandler(PlomHandler):
                 booking = Booking.from_postvars(postvars, starts_at, validate)
             if submit_button in {'update', 'add'}:
                 if submit_button == 'update':
-                    # if 'textarea' == edit_mode and 'delete' == ''.join([l.text_line for l in lines]).strip():
                     if 'textarea' == edit_mode and delete:
                        del db.bookings[index]
                     # if not creating new Booking, and date unchanged, keep it in place 
@@ -571,7 +579,7 @@ class LedgerHandler(PlomHandler):
                 return
         db.write_db() 
         index = index if index >= 0 else len(db.bookings) - 1
-        self.redirect(prefix + f'/ledger#{index}')
+        self.redirect('ledger#{index}')
 
     def do_GET(self):
         self.try_do(self.forward_gets)
@@ -588,11 +596,12 @@ class LedgerHandler(PlomHandler):
             self.send_HTML(page)
             return
         parsed_url = urlparse(self.path)
+        site = path_split(parsed_url.path)[1]
         params = parse_qs(parsed_url.query)
-        if parsed_url.path == f'{prefix}/balance':
+        if site == 'balance':
             stop = params.get('until_after', [None])[0]
             page = db.balance_as_html(stop)
-        elif parsed_url.path == f'{prefix}/edit':
+        elif site == 'edit':
             index = params.get('i', [-1])[0]
             copy = params.get('copy', [0])[0]
             page = db.edit(int(index), copy=bool(copy))
diff --git a/todo.py b/todo.py
index 6c84ee0dbe8e5d7b05fe00d625ef3342b972d97a..c3551a44aefb9040cf406cf133628c08a7c60241 100644 (file)
--- a/todo.py
+++ b/todo.py
@@ -21,25 +21,22 @@ def today_date(with_time=False):
 
 class AttributeWithHistory:
 
-    def __init__(self, default_if_empty, history=None, then_date='2000-01-01', set_check=None, alt_get=None):
+    def __init__(self, default_if_empty, history=None, then_date='2000-01-01', set_check=None):
         self.default = default_if_empty
         self.then_date = then_date
         self.history = history if history else {}
         self.set_check = set_check
-        self.alt_get = alt_get 
 
     def set(self, value):
+        print("DEBUG set", value, "HAS SET CHECK?", self.set_check)
         if self.set_check:
+            print("DEBUG set CALLED SET CHECK")
             self.set_check(value)
         keys = sorted(self.history.keys())
         if len(self.history) == 0 or value != self.history[keys[-1]]:
             self.history[today_date(with_time=True)] = value
 
     def at(self, queried_date):
-        if self.alt_get:
-            ret = self.alt_get('at', queried_date)
-            if ret is not None:
-                return ret
         if 0 == len(self.history):
             return self.default
         ret = self.history[sorted(self.history.keys())[0]]
@@ -51,24 +48,52 @@ class AttributeWithHistory:
 
     @property
     def now(self):
-        if self.alt_get:
-            ret = self.alt_get('now')
-            if ret is not None:
-                return ret
         keys = sorted(self.history.keys())
         return self.default if 0 == len(self.history) else self.history[keys[-1]]
 
     @property
     def then(self):
-        if self.alt_get:
-            ret = self.alt_get('then')
-            if ret is not None:
-                return ret
         return self.at(self.then_date)
 
 
 
-class Task:
+class TaskLike:
+
+    def __init__(self, db, id_, comment):
+        self.db = db
+        self.id_ = id_
+        self.comment = comment
+        self.dependers = []
+
+    @property
+    def visible(self):
+        visible_by_and = 0 == len([tag for tag in self.db.tag_filter_and
+                                   if not tag in self.tags])
+        visible_by_not = 0 == len([tag for tag in self.db.tag_filter_not
+                                   if tag in self.tags])
+        return visible_by_and and visible_by_not
+
+    @property
+    def deps_depth(self):
+        if len(self.deps) == 0:
+            return 0
+        return 1 + max([d.deps_depth for d in self.deps])
+
+    @property
+    def deps_chain(self):
+        all_deps = set()
+        def add_deps(todo, all_deps):
+            for dep in todo.deps:
+                all_deps.add(dep)
+                add_deps(dep, all_deps)
+        add_deps(self, all_deps)
+        chain = list(all_deps)
+        chain.sort(key=lambda t: t.deps_depth)
+        return chain
+
+
+
+class Task(TaskLike):
 
     def __init__(self,
             db,
@@ -76,18 +101,13 @@ class Task:
             title_history=None,
             tags_history=None,
             default_effort_history=None,
-            subtask_ids_history=None,
+            dep_ids_history=None,
             comment=''):
-        self.db = db
-        self.id_ = id_
+        super().__init__(db, id_, comment)
         self.title = AttributeWithHistory('', title_history, self.db.selected_date)
         self.tags = AttributeWithHistory(set(), tags_history, self.db.selected_date)
-        self.default_effort = AttributeWithHistory(0.0, default_effort_history, self.db.selected_date, alt_get=self.subtasks_sum_maker())
-        self.subtask_ids = AttributeWithHistory(set(), subtask_ids_history, self.db.selected_date, set_check=self.subtask_loop_checker())
-        self.comment = comment
-
-        self.visible = True
-        self.dependers = [] 
+        self.default_effort = AttributeWithHistory(0.0, default_effort_history, self.db.selected_date)
+        self.dep_ids = AttributeWithHistory(set(), dep_ids_history, self.db.selected_date, set_check=self.dep_loop_checker())
 
     @classmethod
     def from_dict(cls, db, d, id_):
@@ -97,7 +117,7 @@ class Task:
                d['title_history'],
                {k: set(v) for k, v in d['tags_history'].items()},
                d['default_effort_history'],
-               {k: set(v) for k, v in d['subtasks_history'].items()},
+               {k: set(v) for k, v in d['deps_history'].items()},
                d['comment'])
         return t
 
@@ -106,58 +126,41 @@ class Task:
             'title_history': self.title.history,
             'default_effort_history': self.default_effort.history,
             'tags_history': {k: list(v) for k, v in self.tags.history.items()},
-            'subtasks_history': {k: list(v) for k, v in self.subtask_ids.history.items()},
+            'deps_history': {k: list(v) for k, v in self.dep_ids.history.items()},
             'comment': self.comment,
         }
 
     @property
-    def subtasks(self):
-        subtasks = []
-        for id_ in self.subtask_ids.now:
+    def deps(self):
+        deps = []
+        for id_ in self.dep_ids.now:
             if len(id_) == 0:
                 continue
-            subtasks += [self.db.tasks[id_]]
-        return subtasks
+            elif id_ not in self.db.tasks.keys():
+                raise PlomException(f'dep referenced on Task {self.id_} not found: {id_}')
+            deps += [self.db.tasks[id_]]
+        return deps
 
     @property
-    def subtask_depth(self):
-        def count_depth(task):
+    def deps_weight(self):
+        def count_weight(task):
             sub_count = 1
-            for subtask in task.subtasks:
-                sub_count += count_depth(subtask)
+            for dep in task.deps:
+                sub_count += count_weight(dep)
             return sub_count
-        return count_depth(self) 
+        return count_weight(self) 
 
-    def subtask_loop_checker(self):
-        def f(subtask_ids_now):
-            loop_msg = "can't set subtask, would create loop"
-            for id_ in subtask_ids_now:
+    def dep_loop_checker(self):
+        def f(dep_ids_now):
+            loop_msg = "can't set dep, would create loop"
+            for id_ in dep_ids_now:
                 if id_ == self.id_:
                     raise PlomException(loop_msg)
                 elif id_ in self.db.tasks.keys():
-                    subtask = self.db.tasks[id_]
-                    f(subtask.subtask_ids.now)
+                    dep = self.db.tasks[id_]
+                    f(dep.dep_ids.now)
         return f 
 
-    def subtasks_sum_maker(self):
-        def f(f_name, queried_date=None):
-            subtask_ids_to_check = getattr(self.subtask_ids, f_name)
-            if queried_date:
-                subtasks = [self.db.tasks[id_] for id_ in subtask_ids_to_check(queried_date)]
-            else:
-                subtasks = [self.db.tasks[id_] for id_ in subtask_ids_to_check]
-            if len(self.subtasks) > 0:
-                summe = 0
-                for subtask in self.subtasks:
-                    if queried_date:
-                        to_add = getattr(subtask.default_effort, f_name)
-                        summe += to_add(queried_date)
-                    else:
-                        summe += getattr(subtask.default_effort, f_name)
-                return summe
-            return None
-        return f
-
     def matches(self, search):
         if search is None:
             return False
@@ -165,6 +168,7 @@ class Task:
             return search in self.title.now or search in self.comment or search in '$'.join(self.tags.now)
 
 
+
 class Day:
 
     def __init__(self, db, date, comment=''):
@@ -194,7 +198,6 @@ class Day:
         s = 0
         for todo in [todo for todo in self.linked_todos.values()
                      if self.date in todo.efforts.keys()]:
-                     # and not todo.children]:
             day_effort = todo.efforts[self.date]
             if todo.done:
                 s += day_effort if day_effort else todo.task.default_effort.at(self.date)
@@ -206,8 +209,34 @@ class Day:
     def todos_sum(self):
         return self._todos_sum()
 
+    def sorted_todos(self, done, is_tree_shaped, sort_order, legal_keys):
+        todos = [t for t in self.linked_todos_as_list if t.visible and t.done == done]
+        reverse = False
+        sort_column = sort_order[:]
+        if sort_order and '-' == sort_order[0]:
+            reverse = True
+            sort_column = sort_order[1:]
+        if sort_column in legal_keys:
+            todos.sort(key=lambda t: getattr(t, sort_column))
+        if reverse:
+            todos.reverse()
+        if is_tree_shaped:
+            def walk_tree(todo, sorted_todos):
+                todo.deps = [t for t in sorted_todos if t in todo.deps]
+                for dep in [t for t in sorted_todos if t in todo.deps]:
+                    walk_tree(dep, sorted_todos)
+            if done:
+                trunk = [t for t in todos if len([td for td in t.dependers if td.done]) == 0]
+            else:
+                trunk = [t for t in todos if len(t.dependers) == 0]
+            for node in trunk:
+                walk_tree(node, todos)
+            todos = trunk 
+        return todos
+
+
 
-class Todo:
+class Todo(TaskLike):
 
     def __init__(self,
                  db,
@@ -219,17 +248,15 @@ class Todo:
                  importance=1.0,
                  efforts=None,
                  dep_ids=None):
-        self.id_ = id_
-        self.db = db 
+        super().__init__(db, id_, comment)
         self.task = task 
         self._done = done
         self.efforts = efforts if efforts else {}
-        self.comment = comment
         self.day_tags = day_tags if day_tags else set()
         self.importance = importance
-        self.dep_ids = dep_ids if dep_ids else [] 
-
-        self.dependers = [] 
+        self._dep_ids = dep_ids if dep_ids else [] 
+        self.already_listed = False
+        self.been_observed = False 
 
     @classmethod
     def from_dict(cls, db, d, id_):
@@ -253,11 +280,11 @@ class Todo:
                 'day_tags': list(self.day_tags),
                 'importance': self.importance,
                 'efforts': self.efforts,
-                'deps': self.dep_ids}
+                'deps': self._dep_ids}
 
     @property
     def title(self):
-        return self.task.title.at(self.earliest_date)
+        return self.task.title.at(self.db.selected_date)
 
     @property
     def dated_title(self):
@@ -265,11 +292,19 @@ class Todo:
 
     @property
     def deps(self):
-        return [self.db.todos[id_] for id_ in self.dep_ids]
+        return [self.db.todos[id_] for id_ in self._dep_ids]
 
     @deps.setter
     def deps(self, deps):
-        self.dep_ids = [dep.id_ for dep in deps]
+        self._dep_ids = [dep.id_ for dep in deps]
+        def f(deps):
+            loop_msg = "can't set dep, would create loop"
+            for dep in deps: 
+                if dep == self:
+                    raise PlomException(loop_msg)
+                else:
+                    f(dep.deps)
+        f(self.deps)
 
     @property
     def default_effort(self):
@@ -317,6 +352,20 @@ class Todo:
                     paths += [path + [depender]] 
         return paths
 
+    @property
+    def shortened_depender_paths(self):
+        new_paths = []
+        for path in self.depender_paths:
+            new_path = []
+            for i, step in enumerate(path):
+                next_step = None if len(path) <= i+1 else path[i+1]
+                for distinct_path in new_paths:
+                    if len(distinct_path) >= i+2 and distinct_path[i+1] == next_step:
+                        step = None
+                new_path += [step]
+            new_paths += [new_path]
+        return new_paths
+
     @property
     def all_days_effort(self):
         total = 0
@@ -349,6 +398,13 @@ class Todo:
     def day_effort(self):
         return self.efforts[self.db.selected_date]
 
+    @property
+    def effort_at_selected_date(self):
+        if self.db.selected_date in self.efforts.keys() and self.day_effort is not None:
+            return self.day_effort 
+        else:
+            return self.task.default_effort.then
+
     @property
     def day(self):
         return self.db.days[self.earliest_date]
@@ -367,20 +423,37 @@ class Todo:
     def latest_date(self):
         return self.sorted_effort_dates[-1]
 
+    @property
+    def has_dependers(self):
+        return len(self.dependers) > 0
+
+    @property
+    def has_deps(self):
+        return len(self.deps) > 0
+
+    @property
+    def sort_done(self):
+        return self.day_effort if self.day_effort else 0 
+
+    @property
+    def family_effort(self):
+        return self.effort_at_selected_date + self.dep_efforts
+
+    def observe(self):
+        self.been_observed = True
+        return '' 
+
+
 
 class TodoDB(PlomDB):
 
     def __init__(self,
             selected_date=None,
             tag_filter_and = None,
-            tag_filter_not = None,
-            hide_unchosen=False,
-            hide_done=False):
+            tag_filter_not = None):
         self.selected_date = selected_date if selected_date else today_date()
         self.tag_filter_and = tag_filter_and if tag_filter_and else []
         self.tag_filter_not = tag_filter_not if tag_filter_not else []
-        self.hide_unchosen = hide_unchosen
-        self.hide_done = hide_done
 
         self.days = {}
         self.tasks = {}
@@ -398,7 +471,7 @@ class TodoDB(PlomDB):
             for tag in t.tags.now:
                 self.t_tags.add(tag)
         for task in self.tasks.values():
-            for dep in task.subtasks:
+            for dep in task.deps:
                 dep.dependers += [task]
 
         for id_, todo_dict in d['todos'].items():
@@ -417,7 +490,7 @@ class TodoDB(PlomDB):
                     self.add_day(date)
                 self.days[date].linked_todos_as_list += [todo]
 
-        self.set_visibilities()
+        self.set_visibilities()
 
     def to_dict(self):
         d = {'tasks': {}, 'days': {}, 'todos': {}}
@@ -459,12 +532,12 @@ class TodoDB(PlomDB):
         self.tasks[id_] = t
         return t
 
-    def update_task(self, id_, title, default_effort, tags, subtask_ids, comment):
+    def update_task(self, id_, title, default_effort, tags, dep_ids, comment):
         task = self.tasks[id_] if id_ in self.tasks.keys() else self.add_task(id_)
         task.title.set(title)
         task.default_effort.set(default_effort)
         task.tags.set(tags)
-        task.subtask_ids.set(subtask_ids)
+        task.dep_ids.set(dep_ids)
         task.comment = comment 
         return task
 
@@ -475,7 +548,7 @@ class TodoDB(PlomDB):
         elif task and efforts:
             todo = Todo(self, id_, task, efforts=efforts)
             deps = []
-            for dep_task in task.subtasks:
+            for dep_task in task.deps:
                 # if Todo expects dependencies, adopt any compatibles found in DB.selected_date
                 # before creating new depended Todos
                 dep_todo = None
@@ -489,7 +562,8 @@ class TodoDB(PlomDB):
                                                link_into_day=link_into_day,
                                                adopt_if_possible=adopt_if_possible)
                 deps += [dep_todo]
-            todo.dep_ids = [dep.id_ for dep in deps]
+            # todo.dep_ids = [dep.id_ for dep in deps]
+            todo.deps = deps 
         self.todos[id_] = todo 
         if link_into_day:
             self.selected_day.linked_todos_as_list += [todo] 
@@ -527,7 +601,7 @@ class TodoDB(PlomDB):
         for date in dates_to_delete:
             self.delete_effort(todo, date, force=True)
         for depender in todo.dependers:
-            depender.dep_ids.remove(todo.id_)
+            depender._dep_ids.remove(todo.id_)
         del self.todos[id_]
 
     def delete_task(self, id_):
@@ -547,8 +621,20 @@ class TodoDB(PlomDB):
     def show_calendar(self, start_date_str, end_date_str):
         self.tag_filter_and = ['calendar']
         self.tag_filter_not = ['deleted']
-        self.set_visibilities()
-        start_date_obj, end_date_obj = self.get_limit_days_from_date_strings(start_date_str, end_date_str)
+
+        todays_date_obj = datetime.strptime(today_date(), DATE_FORMAT) 
+        yesterdays_date_obj = todays_date_obj - timedelta(1)
+        def get_day_limit_obj(index, day_limit_string):
+            date_obj = datetime.strptime(sorted(self.days.keys())[index], DATE_FORMAT)
+            if day_limit_string and len(day_limit_string) > 0:
+                if day_limit_string in {'today', 'yesterday'}:
+                    date_obj = todays_date_obj if day_limit_string == 'today' else yesterdays_date_obj
+                else:
+                    date_obj = datetime.strptime(day_limit_string, DATE_FORMAT)
+            return date_obj
+        start_date_obj = get_day_limit_obj(0, start_date_str)
+        end_date_obj = get_day_limit_obj(-1, end_date_str)
+
         days_to_show = {}
         for n in range(int((end_date_obj - start_date_obj).days) + 1):
             date_obj = start_date_obj + timedelta(n)
@@ -566,27 +652,28 @@ class TodoDB(PlomDB):
                 start_date=start_date_str,
                 end_date=end_date_str)
 
-    def show_do_todos(self, sort_order=None):
-        prev_date_str, next_date_str = self.neighbor_dates()
+    def show_day_todos(self, undone_sort_order=None, done_sort_order=None, is_tree_shaped=False):
+        legal_undone_sort_keys = {'title', 'sort_done', 'default_effort', 'importance'} 
+        legal_done_sort_keys = {'title', 'effort_at_selected_date', 'family_effort'} 
+
+        current_date = datetime.strptime(self.selected_date, DATE_FORMAT)
+        prev_date = current_date - timedelta(days=1)
+        prev_date_str = prev_date.strftime(DATE_FORMAT)
+        next_date = current_date + timedelta(days=1)
+        next_date_str = next_date.strftime(DATE_FORMAT)
+
         adoptable_past_todos = []
-        for todo in self.todos.values():
-            if todo.done\
-                    or (not todo.visible)\
-                    or todo.earliest_date >= self.selected_date:
-                continue
-            adoptable_past_todos += [todo] 
-        todos = [t for t in self.selected_day.linked_todos_as_list
-                 if t.visible]
-                 # and not t.deps]
-        if sort_order == 'title':
-            todos.sort(key=lambda t: t.task.title.then)
-        elif sort_order == 'done':
-            todos.sort(key=lambda t: t.day_effort if t.day_effort else t.default_effort if t.done else 0, reverse=True)
-        elif sort_order == 'default_effort':
-            todos.sort(key=lambda t: t.default_effort, reverse=True)
-        elif sort_order == 'importance':
-            todos.sort(key=lambda t: t.importance, reverse=True)
-        return j2env.get_template('do_todos.html').render(
+        for todo in [t for t in self.todos.values()
+                     if t.visible
+                     and (not t.done)
+                     and t.earliest_date < self.selected_date]:
+             adoptable_past_todos += [todo] 
+        undone_todos = self.selected_day.sorted_todos(False, is_tree_shaped, undone_sort_order,
+                                                      legal_undone_sort_keys)
+        done_todos = self.selected_day.sorted_todos(True, is_tree_shaped, done_sort_order,
+                                                    legal_done_sort_keys)
+
+        return j2env.get_template('day_todos.html').render(
                 day=self.selected_day,
                 tags=self.t_tags,
                 filter_and=self.tag_filter_and,
@@ -595,26 +682,21 @@ class TodoDB(PlomDB):
                 adoptable_past_todos=adoptable_past_todos,
                 next_date=next_date_str,
                 all_tasks=[t for t in self.tasks.values()],
-                todos=todos,
-                sort=sort_order,
-                hide_done=self.hide_done)
+                undone_todos=undone_todos,
+                done_todos=done_todos,
+                is_tree_shaped=is_tree_shaped,
+                undone_sort=undone_sort_order,
+                done_sort=done_sort_order)
 
-    def show_todo(self, id_, start_date, end_date):
+    def show_todo(self, id_):
         todo = self.todos[id_]
         filtered_tasks = [t for t in self.tasks.values()
                           if t != todo.task] 
         filtered_todos = [t for t in self.todos.values()
-                          if t != todo]
-
-        # if going into the past, only allow 3-day ranges 
-        start_day, end_day = self.get_limit_days_from_date_strings(start_date, end_date)
-        if start_day < datetime.now() - timedelta(days=2):
-            end_day = start_day + timedelta(days=3)
-            end_date = end_day.strftime(DATE_FORMAT)
-        legal_dates = []
-        for n in range(int((end_day - start_day).days) + 1):
-            day = start_day + timedelta(n)
-            legal_dates += [day.strftime(DATE_FORMAT)]
+                          if t != todo
+                          and t not in todo.deps]
+
+        legal_dates = list(todo.efforts.keys())
         date_filtered_todos = [] 
         for date in legal_dates:
             for filtered_todo in filtered_todos:
@@ -623,14 +705,25 @@ class TodoDB(PlomDB):
                 if date in filtered_todo.efforts.keys():
                     date_filtered_todos += [filtered_todo]
 
+        dep_slots = []
+        for dep in todo.task.deps:
+            dep_slots += [{'task': dep,
+                               'todos': [t for t in todo.deps if t.task == dep]}]
+
+        suggested_todos = {}
+        for dep in todo.task.deps:
+            suggested_todos[dep.id_] = [t for t in date_filtered_todos if t.task.id_ == dep.id_]
+        additional_deps = [t for t in todo.deps if not t.task in todo.task.deps]
+
         return j2env.get_template('todo.html').render(
                 tags=self.t_tags,
                 todo=todo,
                 filtered_todos=date_filtered_todos,
                 filtered_tasks=filtered_tasks,
-                dep_todos=todo.deps,
-                start_date=start_date,
-                end_date=end_date)
+                dep_slots=dep_slots,
+                suggested_todos=suggested_todos,
+                additional_deps=additional_deps,
+                dep_todos=todo.deps)
 
     def show_task(self, id_):
         task = self.tasks[id_] if id_ else self.add_task()
@@ -638,7 +731,8 @@ class TodoDB(PlomDB):
             task.default_effort.set(1.0)
         filtered_tasks = [t for t in self.tasks.values()
                           if t != task
-                          and (t not in task.subtasks)]
+                          and (t not in task.deps)]
+
         return j2env.get_template('task.html').render(
                 selected_date=self.selected_date,
                 tags=self.t_tags, 
@@ -649,12 +743,19 @@ class TodoDB(PlomDB):
         filtered_tasks = [] 
         for task in [t for t in self.tasks.values() if (not search) or t.matches(search)]:
             filtered_tasks += [task]
-        if sort_order == 'title':
+        reverse = False
+        sort_column = sort_order 
+        if sort_order and '-' == sort_order[0]:
+            reverse = True
+            sort_column = sort_order[1:]
+        if sort_column == 'title':
             filtered_tasks.sort(key=lambda t: t.title.now)
-        elif sort_order == 'default_effort':
-            filtered_tasks.sort(key=lambda t: t.default_effort.now, reverse=True)
-        elif sort_order == 'depth':
-            filtered_tasks.sort(key=lambda t: t.subtask_depth, reverse=True)
+        elif sort_column == 'default_effort':
+            filtered_tasks.sort(key=lambda t: t.default_effort.now)
+        elif sort_column == 'weight':
+            filtered_tasks.sort(key=lambda t: t.deps_weight)
+        if reverse:
+            filtered_tasks.reverse()
         return j2env.get_template('tasks.html').render(
                 sort=sort_order,
                 tasks=filtered_tasks,
@@ -663,90 +764,6 @@ class TodoDB(PlomDB):
                 filter_not=self.tag_filter_not,
                 search=search)
 
-    # def show_pick_tasks(self, search, hide_chosen_tasks, sort_order=None):
-    #     prev_date_str, next_date_str = self.neighbor_dates()
-
-    #     chosen_todos = self.selected_day.linked_todos_as_list
-
-    #     relevant_todos = []
-    #     for todo in self.todos.values():
-    #         if todo.done\
-    #                 or (not todo.visible)\
-    #                 or (not todo.matches(search))\
-    #                 or todo.earliest_date >= self.selected_date:
-    #             continue
-    #         relevant_todos += [todo] 
-
-    #     filtered_tasks = []
-    #     chosen_tasks = [todo.task for todo in self.selected_day.linked_todos_as_list]
-    #     for uuid, task in self.tasks.items():
-    #         if (not task.visible)\
-    #                 or (not task.matches(search))\
-    #                 or (hide_chosen_tasks and task in chosen_tasks):
-    #             continue
-    #         filtered_tasks += [task]
-
-    #     if sort_order == 'title':
-    #         chosen_todos.sort(key=lambda t: t.title)
-    #         relevant_todos.sort(key=lambda t: t.dated_title)
-    #         tasks.sort(key=lambda t: t.title.then)
-    #     elif sort_order == 'effort':
-    #         chosen_todos.sort(key=lambda t:
-    #                           t.day_effort if t.day_effort else (t.default_effort if t.done else 0),
-    #                           reverse=True)
-    #         relevant_todos.sort(key=lambda t: t.all_days_effort, reverse=True)
-    #         filtered_tasks.sort(key=lambda t: t.default_effort.then, reverse=True)
-
-    #     return j2env.get_template('pick_tasks.html').render(
-    #             sort=sort_order,
-    #             tags=self.t_tags,
-    #             chosen_todos=chosen_todos,
-    #             filter_and=self.tag_filter_and,
-    #             filter_not=self.tag_filter_not,
-    #             day=self.selected_day,
-    #             prev_date=prev_date_str,
-    #             next_date=next_date_str,
-    #             all_tasks=[t for t in self.tasks.values()],
-    #             filtered_tasks=filtered_tasks,
-    #             hide_chosen_tasks=hide_chosen_tasks,
-    #             relevant_todos=relevant_todos,
-    #             search=search)
-
-    # helpers
-
-    def set_visibilities(self):
-        for uuid, t in self.tasks.items():
-            t.visible = len([tag for tag in self.tag_filter_and if not tag in t.tags.now]) == 0\
-                    and len([tag for tag in self.tag_filter_not if tag in t.tags.now]) == 0\
-                    and ((not self.hide_unchosen) or uuid in self.selected_day.todos.keys())
-        for todo in self.todos.values():
-            todo.visible = len([tag for tag in self.tag_filter_and if not tag in todo.day_tags | todo.task.tags.now ]) == 0\
-                and len([tag for tag in self.tag_filter_not if tag in todo.day_tags | todo.task.tags.now ]) == 0\
-                and ((not self.hide_done) or (not todo.done))
-
-    def get_limit_days_from_date_strings(self, start_date_str, end_date_str):
-        todays_date_obj = datetime.strptime(today_date(), DATE_FORMAT) 
-        yesterdays_date_obj = todays_date_obj - timedelta(1)
-        def get_day_limit_obj(index, day_limit_string):
-            date_obj = datetime.strptime(sorted(self.days.keys())[index], DATE_FORMAT)
-            if day_limit_string and len(day_limit_string) > 0:
-                if day_limit_string in {'today', 'yesterday'}:
-                    date_obj = todays_date_obj if day_limit_string == 'today' else yesterdays_date_obj
-                else:
-                    date_obj = datetime.strptime(day_limit_string, DATE_FORMAT)
-            return date_obj
-        start_date_obj = get_day_limit_obj(0, start_date_str)
-        end_date_obj = get_day_limit_obj(-1, end_date_str)
-        return start_date_obj, end_date_obj
-
-    def neighbor_dates(self):
-        current_date = datetime.strptime(self.selected_date, DATE_FORMAT)
-        prev_date = current_date - timedelta(days=1)
-        prev_date_str = prev_date.strftime(DATE_FORMAT)
-        next_date = current_date + timedelta(days=1)
-        next_date_str = next_date.strftime(DATE_FORMAT)
-        return prev_date_str, next_date_str
-
 
 
 class ParamsParser:
@@ -755,19 +772,22 @@ class ParamsParser:
         self.params = parse_qs(parsed_url_query)
         self.cookie_db = cookie_db
 
-    def get(self, key, default=None):
-        boolean = bool == type(default) 
+    def get(self, key, default=None, as_bool=False):
+        boolean = bool == type(default) 
         param = self.params.get(key, [default])[0]
-        if boolean:
-            param = param != '0' 
+        if as_bool:
+            if param == '0':
+                param = False
+            elif param is not None:
+                param = True
         return param 
 
     def cookie_key_from_params_key(self, prefix, key):
         return f'{prefix}:{key}' if prefix else key
 
-    def get_cookied(self, key, default=None, prefix=None):
+    def get_cookied(self, key, default=None, prefix=None, as_bool=False):
         cookie_key = self.cookie_key_from_params_key(prefix, key) 
-        param = self.get(key, default)
+        param = self.get(key, default, as_bool)
         if param == '-':
             param = None
             if cookie_key in self.cookie_db.keys():
@@ -792,6 +812,7 @@ class ParamsParser:
         return params
 
 
+
 class PostvarsParser:
 
     def __init__(self, postvars):
@@ -925,49 +946,26 @@ class TodoHandler(PlomHandler):
                     raise PlomException('will not remove Task describing existing Todos')
                 if postvars.get('title', '')\
                         or postvars.get_all('tag', [])\
-                        or postvars.get_all('subtask', [])\
+                        or postvars.get_all('dep', [])\
                         or postvars.get('comment', ''):
                     raise PlomException('will not remove Task of preserve-worthy values')
                 db.delete_task(task_id)
             elif postvars.has('update'):
+                dep_ids = postvars.get_all('dep', [])
+                for id_ in [id_ for id_ in dep_ids if not id_ in db.tasks.keys()]:
+                    raise PlomException('submitted illegal dep ID')
                 task = db.update_task(
                         id_=task_id,
                         title=postvars.get('title', ''),
                         default_effort=postvars.get('default_effort', float_if_possible=True), 
                         tags=postvars.get_all('tag', []),
-                        subtask_ids=postvars.get_all('subtask', []),
+                        dep_ids=dep_ids,
                         comment=postvars.get('comment', ''))
                 if postvars.has('add_as_todo'):
                     db.add_todo(task=task, efforts={postvars.get('selected_date'): None})
             redir_params += [('id', task_id)]
 
-        # elif 'pick_tasks' == site:
-        #     redir_params += [('hide_chosen_tasks', int(postvars.has('hide_chosen_tasks')))]
-        #     if postvars.has('update'):
-        #         db.selected_date = postvars.get('date')
-        #         todos_to_shrink = []
-        #         todos_to_delete = []
-        #         for todo in db.selected_day.linked_todos_as_list:
-        #             if todo.visible and not todo.id_ in postvars.get_all('chosen_todo', []):
-        #                 if len(todo.comment) > 0\
-        #                         or len(todo.day_tags) > 0\
-        #                         or not todo.is_effort_removable(db.selected_date):
-        #                     raise PlomException('will not remove effort of preserve-worthy values')
-        #                 if len(todo.efforts) > 1:
-        #                     todos_to_shrink += [todo]
-        #                 else:
-        #                     todos_to_delete += [todo]
-        #         for todo in todos_to_shrink:
-        #             db.delete_effort(todo, db.selected_date)
-        #         for todo in todos_to_delete:
-        #             db.delete_todo(todo.id_)
-        #         for id_ in postvars.get_all('choose_task', []):
-        #             db.add_todo(task=db.tasks[id_], efforts={db.selected_date: None})
-        #         for id_ in postvars.get_all('choose_todo', []):
-        #             db.todos[id_].efforts[db.selected_date] = None
-
-        elif 'do_todos' == site:
-            redir_params += [('hide_done', int(postvars.has('hide_done')))]
+        elif 'day_todos' == site:
             if postvars.has('update'): 
                 db.selected_date = postvars.get('date') 
                 redir_params += [('date', db.selected_date)]
@@ -1025,47 +1023,40 @@ class TodoHandler(PlomHandler):
         params = ParamsParser(parsed_url.query, cookie_db)
 
         selected_date = tag_filter_and = tag_filter_not = None
-        hide_unchosen = hide_done = False
-        return_to = params.get('return_to', '')
-        if site in {'do_todos', 'calendar', 'task'}:
+        if site in {'day_todos', 'calendar', 'task'}:
             selected_date = params.get_cookied('date')
-        if site in {'do_todos', 'tasks'}:
+        if site in {'day_todos', 'tasks'}:
             tag_filter_and = params.get_cookied_chain('and_tag', prefix=site)
             tag_filter_not = params.get_cookied_chain('not_tag', prefix=site)
-        if 'do_todos' == site:
-            hide_done = params.get('hide_done', False) 
-        db = TodoDB(selected_date, tag_filter_and, tag_filter_not, hide_unchosen, hide_done)
+        db = TodoDB(selected_date, tag_filter_and, tag_filter_not)
         if site in {'todo', 'task'}:
             id_ = params.get('id')
-        if site in {'do_todos', 'tasks'}:
-            sort_order = params.get_cookied('sort', prefix=site)
-        if site in {'', 'calendar', 'todo'}:
-            start_date = params.get_cookied('start', prefix=site)
-            end_date = params.get_cookied('end', prefix=site)
         if 'reset_cookie' == site:
             cookie_db = {  # sensible defaults
-                # params.cookie_key_from_params_key('pick_tasks', 'and_tag'): ['default'],
-                # params.cookie_key_from_params_key('pick_tasks', 'not_tag'): ['ignore'],
+                params.cookie_key_from_params_key('day_todos', 'tree'): True,
                 params.cookie_key_from_params_key('todo', 'and_tag'): ['default'],
                 params.cookie_key_from_params_key('todo', 'not_tag'): ['ignore'],
                 params.cookie_key_from_params_key('todo', 'start'): 'yesterday',
                 params.cookie_key_from_params_key('todo', 'end'): 'today'}
             page = db.show_message('cookie unset!')
-        elif 'do_todos' == site:
-            page = db.show_do_todos(sort_order)
-        # elif 'pick_tasks' == site:
-        #     hide_chosen_tasks = params.get('hide_chosen_tasks', False)
-        #     page = db.show_pick_tasks(search, hide_chosen_tasks, sort_order)
+        elif 'day_todos' == site:
+            is_tree_shaped = params.get_cookied('tree', prefix=site, as_bool=True)
+            undone_sort_order = params.get_cookied('undone_sort', prefix=site)
+            done_sort_order = params.get_cookied('done_sort', prefix=site)
+            page = db.show_day_todos(undone_sort_order, done_sort_order, is_tree_shaped)
         elif site == 'todo':
-            page = db.show_todo(id_, start_date, end_date)
+            page = db.show_todo(id_)
         elif 'task' == site:
             page = db.show_task(id_)
         elif 'tasks' == site:
+            sort_order = params.get_cookied('sort', prefix=site)
             search = params.get('search', '')
             page = db.show_tasks(search, sort_order)
         elif 'add_task' == site:
             page = db.show_task(None)
         else:  # 'calendar' == site
+            start_date = params.get_cookied('start', prefix=site)
+            end_date = params.get_cookied('end', prefix=site)
             page = db.show_calendar(start_date, end_date)
 
         self.set_cookie(config['cookie_name'], config['cookie_path'], cookie_db)
index a2d05dae44fe04b362e7cea400df571372795336..1977c1fd952ca7591137865b98ea721937d5c0c8 100644 (file)
@@ -9,20 +9,21 @@ table.alternating tr:nth-child(odd) {
     background-color: white;
 }
 th, td { vertical-align: top; text-align: left}
+th.desc { background: linear-gradient(to bottom, white, grey); }
+th.asc { background: linear-gradient(to top, white, grey); }
 input[type="number"], td.number { text-align: right; }
 input[type="checkbox"] { height: 1.3em; width: 1.3em; }
-th.desc { background: linear-gradient(to bottom, white, grey); }
 input[type="submit"] { background-color: #cccccc; }
-button { background-color: #cccccc; }
 input[type="submit"].update { background-color: #aaffaa; }
 input[type="submit"].delete { background-color: #ff7777; }
 div.delete { float: right; }
+button { background-color: #cccccc; }
 {% block css %}
 {% endblock %}
 </style>
 <body>
-tasks: <a href="tasks">review</a> <a href="add_task">add</a> | day:
-<a href="do_todos">do todos</a>
+tasks: <a href="tasks">review</a> / <a href="add_task">add</a>
+| <a href="day_todos">day todos</a>
 | <a href="calendar">calendar</a>
 | <a href="reset_cookie">reset cookie</a>
 <hr />
index bc77ccdb0669aed74dd67be1fa6ff7828301958a..343019aa6387b8254a2bd3fce7ef39ec390bfec4 100644 (file)
@@ -1,13 +1,18 @@
 {% extends 'base.html' %}
 
+
+
 {% block css %}
 #filter { margin-bottom: 1em; }
 tr.month_row td { color: white; background-color: #555555; text-align: center; }
 tr.week_row td { height: 0.1em; background-color: black; }
 tr.day_row td { background-color: #cccccc; }
 span.selected_date { font-weight: bold; }
+span.todos_sum { white-space: pre; }
 {% endblock %}
 
+
+
 {% block content %}
 <h3>calendar</h3>
 <form action="calendar" method="POST">
@@ -36,9 +41,9 @@ to: <input name="end" {% if end_date %}value="{{ end_date }}"{% endif %} placeho
 <tr class="day_row">
 <td colspan=3>
 <span {% if date == selected_date %}class="selected_date"{% endif %}>
-<a href="do_todos?date={{date}}&hide_unchosen=1">{{ day.weekday }} {{ date }}</a>
+<a href="day_todos?date={{date}}">{{ day.weekday }} {{ date }}</a>
 </span>
-<span style="white-space: pre; ">|{{ '{:5.1f}'.format(day.todos_sum)}}|</span>
+<span class="todos_sum">|{{ '{:5.1f}'.format(day.todos_sum)}}|</span>
 {{ day.comment|e }}
 </td>
 </tr>
@@ -48,7 +53,7 @@ to: <input name="end" {% if end_date %}value="{{ end_date }}"{% endif %} placeho
 <tr>
 <td>
 {% if "cancelled" in todo.tags %}<s>{% endif %}
-[{% if todo.done and not "cancelled" in todo.tags %}✓{% else %} {% endif %}]
+{{ macros.doneness_string(todo, true) }}
 <a href="todo?id={{todo.id_}}">
 {% if "deadline" in todo.tags %}DEADLINE: {% endif %}
 {{ todo.title|e }}
diff --git a/todo_templates/day_todos.html b/todo_templates/day_todos.html
new file mode 100644 (file)
index 0000000..8cf87fb
--- /dev/null
@@ -0,0 +1,240 @@
+{% extends 'base.html' %}
+
+
+
+{% block css %}
+td.checkbox { text-align: center; }
+td { vertical-align: middle; }
+td button { padding: 0em; }
+th.centered { text-align: center; }
+ul { padding-left: 1.5em; margin: 0; }
+details > summary.todo {
+    list-style-type: '    ';
+}
+details > summary.has_dependers {
+    list-style-type: '[+]:';
+}
+details[open] > summary.has_dependers {
+    list-style-type: '[▼]:';
+}
+details > summary.has_deps::after {
+    content: ':[+]';
+}
+details[open] > summary.has_deps::after {
+    content: ':[▼]';
+}
+table.undone_todos tr.deps_undone {
+    background-color: #cccccc;
+}
+details.adoptables {
+    margin-bottom: 1em;
+}
+details.adoptables summary span {
+    background-color: #cccccc; 
+}
+table.undone_todos tr td {
+    border-bottom: 1px dotted black;
+}
+td.left { text-align: left; }
+td.unbreakable { white-space: nowrap; }
+{% endblock %}
+
+
+
+{% macro todo_title_expandable(todo, show_deps_doneness, ignore=0) %}
+{% if todo.has_dependers or todo.has_deps %}
+<details>
+<summary class="todo {% if todo.has_dependers %}has_dependers{% endif %} {% if todo.has_deps %}has_deps{% endif %}">
+{% else %}
+&nbsp;&nbsp;&nbsp;&nbsp;
+{% endif %}
+<a href="todo?id={{todo.id_}}&return_to=day_todos">{{todo.title|e}}</a>
+{% if todo.has_dependers or todo.has_deps %}
+</summary>
+{% if todo.has_dependers %}
+dependers:
+<ul>
+{% for path in todo.depender_paths %}
+<li>{% for depender_todo in path %}<a href="todo?id={{depender_todo.id_}}&return_to=day_todos">{{ depender_todo.title|e }}</a>{% if not loop.last %}:{% endif %}{% endfor %}
+{% endfor %}
+</ul>
+{% endif %}
+{% if todo.has_deps %}
+depends on:
+<ul>
+{% for dep_todo in todo.deps %}
+<li>
+{% if show_deps_doneness == true %}{{ macros.doneness_string(dep_todo) }}{% endif %}
+<a href="todo?id={{dep_todo.id_}}&return_to=day_todos">{{ dep_todo.title|e }}</a>{% if dep_todo.has_deps %}:+{% endif %}
+{% endfor %}
+</ul>
+{% endif %}
+</details>
+{% endif %}
+{% endmacro %}
+
+
+
+{% macro todo_title_as_tree_node(todo, indent) %}
+{% for i in range(indent-1) %}&nbsp; &nbsp;{% endfor %}
+{% if indent>0 %}&nbsp;+{% endif %}
+{% if todo.been_observed %}({% endif %}<a href="todo?id={{todo.id_}}&return_to=day_todos">{{todo.title}}</a>{% if todo.been_observed %}){% endif %}
+{% endmacro %}
+
+
+
+{% macro draw_undone_todo_row(todo, title_drawer, indent_or_doneness) %}
+<tr {% if todo.deps_done == false %}class="deps_undone"{% endif %}>
+{% if todo.already_listed %}
+<td class="checkbox"><input type="checkbox" disabled /></td>
+<td class="number left"><input type="number" value="{{todo.day_effort}}" size=7 disabled /></td>
+<td class="number"><input type="number" value="{{todo.importance}}" size=7 disabled /></td>
+<td>
+{{ title_drawer(todo, indent_or_doneness ) }}
+</td>
+<td><input value="{{todo.comment|e}}" size=100 disabled /></td>
+{% else %}
+<input name="todo_id" value="{{todo.id_}}" type="hidden" >
+<td class="checkbox">
+<input name="done" type="checkbox" value="{{todo.id_}}" {% if todo.done %}checked{% endif %} {% if todo.deps_done == false %}disabled{% endif %}>
+</td>
+<td class="number unbreakable">
+<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)}} >
+</td>
+<td class="number">
+<input name="importance" type="number" step=0.1 size=7 value={{todo.importance}} } >
+</td>
+<td>
+{{ title_drawer(todo, indent_or_doneness) }}
+</td>
+<td>
+<input name="effort_comment" type="text" size=100 value="{{todo.comment|e}}" />
+</td>
+{% endif %}
+</tr>
+{% endmacro %}
+
+
+
+{% macro draw_done_todo_row(todo, title_drawer, indent) %}
+<tr>
+<td class="number">{{ '{:4.1f}'.format(todo.effort_at_selected_date) }}</td>
+<td class="number">{{ '{:4.1f}'.format(todo.effort_at_selected_date + todo.dep_efforts) }}</td>
+<td>
+{{ title_drawer(todo, indent) }}
+</td>
+</td>
+</td>
+<td>{{ todo.comment }}</td>
+</tr>
+{% endmacro %}
+
+
+
+{% macro draw_todo_rows(todos, is_tree_shaped, todo_row_drawer, indent, show_deps_doneness=false) %}
+{% for todo in todos %}
+{% if is_tree_shaped %}
+{{ todo_row_drawer(todo, todo_title_as_tree_node, indent) }}
+{% if not todo.been_observed and todo.deps %}
+{{ draw_todo_rows(todo.deps, is_tree_shaped, todo_row_drawer, indent+1) }}
+{% endif %}
+{% else %}
+{{ todo_row_drawer(todo, todo_title_expandable, show_deps_doneness) }}
+{% endif %}
+{{ todo.observe() }}
+{% endfor %}
+{% endmacro %}
+
+
+
+{% block content %}
+<h3>day todos</h3>
+
+<form id="form_to_watch" action="day_todos" method="POST">
+{% include 'tagfilters.html' %}
+<br />
+<input id="filter_button" type="submit" name="filter" value="filter" />
+<p>
+| <a href="day_todos?date={{prev_date}}">prev</a> | {{day.date}} | <a href="day_todos?date={{next_date}}">next</a> | 
+comment: <input name="day_comment" value="{{day.comment|e}}">
+<input class="update" type="submit" name="update" value="update">
+<input type="hidden" name="date" value="{{day.date}}" />
+| show as {% if is_tree_shaped %}<a href="?tree=0">flat</a>|<b>tree</b>{% else %}<b>flat</b>|<a href="?tree=1">tree</a>{% endif %}
+</p>
+
+<h3>undone</h3>
+<p>
+task quick-add: <input name="choose_task" size=50 list="tasks" autocomplete="off">
+don't adopt, make new: <input type="checkbox" name="dont_adopt" />
+</p>
+{{ macros.datalist_tasks(all_tasks, with_weight=true) }}
+
+{% if adoptable_past_todos %}
+<details class="adoptables">
+<summary><span>there are adoptable/unfinished past todos ({{adoptable_past_todos|count}})</span></summary>
+<table class="alternating">
+<tr>
+<th>adopt?</th><th>date</th><th>title</th><th>comment</th>
+</tr
+{% for todo in adoptable_past_todos %}
+<tr>
+<td class="checkbox"><input name="choose_todo" type="checkbox" value="{{todo.id_}}"></td>
+<td>{{todo.earliest_date}}</td>
+<td><a href="todo?id={{todo.id_}}">{{todo.title|e}}</a></td>
+<td>{{todo.comment|e}}</td>
+</tr>
+{% endfor %}
+</table>
+</details>
+{% endif %}
+
+{% if undone_todos %} 
+<table class="undone_todos">
+<tr>
+{{ macros.sort_head(undone_sort, "sort_done", "done", "undone_sort") }}
+{{ macros.sort_head(undone_sort, "default_effort", "effort", "undone_sort") }}
+{{ macros.sort_head(undone_sort, "importance", "importance", "undone_sort") }}
+{{ macros.sort_head(undone_sort, "title", "todo", "undone_sort") }}
+<th>comment</th>
+</tr>
+{{ draw_todo_rows(undone_todos, is_tree_shaped, draw_undone_todo_row, 0, show_deps_doneness=true) }}
+{% endif %}
+
+</table>
+<input id="update_button" class="update" type="submit" name="update" value="update">
+</form>
+
+{% if done_todos %}
+<h3>done</h3>
+<table class="alternating">
+<tr>
+{{ macros.sort_head(done_sort, "effort_at_selected_date", "single<br />effort", "done_sort") }}
+{{ macros.sort_head(done_sort, "family_effort", "family<br />effort", "done_sort") }}
+{{ macros.sort_head(done_sort, "title", "todo", "done_sort") }}
+<th>comment</th>
+</tr>
+{{ draw_todo_rows(done_todos, is_tree_shaped, draw_done_todo_row, 0) }}
+</table>
+{% endif %}
+
+{% include 'watch_form.html' %}
+<script>
+var effort_inputs = document.getElementsByClassName("effort_input");
+for (let i = 0; i < effort_inputs.length; i++) {
+    let input = effort_inputs[i];
+    let button = document.createElement('button');
+    button.innerHTML = '+' + parseFloat(input.placeholder).toFixed(1);
+    button.onclick = function(event) {
+        event.preventDefault();
+        if (input.value) {
+            input.value = parseFloat(input.value) + parseFloat(input.placeholder);
+        } else {
+            input.value = parseFloat(input.placeholder);
+        }
+        input.value = parseFloat(input.value).toFixed(1);
+        changes_to_commit = true; 
+    };
+    input.insertAdjacentElement('afterend', button);
+}
+</script>
+{% endblock %}
diff --git a/todo_templates/do_todos.html b/todo_templates/do_todos.html
deleted file mode 100644 (file)
index 25211f0..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-{% extends 'base.html' %}
-
-{% block css %}
-td.number, td.checkbox { text-align: center; }
-td { vertical-align: middle; }
-td button { padding: 0em; }
-th.centered { text-align: center; }
-ul { margin: 0; }
-details > summary {
-    list-style-type: none;
-}
-details > summary.has_dependers {
-    list-style-type: '▶';
-}
-details[open] > summary.has_dependers {
-    list-style-type: '▼';
-}
-details > summary.has_deps::after {
-    content: '▶';
-}
-details[open] > summary.has_deps::after {
-    content: '▼';
-}
-{% endblock %}
-
-{% block content %}
-<h3>do todos</h3>
-
-<form id="form_to_watch" action="do_todos" method="POST">
-{% include 'tagfilters.html' %}
-<br />
-<input name="hide_done" type="checkbox" {% if hide_done %}checked{% endif %} /> hide done
-<input id="filter_button" type="submit" name="filter" value="filter" />
-<p>
-| <a href="do_todos?date={{prev_date}}">prev</a> | {{day.date}} | <a href="do_todos?date={{next_date}}">next</a> | 
-comment: <input name="day_comment" value="{{day.comment|e}}">
-<input class="update" type="submit" name="update" value="update">
-<input type="hidden" name="date" value="{{day.date}}" />
-</p>
-
-<p>
-task quick-add: <input name="choose_task" size=50 list="tasks" autocomplete="off">
-don't adopt, make new: <input type="checkbox" name="dont_adopt" />
-</p>
-<datalist id="tasks">
-{% for task in all_tasks %}
-<option value="{{task.id_}}">({{task.subtask_depth}}) {{task.title.now}}</option>
-{% endfor %}
-</datalist>
-
-{% if adoptable_past_todos %}
-<p>
-<details>
-<summary>
-there are adoptable/unfinished past todos ({{adoptable_past_todos|count}})
-</summary>
-<table class="alternating">
-<tr>
-<th>adopt?</th><th>date</th><th>title</th><th>comment</th>
-</tr
-{% for todo in adoptable_past_todos %}
-<tr>
-<td class="checkbox"><input name="choose_todo" type="checkbox" value="{{todo.id_}}"></td>
-<td>{{todo.earliest_date}}</td>
-<td><a href="todo?id={{todo.id_}}">{{todo.title|e}}</a></td>
-<td>{{todo.comment|e}}</td>
-</tr>
-{% endfor %}
-</table>
-</details>
-</p>
-{% endif %}
-
-<table class="alternating">
-<tr>
-<th {% if sort=='done' %}class="desc"{% endif %}>
-<a href="?sort=done">done</a>
-</th>
-<th class="centered{% if sort=='default_effort' %} 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 {% if sort=='title' %}class="desc"{% endif %}>
-<a href="?sort=title">todo</a>
-</th>
-<th>comment</th>
-</tr>
-
-{% for todo in todos %}
-<tr>
-<input name="todo_id" value="{{todo.id_}}" type="hidden" >
-<td class="checkbox">
-<input name="done" type="checkbox" value="{{todo.id_}}" {% if todo.done %}checked{% endif %} {% if todo.deps_done == false %}disabled{% endif %}>
-</td>
-<td class="number">
-<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)}} >
-</td>
-<td class="number">
-<input name="importance" type="number" step=0.1 size=7 value={{todo.importance}} } >
-</td>
-<td>
-{% if todo.dependers|length > 0 or todo.deps|length > 0 %}
-<details>
-<summary class="{% if todo.dependers|length > 0 %}has_dependers{% endif %} {% if todo.deps|length > 0 %}has_deps{% endif %}">
-{% endif %}
-<a href="todo?id={{todo.id_}}&return_to=do_todos">{{todo.title|e}}</a>
-{% if todo.dependers|length > 0 or todo.deps|length > 0 %}
-</summary>
-{% if todo.dependers|length > 0 %}
-dependers:
-<ul>
-{% for path in todo.depender_paths %}
-<li>{% for depender_todo in path %}<a href="todo?id={{depender_todo.id_}}&return_to=do_todos">{{ depender_todo.title|e }}</a> ▶ {% endfor %}…
-{% endfor %}
-</ul>
-{% endif %}
-{% if todo.deps|length > 0 %}
-depends on:
-<ul>
-{% for dep_todo in todo.deps %}
-<li>[{% if dep_todo.done %}✓{% else %} {% endif %}] <a href="todo?id={{dep_todo.id_}}&return_to=do_todos">{{ dep_todo.title|e }}</a>{% if dep_todo.deps|length > 0 %} ▶{% endif %}
-{% endfor %}
-</ul>
-{% endif %}
-</details>
-{% endif %}
-</td>
-<td>
-<input name="effort_comment" type="text" size=100 value="{{todo.comment|e}}" />
-</td>
-</tr>
-{% endfor %}
-
-</table>
-<input id="update_button" class="update" type="submit" name="update" value="update">
-</form>
-
-{% include 'watch_form.html' %}
-<script>
-mere_filter_inputs = mere_filter_inputs.concat(['hide_done']);
-var effort_inputs = document.getElementsByClassName("effort_input");
-for (let i = 0; i < effort_inputs.length; i++) {
-    let input = effort_inputs[i];
-    let button = document.createElement('button');
-    button.innerHTML = '+' + parseFloat(input.placeholder).toFixed(1);
-    button.onclick = function(event) {
-        event.preventDefault();
-        if (input.value) {
-            input.value = parseFloat(input.value) + parseFloat(input.placeholder);
-        } else {
-            input.value = parseFloat(input.placeholder);
-        }
-        input.value = parseFloat(input.value).toFixed(1);
-        changes_to_commit = true; 
-    };
-    input.insertAdjacentElement('afterend', button);
-}
-</script>
-{% endblock %}
diff --git a/todo_templates/pick_tasks.html b/todo_templates/pick_tasks.html
deleted file mode 100644 (file)
index 28919df..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-{% extends 'base.html' %}
-
-{% block css %}
-#pick_upper, #pick_lower { margin-right: 1em; }
-{% endblock %}
-
-{% block content %}
-<h3>pick todos for day</h3>
-
-<form id="form_to_watch" action="pick_tasks" method="POST">
-
-<p>
-<a href="pick_tasks?date={{prev_date}}">prev</a> | {{day.date}} | <a href="pick_tasks?date={{next_date}}">next</a> | {{day.comment}}
-</p>
-
-<input type="hidden" name="date" value="{{day.date}}" />
-<input class="update" id="pick_upper" name="update" type="submit" value="pick" />
-<input type="hidden" name="search" value="{{search|e}}" />
-<table>
-
-<tr>
-<th colspan=5>task quick-add: <input name="choose_task" size=50 list="tasks"></th>
-</tr>
-<datalist id="tasks">
-{% for task in all_tasks %}
-<option value="{{task.id_}}">{{task.title.now}}</option>
-{% endfor %}
-</datalist>
-
-<tr>
-<th>do</th>
-<th {% if sort=='effort' %}class="desc"{% endif %}>
-<a href="?sort=effort">effort</a>
-</th>
-<th {% if sort=='title' %}class="desc"{% endif %}>
-<a href="?sort=title">what</a>
-</th>
-<th>comment</th>
-</tr>
-
-{% for todo in chosen_todos %}
-<tr>
-<td class="checkbox">
-<input name="chosen_todo" {% if todo.done or todo.day_effort %}class="protected"{% endif %} type="checkbox" value="{{todo.id_}}" checked>
-</td>
-<td class="number">
-{% if todo.day_effort %}{{todo.day_effort}}&nbsp;{% else %}({{todo.default_effort}}){% endif %}{% if todo.done and not "cancelled" in todo.contemporary_tags%}✓{% else %}&nbsp;{% endif %}
-</td>
-<td>
-<a href="todo?id={{todo.id_}}&return_to=pick_tasks">
-{% if "cancelled" in todo.tags.now %}<s>{% endif %}
-{{todo.path|e}}{{todo.title|e}}
-{%if "cancelled" in todo.tags.now %}</s>{% endif %}
-</a>
-</td>
-<td>
-{{todo.comment|e}}
-</td>
-</tr>
-{% endfor %}
-
-<tr>
-<th colspan=4>earlier todos to continue</th>
-</tr>
-
-{% for todo in relevant_todos %}
-<tr>
-<td class="checkbox">
-<input name="choose_todo" type="checkbox" value="{{todo.id_}}">
-</td>
-<td class="number">
-{{todo.all_days_effort}}/{{todo.default_effort}}
-</td>
-<td>
-<a href="todo?id={{todo.id_}}">{{todo.dated_title|e}}</a>
-</td>
-<td>
-{{todo.comment|e}}
-</td>
-</tr>
-{% endfor %}
-
-<tr>
-<th colspan=4>tasks</th>
-</tr>
-
-{% for task in filtered_tasks %}
-<tr>
-<td class="checkbox">
-<input name="choose_task" type="checkbox" value="{{task.id_}}">
-</td>
-<td class="number">
-({{task.default_effort.then}})&nbsp;
-</td>
-<td>
-<a href="task?id={{ task.id_ }}&return_to=pick_tasks" />{{ task.title.then|e }}</a>
-</td>
-<td>
-{{task.comment|e}}
-</td>
-</tr>
-{% endfor %}
-
-</table>
-<input id="update_button" class="update" id="pick_lower" name="update" type="submit" value="pick" />
-<br />
-{% include 'tagfilters.html' %}
-<br />
-<input name="hide_chosen_tasks" type="checkbox" {% if hide_chosen_tasks %}checked{% endif %} /> hide chosen tasks<br />
-search: <input name="search" value="{{search|e}}" />
-<input id="filter_button" type="submit" name="filter" value="filter" />
-</form>
-
-{% include 'watch_form.html' %}
-<script>
-function make_selectables_toggler(neighbor_id, input_name) {
-    var neighbor = document.getElementById(neighbor_id);
-    var button = document.createElement('button');
-    button.textContent = 'toggle selectables';
-    button.onclick = function(event) {
-        event.preventDefault();
-        let checkboxes = document.getElementsByName(input_name);
-        for (let i = 0; i < checkboxes.length; i++) {
-            if (checkboxes[i].classList.contains('protected')) { 
-                continue;      
-       }
-            checkboxes[i].click();
-            changes_to_comit = true;
-        }
-    }
-    neighbor.insertAdjacentElement('afterend', button);
-}
-make_selectables_toggler('pick_upper', 'chosen_todo');
-make_selectables_toggler('pick_lower', 'choose_task');
-</script>
-{% endblock %}
index 7284f1bdc7218f0f85c54f5a6c5d94a6b4c92b84..c26d33a9d8d30d7b4c8efebe938b1aed86bc2b4d 100644 (file)
@@ -1,11 +1,31 @@
 {% extends 'base.html' %}
 
+
+
 {% block css %}
 tr.toplevel th { padding-right: 1em; }
 tr.toplevel td, tr.toplevel th { padding-top: 1em; }
 tr.lowlevel td, tr.lowlevel th { padding-top: 0em; }
 {% endblock %}
 
+
+
+{% macro draw_task(task) %}
+<a href="task?id={{task.id_}}">{{task.title.now}}</a>
+{% endmacro %}
+
+
+
+{% macro task_with_deps(task, indent) %}
+{% for i in range(indent) %}&nbsp;&nbsp;{% if loop.last %}+{% endif %}{% endfor %}
+{{ draw_task(task) }}<br />
+{% for task in task.deps %}
+{{ task_with_deps(task, indent+1) }}
+{% endfor %}
+{% endmacro %}
+
+
+
 {% block content %}
 <h3>edit task</h3>
 
@@ -44,9 +64,6 @@ tr.lowlevel td, tr.lowlevel th { padding-top: 0em; }
 <tr class="toplevel">
 <th>default effort</th>
 <td class="input">
-{% if task.subtasks %}
-{{ task.default_effort.now }}
-{% else %}
 <input type="number" name="default_effort" value="{{ task.default_effort.now }}" step=0.1 size=8 required />
 <details>
 <summary>history</summary>
@@ -56,7 +73,6 @@ tr.lowlevel td, tr.lowlevel th { padding-top: 0em; }
 {% endfor %}
 </ul>
 </details>
-{% endif %}
 </td>
 </tr>
 
@@ -75,45 +91,67 @@ add: {{ macros.tagselection(submit_name='tag', selected_tags=task.tags.now, all_
 </td>
 </tr>
 
-{% if task.parents %}
+{% if task.dependers %}
 <tr class="toplevel">
-<th>parents</th>
+<th>dependers</th>
 <td>
 <ul>
-{% for parent in task.parents %}
+{% for parent in task.dependers %}
 <li><a href="task?id={{parent.id_}}">{{parent.title.now}}</a>
 {% endfor %}
 </ul>
 </td>
 </tr>
 {% endif %}
-    
+
 <tr class="toplevel">
 <th>children</th>
 <td>
-{% if task.subtasks %}
+{% if task.deps %}
 <table>
-{% for subtask in task.subtasks %}
+{% for dep in task.deps %}
 <tr class="lowlevel">
 <td>
-<input name="subtask" type="checkbox" value="{{subtask.id_}}" checked/>
+<input name="dep" type="checkbox" value="{{dep.id_}}" checked/>
 </td>
 <td>
-<a href="task?id={{subtask.id_}}">{{subtask.title.now}}</a>
+{% if dep.deps %}
+<details>
+<summary>
+{% endif %}
+{{ draw_task(dep)}}
+{% if dep.deps %}
+</summary>
+{% for s in dep.deps %}
+{{ task_with_deps(s, 1) }}
+{% endfor %}
+</details>
+{% endif %}
 </td>
 </tr>
 {% endfor %}
 </table>
 {% endif %}
-<br />
-add: <input name="subtask" list="tasks" />
+add: <input name="dep" list="tasks" autocomplete="off" />
 </td>
 </tr>
-<datalist id="tasks">
-{% for subtask in filtered_tasks %}
-<option value="{{subtask.id_}}">{{subtask.title.now}}</option>
+{{ macros.datalist_tasks(filtered_tasks) }}
+
+{% if task.deps %}
+<tr class="toplevel">
+<th>as chain</th>
+<td>
+<table>
+{% for dep in task.deps_chain %}
+<tr class="lowlevel">
+<td class="number">{{dep.deps_depth}}</td>
+<td><a href="task?id={{ dep.id_ }}">{{dep.title.now}}</a></td>
+</tr>
 {% endfor %}
-</datalist>
+</table>
+</td>
+</tr>
+{% endif %}
 
 </table>
 <input id="update_button" class="update" type="submit" name="update" value="update" />
index 90f43585e1b956f8be0562e21b8398e5450746dd..cd5ef0ff7c7a69247ae415b3d9cf24bdfe64af81 100644 (file)
@@ -21,15 +21,9 @@ match: <input name="search" value="{{search|e}}" />
 
 <table class="alternating">
 <tr>
-<th class="centered{% if sort=='default_effort' %} desc{% endif %}">
-<a href="?sort=default_effort">effort</a>
-</th>
-<th {% if sort=='depth' %}class ="desc"{% endif %}>
-<a href="?sort=depth">depth</a>
-</th>
-<th {% if sort=='title' %}class="desc"{% endif %}>
-<a href="?sort=title">todo</a>
-</th>
+{{ macros.sort_head(sort, "default_effort", "effort") }}
+{{ macros.sort_head(sort, "weight", "weight") }}
+{{ macros.sort_head(sort, "title", "task") }}
 <th>tags</th>
 </tr>
 {% for t in tasks %}
@@ -39,7 +33,7 @@ match: <input name="search" value="{{search|e}}" />
 {{ '{:5.1f}'.format(t.default_effort.now) }}
 </td>
 <td class="number">
-{{ '{:5.1f}'.format(t.subtask_depth) }}
+{{ '{:5.1f}'.format(t.subtask_weight) }}
 </td>
 <td>
 <a href="task?id={{ t.id_ }}" />{{ t.title.now|e }}</a></td>
index 88fa72b2e0ec6fc9afb0abd7b8f89b2ab7b45e70..5aaf8a0bd71165ef5b36aeeb50cbe728f44d2f0b 100644 (file)
@@ -1,12 +1,69 @@
 {% extends 'base.html' %}
 
+
+
 {% block css %}
 tr.toplevel th { padding-right: 1em; }
 td.center { text-align: center; }
 tr.toplevel td, tr.toplevel th { padding-top: 1em; }
 tr.lowlevel td, tr.lowlevel th { padding-top: 0em; }
+tr.grey td { background-color: #cccccc; }
 {% endblock %}
 
+
+
+{% macro draw_todo(todo) %}<a href="?id={{todo.id_}}">{{todo.title}}</a>{% if todo.comment %}({{todo.comment|e}}){% endif %}{% endmacro %}
+
+
+
+{% macro task_with_deps(task, indent) %}
+{% for i in range(indent) %}&nbsp;&nbsp;{% endfor %}+ 
+({{task.title.then}})<br />
+{% for t in task.deps %}
+{{ task_with_deps(t, indent+1) }}
+{% endfor %}
+{% endmacro %}
+
+
+
+{% macro todo_with_deps(todo, indent) %}
+{% for i in range(indent) %}&nbsp;&nbsp;&nbsp;{% endfor %}{{ macros.doneness_string(todo) }} {{ draw_todo(todo) }}<br />
+{% for dep in todo.deps %}
+{% if dep.been_observed %}
+{% for i in range(indent+1) %}&nbsp;&nbsp;&nbsp;{% endfor %}{{ macros.doneness_string(dep) }} ({{ draw_todo(dep) }})<br />
+{% else %}
+{{ todo_with_deps(dep, indent+1) }}
+{% endif %}
+{% endfor %}
+{{ todo.observe() }}
+{% endmacro %}
+
+
+
+{% macro draw_deps(deps) %}
+{% for t in deps %}
+<tr class="lowlevel">
+<td><input name="adopt_dep" type="checkbox" value="{{t.id_}}" checked/></td>
+<td>{{ macros.doneness_string(t) }}</td>
+<td>
+{% if t.deps and not t.been_observed %}
+<details>
+<summary>{{ draw_todo(t) }}</summary>
+{% for dep in t.deps %}
+{{ todo_with_deps(dep, 0) }}
+{% endfor %}
+</details>
+{% else %}
+{{ draw_todo(t) }}
+{% endif %}
+</td>
+{{ t.observe() }}
+</tr>
+{% endfor %}
+{% endmacro %}
+
+
+
 {% block content %}
 <h3>edit todo</h3>
 
@@ -77,9 +134,8 @@ done<br />
 <tr class="toplevel">
 <th>tags</th>
 <td colspan=2>
-new: <input name="tag" value="" size=15 >
+new: {{ macros.tagselection(submit_name='tag', selected_tags=todo.day_tags, all_tags=tags) }}
 {% for tag in todo.task.tags.now | sort %}<select disabled><option>{{ tag }}</option></select>{% endfor %}
-{{ macros.tagselection(submit_name='tag', selected_tags=todo.day_tags, all_tags=tags) }}
 <br />
 </td>
 </tr>
@@ -88,46 +144,119 @@ new: <input name="tag" value="" size=15 >
 <tr class="toplevel">
 <th>dependers</th>
 <td colspan=2>
-<ul>
-{% for depender in todo.dependers %}
-<li><a href="todo?id={{depender.id_}}">{{depender.title}}</a>
+<table>
+{% for path in todo.shortened_depender_paths %}
+<tr>
+<td>
+{% if not path[0] %}[…]<br />{% endif %}
+{% for step in path %}
+{% if step %}
+{% if step.dependers %}➛ {% endif %}<a href="todo?id={{step.id_}}">{{step.title}}</a><br />
+{% endif %}
+{% endfor %}</td>
+</tr>
 {% endfor %}
-</ul>
+</table>
 </td>
 </tr>
 {% endif %}
 
 <tr class="toplevel">
-<th>dependencies</th>
+<th>sub-todos</th>
 <td colspan=2>
-{% if todo.deps %}
 <table>
+<tr class="lowlevel"><td colspan=4>expected:</td></tr>
+{% for dep_slot in dep_slots %}
+{% if dep_slot.todos %}
+{{ draw_deps(dep_slot.todos) }}
+{% else %}
 <tr class="lowlevel">
-<th>adopted</th><th>effort</th><th>title</th><th>comments</th>
+<td></td>
+<td>[ ]</td>
+<td>
+{% if dep_slot.task.deps %} <details>
+<summary>({{dep_slot.task.title.then}})</summary>
+{% for task in dep_slot.task.deps %}
+{{ task_with_deps(task, 1) }}
+{% endfor %}
+</details>
+{% else %}
+({{dep_slot.task.title.then}})
+{% endif %}
+</td>
 </tr>
-{% for todo in dep_todos %}
+{% endif %}
+{% endfor %}
+{% if additional_deps %}
+<tr class="lowlevel"><td colspan=4>bonus:</td></tr>
+{{ draw_deps(additional_deps) }}
+{% endif %}
+</table>
+</td>
+</tr>
+
+<tr class="toplevel">
+<th>suggestions</th>
+<td colspan=2>
+{% if todo.task.deps %}
+<table>
+{% for dep in todo.task.deps %}
+<tr class="lowlevel">
+<td><input name="birth_dep" type="checkbox" value="{{dep.id_}}"></td>
+<td>make new</td>
+<td><a href="task?id={{dep.id_}}">{{dep.title.then}}</a></td>
+</tr>
+{% for suggested_todo in suggested_todos[dep.id_] %}
 <tr class="lowlevel">
-<td class="center"><input name="adopt_dep" type="checkbox" value="{{todo.id_}}" checked/></td>
-<td class="number">{{ '{:2.1f}'.format(todo.all_days_effort) }} {% if todo.done %}✓{% else %}&nbsp;{% endif %}</td>
-<td><a href="todo?id={{todo.id_}}">{{todo.day.date}} {{todo.title}}</a></td>
-<td>{{todo.comment}}</td>
+<td><input name="adopt_dep" type="checkbox" value="{{suggested_todo.id_}}" /></td>
+<td>adopt</td>
+<td><a href="todo?id={{suggested_todo.id_}}">{{suggested_todo.day.date}}:{{suggested_todo.title}}{% if suggested_todo.deps %}:+{% endif %}</a></td>
+<td>{{suggested_todo.comment}}</td>
 </tr>
 {% endfor %}
+{% endfor %}
 </table>
 {% endif %}
-<br />
+</td>
+</tr>
+
+<tr class="toplevel">
+<th>free add</th>
+<td colspan=2>
 make from task:<br />
-<input name="birth_dep" list="tasks" size=100><br />
-adopt (from <input name="start" {% if start_date %}value="{{ start_date }}"{% endif %} placeholder="yesterday" /> to <input name="end" {% if end_date %}value="{{ end_date }}"{% endif %} placeholder="2030-12-31" />):<br />
-<input name="adopt_dep" list="todos" size=100>
+<input name="birth_dep" list="tasks" size=100 autocomplete="off"><br />
+adopt:<br />
+<input name="adopt_dep" list="todos" size=100 autocomplete="off">
 <datalist id="todos">
-{% for todo in filtered_todos %}<option value="{{todo.id_}}">{{ '{:2.1f}'.format(todo.all_days_effort) }} {% if todo.done %}✓{% else %}&nbsp;&nbsp;{% endif %} {{todo.day.date}} {{todo.title}} {{todo.comment}}</option>
+{% for t in filtered_todos %}
+<option value="{{t.id_}}">
+{{ macros.doneness_string(t, datalist_hack=true) }}
+{{t.day.date}} {{t.title}} {{t.comment}}
+{% if t.dependers %}
+(dependers:
+{% for path in t.depender_paths %}
+{{ path[0].title }}{% if path|count > 1 %}➛{% endif %}{% if path|count > 3 %}…➛{% endif %}{% if path|count > 1 %}{{ path[-1].title }}{% endif %}
+{% endfor %})
+{% endif %}
+</option>
 {% endfor %}
 </datalist>
-<datalist id="tasks">
-{% for task in filtered_tasks %}<option value="{{task.id_}}">{{task.title.now}}</option>
+</td>
+</tr>
+{{ macros.datalist_tasks(filtered_tasks) }}
+
+<tr class="toplevel">
+<th>as chain</th>
+<td colspan=2>
+<table>
+{% for dep in todo.deps_chain %}
+<tr class="lowlevel">
+<td class="number">{{dep.deps_depth}}</td>
+<td>{% if dep.deps_done %}{{ macros.doneness_string(dep) }}{% endif %}</td>
+<td>{{ draw_todo(dep) }}</td>
+</tr>
 {% endfor %}
-</datalist>
+</table>
 </td>
 </tr>