fix(tasklist): Fix sub menu labelling.

This commit is contained in:
2023-09-11 11:17:59 +03:00
parent a9a21b1735
commit 8e54186649

View File

@@ -381,9 +381,10 @@ class TasklistUI(BasePager):
def _format_parent(self, parentid) -> str: def _format_parent(self, parentid) -> str:
parentstr = '' parentstr = ''
if parentid is not None: if parentid is not None:
task = self.tasklist.tasklist.get(parentid, None) pair = next(((label, task) for label, task in self.labelled.items() if task.taskid == parentid), None)
if task: if pair is not None:
parent_label = self.tasklist.format_label(self.tasklist.labelid(parentid)).strip('.') label, task = pair
parent_label = self.tasklist.format_label(label).strip('.')
parentstr = f"{parent_label}: {task.content}" parentstr = f"{parent_label}: {task.content}"
return parentstr return parentstr
@@ -561,8 +562,8 @@ class TasklistUI(BasePager):
label=self.tasklist.format_label(rootlabel).strip('.'), label=self.tasklist.format_label(rootlabel).strip('.'),
) )
children = { children = {
label: taskid label: task
for label, taskid in labelled.items() for label, task in labelled.items()
if all(i == j for i, j in zip(label, rootlabel)) if all(i == j for i, j in zip(label, rootlabel))
} }
this_page = self.this_page this_page = self.this_page
@@ -572,11 +573,13 @@ class TasklistUI(BasePager):
else: else:
# Only show the children which display # Only show the children which display
page_children = [ page_children = [
(label, tid) for label, tid in this_page if label in children and tid != rootid (label, task) for label, task in this_page if label in children and task.taskid != rootid
][:24] ][:24]
if page_children: if page_children:
block = [(rootlabel, rootid), *page_children] # Always add the root task
block = [(rootlabel, self.tasklist.tasklist[rootid]), *page_children]
else: else:
# There are no subtree children on the current page
block = [] block = []
# Special case if the subtree is exactly the same as the page # Special case if the subtree is exactly the same as the page
if not (len(block) == len(this_page) and all(i[0] == j[0] for i, j in zip(block, this_page))): if not (len(block) == len(this_page) and all(i[0] == j[0] for i, j in zip(block, this_page))):