orphan tasks

This commit is contained in:
Philippe PITTOLI 2019-12-08 02:17:55 +01:00
parent 8612f0ab8b
commit 3b489f1669
3 changed files with 102 additions and 70 deletions

View File

@ -4,6 +4,39 @@ Modal = require './modal.ls'
UUID = require "uuid/v4"
bulma = require "./bulma.ls"
col-to-lines = (column, self) ->
h \div.field.has-addons {
key: "field" + column.id
} [
h \p.control [
h \input.input {
key: "input" + column.id
value: column.title
oninput: (e) ->
self.extra_properties.columns.find((.id == column.id)).title := e.target.value
} [ ]
]
h \div.control.button.is-primary {
key: "button" + column.id
onclick: ->
# console.log "BEFORE REMOVING THE COLUMN: ", self.extra_properties.columns
self.extra_properties.columns := self.extra_properties.columns.filter((.id != column.id))
# console.log "AFTER REMOVING THE COLUMN: ", self.extra_properties.columns
} [ "DELETE" ]
]
# <div class="field has-addons">
# <p class="control">
# <input class="input" type="text" placeholder="Your email">
# </p>
# <p class="control">
# <a class="button is-static">
# @gmail.com
# </a>
# </p>
# </div>
ProjectCreationModal = (project, todod-ws) ->
# work on a copy of the columns
@ -32,11 +65,20 @@ ProjectCreationModal = (project, todod-ws) ->
+visible
content-render: (self) ->
h \div.form [
bulma.field [
# console.log "NEW USER NAME: " + self.new-user
# bulma.label "Valeur actuelle : " + self.new-user
bulma.label "Project title"
h \input.input {
value: self.title
oninput: (e) ->
self.title := e.target.value
}
]
h \hr []
bulma.field [
# console.log "NEW USER NAME: " + self.new-user
@ -52,11 +94,7 @@ ProjectCreationModal = (project, todod-ws) ->
}
]
h \input.input {
value: self.title
oninput: (e) ->
self.title := e.target.value
}
h \hr []
h \aside.menu [
h \p.menu-label [ "Permissions" ]
@ -70,29 +108,14 @@ ProjectCreationModal = (project, todod-ws) ->
]
]
h \aside.menu [
h \p.menu-label [ "Choose the columns" ]
h \hr []
h \ul.menu-list self.extra_properties.columns.map (column) ->
h \p [ "Choose the columns" ]
h \li {
key: column.id
} [
h \input.input {
key: column.id
value: column.title
oninput: (e) ->
self.extra_properties.columns.find((.id == column.id)).title := e.target.value
} [ ]
for dom in (self.extra_properties.columns.map (column) -> col-to-lines column, self)
dom
h \div.button {
onclick: ->
# TODO: create a new entry in self.extra_properties.columns
self.extra_properties.columns := self.extra_properties.columns.filter((.id != column.id))
# self.todod-ws.edit-list
# todod-ws.edit-list project.id, self
} [ "X" ]
]
h \hr []
h \input.input {
value: self.new-column-input.title
@ -111,7 +134,6 @@ ProjectCreationModal = (project, todod-ws) ->
self.new-column-input.title := "New column !"
} [ "+" ]
]
]
on-validation: ->
if project.id

View File

@ -6,6 +6,19 @@ Modal = require './modal.ls'
TaskCreationModal = require './task-creation-modal.ls'
ProjectCreationModal = require "./project-creation-modal.ls"
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
orphan-tasks = (tasks, columns) ->
tasks.filter (task) -> (! has-column) || inexistant-column task, columns
Project = (self, todod-ws) ->
self.todod-ws = todod-ws
self.tasks = []
@ -14,9 +27,14 @@ Project = (self, todod-ws) ->
self.render-column = (column, first) ->
tasks-to-display = self.tasks.filter (task) ->
task.extra_properties && task.extra_properties.column && task.extra_properties.column == column.id
|| ((! task.extra_properties || ! task.extra_properties.column) && first)
console.log "tasks: ", self.tasks
tasks-to-display = self.tasks.filter (task) -> is-right-column task, column.id
if first
tasks-to-display ++= orphan-tasks self.tasks, self.extra_properties.columns
console.log "column: #{column.id}: ", tasks-to-display
h \div.column {
key: column.id

View File

@ -8,8 +8,9 @@ TaskCreationModal = (project, todod-ws, task) ->
self = {
title: task.title || ""
description: task.description || ""
columns: []
column: void
extra_properties: {
column: task.list || ""
}
}
modal = Modal {
@ -32,33 +33,24 @@ TaskCreationModal = (project, todod-ws, task) ->
h \p.menu-label [ "Choose the column" ]
h \ul.menu-list project.extra_properties.columns.map (column) ->
h \li [
h \a {
h \li {
classes: {
is-active: self.extra_properties && self.extra_properties.column == column.id
}
} [
h \a {
onclick: ->
self.column := column.id
self.extra_properties.column := column.id
} [ column.title ]
]
]
]
on-validation: ->
if task.id
todod-ws.edit-task task.id, {
title: self.title
description: self.description
extra_properties: {
column: self.column || ""
}
}
todod-ws.edit-task task.id, self
else
todod-ws.add-task project.id, self.title, {
description: self.description
extra_properties: {
column: self.column || ""
}
}
todod-ws.add-task project.id, self.title, self
}, self
self.render = ->