Grooming.

dev
Luka Vandervelden 2019-12-24 23:08:57 +01:00
parent 23bc904a20
commit 8c3ed12e4c
1 changed files with 16 additions and 15 deletions

View File

@ -15,15 +15,13 @@ deep-copy = (object) ->
is-right-column = (task, 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)
inexistant-column = (task, columns) ->
columns.filter((.id == task.extra_properties.column)).length == 0
! columns.find((.id == task.extra_properties.column))
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) ->
@ -44,6 +42,18 @@ Project = (self, todod-ws, users-cache) ->
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) ->
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
modal.visible := false
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.edit-column column
}
} [
icon \cog