diff --git a/client/project-creation-modal.ls b/client/project-creation-modal.ls index 175d002..6d8a237 100644 --- a/client/project-creation-modal.ls +++ b/client/project-creation-modal.ls @@ -5,17 +5,31 @@ UUID = require "uuid/v4" bulma = require "./bulma.ls" ProjectCreationModal = (project, todod-ws) -> + + # work on a copy of the columns + # in case of cancelled modifications, only the copies are changed + columns-copy = [] + for col in project.extra_properties.columns + new-col = {} + for k,v of col + console.log "element : ", k, "value: ", v + new-col[k] = v + columns-copy ++= [ new-col ] + self = { title: project.title || "" + # TODO XXX FIXME new-user: "Coucou 2 le retour" + new-column-input: { + title: "New column !" + } + extra_properties: - columns: project.extra_properties.columns || [] + columns: columns-copy } modal = Modal { +visible - new-column-input: "New column !" - content-render: (self) -> h \div.form [ h \input.input { @@ -50,7 +64,9 @@ ProjectCreationModal = (project, todod-ws) -> h \ul.menu-list self.extra_properties.columns.map (column) -> - h \li [ + h \li { + key: column.id + } [ h \input.input { key: column.id value: column.title @@ -61,21 +77,27 @@ ProjectCreationModal = (project, todod-ws) -> h \div.button { onclick: -> # TODO: create a new entry in self.extra_properties.columns - self.extra_properties.columns = self.extra_properties.select((.id != column.id)) + 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 \input.input { - value: self.new-column-input + value: self.new-column-input.title oninput: (e) -> - self.new-column-input := e.target.value + self.new-column-input.title := e.target.value } [ ] h \div.button { onclick: -> # TODO: create a new entry in self.extra_properties.columns - self.extra_properties.columns ++= [ self.new-column-input ] - self.new-column-input := "New column !" + new-col = { + id: UUID! + title: self.new-column-input.title + } + self.extra_properties.columns ++= [ new-col ] + self.new-column-input.title := "New column !" } [ "+" ] ] ] diff --git a/client/project.ls b/client/project.ls index 0590ffb..1006299 100644 --- a/client/project.ls +++ b/client/project.ls @@ -18,7 +18,9 @@ Project = (self, todod-ws) -> task.extra_properties && task.extra_properties.column && task.extra_properties.column == column.id || ((! task.extra_properties || ! task.extra_properties.column) && first) - h \div.column [ + h \div.column { + key: column.id + } [ h \div.card { key: self.id } [ h \div.cart-head [ h \p.title.is-4 [ column.titleĀ ] diff --git a/client/task-creation-modal.ls b/client/task-creation-modal.ls index bb20b3d..c5b826f 100644 --- a/client/task-creation-modal.ls +++ b/client/task-creation-modal.ls @@ -14,35 +14,35 @@ TaskCreationModal = (project, todod-ws, task) -> modal = Modal { +visible - content: h \div.form [ - h \input.input { - value: self.title - oninput: (e) -> - self.title := e.target.value - } + content-render: (self) -> + h \div.form [ + h \input.input { + value: self.title + oninput: (e) -> + self.title := e.target.value + } - h \textarea { - value: self.description - oninput: (e) -> - self.description := e.target.value - } + h \textarea { + value: self.description + oninput: (e) -> + self.description := e.target.value + } - h \aside.menu [ - h \p.menu-label [ "Choose the column" ] - h \ul.menu-list project.extra_properties.columns.map (column) -> - - h \li [ - h \a { - classes: { - is-active: self.extra_properties && self.extra_properties.column == column.id - } - onclick: -> - self.column := column.id - } [ column.title ] - ] + h \aside.menu [ + h \p.menu-label [ "Choose the column" ] + h \ul.menu-list project.extra_properties.columns.map (column) -> + h \li [ + h \a { + classes: { + is-active: self.extra_properties && self.extra_properties.column == column.id + } + onclick: -> + self.column := column.id + } [ column.title ] + ] + ] ] - ] on-validation: -> if task.id todod-ws.edit-task task.id, { @@ -59,7 +59,7 @@ TaskCreationModal = (project, todod-ws, task) -> column: self.column || "" } } - } + }, self self.render = -> modal.render!