mirror of https://github.com/Hoffelhas/autodoist
Better projects order management
parent
85e9d48722
commit
09fc8cfebf
|
@ -142,16 +142,17 @@ class Project(object):
|
||||||
if self._subProjects == None:
|
if self._subProjects == None:
|
||||||
self._subProjects = []
|
self._subProjects = []
|
||||||
initialIndent = self.indent
|
initialIndent = self.indent
|
||||||
initialOrder = self.itemOrder
|
initialOrder = self._todoist._orderedProjects.index(self)
|
||||||
order = initialOrder + 1
|
order = initialOrder + 1
|
||||||
maxSize = len(self._todoist._orderedProjects)
|
maxSize = len(self._todoist._orderedProjects)
|
||||||
if order < maxSize:
|
if order < maxSize:
|
||||||
current = self._todoist._orderedProjects[order]
|
current = self._todoist._orderedProjects[order]
|
||||||
while ((current.indent > initialIndent) and (order < maxSize)):
|
while ((current.indent > initialIndent) and (order < maxSize)):
|
||||||
current = self._todoist._orderedProjects[order]
|
current = self._todoist._orderedProjects[order]
|
||||||
self._subProjects.append(current)
|
if current != None:
|
||||||
current.parent = self
|
self._subProjects.append(current)
|
||||||
order = order + 1
|
current.parent = self
|
||||||
|
order = order + 1
|
||||||
|
|
||||||
return self._subProjects
|
return self._subProjects
|
||||||
|
|
||||||
|
@ -209,12 +210,14 @@ class TodoistData(object):
|
||||||
def __init__(self, initial_data):
|
def __init__(self, initial_data):
|
||||||
self._SetLabelData(initial_data)
|
self._SetLabelData(initial_data)
|
||||||
self._projects = dict()
|
self._projects = dict()
|
||||||
self._orderedProjects = dict()
|
|
||||||
for project in initial_data['Projects']:
|
for project in initial_data['Projects']:
|
||||||
p = Project(project)
|
p = Project(project)
|
||||||
p.setTodoist(self)
|
p.setTodoist(self)
|
||||||
self._projects[project['id']] = p
|
self._projects[project['id']] = p
|
||||||
self._orderedProjects[project['item_order']] = p
|
|
||||||
|
self._orderedProjects = sorted(self._projects.values(), key=lambda project: project.itemOrder)
|
||||||
|
|
||||||
for project in self._projects.values():
|
for project in self._projects.values():
|
||||||
project.subProjects()
|
project.subProjects()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue