Grooming.

This commit is contained in:
Luka Vandervelden 2019-12-24 23:08:57 +01:00
parent 23bc904a20
commit 8c3ed12e4c

View File

@ -15,15 +15,13 @@ deep-copy = (object) ->
is-right-column = (task, column-id) -> is-right-column = (task, column-id) ->
task.extra_properties && task.extra_properties.column && task.extra_properties.column == column-id task.extra_properties && task.extra_properties.column && task.extra_properties.column == column-id
has-column = (task) ->
task.extra_properties && task.extra_properties.column
# configured column, but inexistant (maybe removed since) # configured column, but inexistant (maybe removed since)
inexistant-column = (task, columns) -> inexistant-column = (task, columns) ->
columns.filter((.id == task.extra_properties.column)).length == 0 ! columns.find((.id == task.extra_properties.column))
orphan-tasks = (tasks, columns) -> orphan-tasks = (tasks, columns) ->
tasks.filter (task) -> (! has-column) || inexistant-column task, columns tasks.filter (task) ->
(! task.extra_properties?.column) || inexistant-column task, columns
Project = (self, todod-ws, users-cache) -> Project = (self, todod-ws, users-cache) ->
@ -44,6 +42,18 @@ Project = (self, todod-ws, users-cache) ->
extra_properties: extra_properties extra_properties: extra_properties
} }
self.edit-column = (column) ->
extra_properties = deep-copy self.extra_properties
extra_properties.columns = extra_properties.columns.map (old-column) ->
if old-column.id == column.id
column
else
old-column
todod-ws.edit-list self.id, {
extra_properties: extra_properties
}
self.render-column = (column, first) -> self.render-column = (column, first) ->
tasks-to-display = self.tasks.filter (task) -> is-right-column task, column.id tasks-to-display = self.tasks.filter (task) -> is-right-column task, column.id
@ -86,16 +96,7 @@ Project = (self, todod-ws, users-cache) ->
console.log "column update:", column console.log "column update:", column
modal.visible := false modal.visible := false
extra_properties = deep-copy(self.extra_properties) self.edit-column column
extra_properties.columns = extra_properties.columns.map (old-column) ->
if old-column.id == column.id
column
else
old-column
todod-ws.edit-list self.id, {
extra_properties: extra_properties
}
} }
} [ } [
icon \cog icon \cog