Adding, removing, modifying columns: ok

This commit is contained in:
Philippe PITTOLI 2019-12-07 05:11:47 +01:00
parent 5a8c6c6c4e
commit e21f373454
3 changed files with 60 additions and 36 deletions

View File

@ -5,17 +5,31 @@ UUID = require "uuid/v4"
bulma = require "./bulma.ls" bulma = require "./bulma.ls"
ProjectCreationModal = (project, todod-ws) -> 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 = { self = {
title: project.title || "" title: project.title || ""
# TODO XXX FIXME
new-user: "Coucou 2 le retour" new-user: "Coucou 2 le retour"
new-column-input: {
title: "New column !"
}
extra_properties: extra_properties:
columns: project.extra_properties.columns || [] columns: columns-copy
} }
modal = Modal { modal = Modal {
+visible +visible
new-column-input: "New column !"
content-render: (self) -> content-render: (self) ->
h \div.form [ h \div.form [
h \input.input { h \input.input {
@ -50,7 +64,9 @@ ProjectCreationModal = (project, todod-ws) ->
h \ul.menu-list self.extra_properties.columns.map (column) -> h \ul.menu-list self.extra_properties.columns.map (column) ->
h \li [ h \li {
key: column.id
} [
h \input.input { h \input.input {
key: column.id key: column.id
value: column.title value: column.title
@ -61,21 +77,27 @@ ProjectCreationModal = (project, todod-ws) ->
h \div.button { h \div.button {
onclick: -> onclick: ->
# TODO: create a new entry in self.extra_properties.columns # 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" ] } [ "X" ]
] ]
h \input.input { h \input.input {
value: self.new-column-input value: self.new-column-input.title
oninput: (e) -> oninput: (e) ->
self.new-column-input := e.target.value self.new-column-input.title := e.target.value
} [ ] } [ ]
h \div.button { h \div.button {
onclick: -> onclick: ->
# TODO: create a new entry in self.extra_properties.columns # TODO: create a new entry in self.extra_properties.columns
self.extra_properties.columns ++= [ self.new-column-input ] new-col = {
self.new-column-input := "New column !" id: UUID!
title: self.new-column-input.title
}
self.extra_properties.columns ++= [ new-col ]
self.new-column-input.title := "New column !"
} [ "+" ] } [ "+" ]
] ]
] ]

View File

@ -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 && task.extra_properties.column == column.id
|| ((! task.extra_properties || ! task.extra_properties.column) && first) || ((! 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.card { key: self.id } [
h \div.cart-head [ h \div.cart-head [
h \p.title.is-4 [ column.title ] h \p.title.is-4 [ column.title ]

View File

@ -14,7 +14,8 @@ TaskCreationModal = (project, todod-ws, task) ->
modal = Modal { modal = Modal {
+visible +visible
content: h \div.form [ content-render: (self) ->
h \div.form [
h \input.input { h \input.input {
value: self.title value: self.title
oninput: (e) -> oninput: (e) ->
@ -40,7 +41,6 @@ TaskCreationModal = (project, todod-ws, task) ->
self.column := column.id self.column := column.id
} [ column.title ] } [ column.title ]
] ]
] ]
] ]
on-validation: -> on-validation: ->
@ -59,7 +59,7 @@ TaskCreationModal = (project, todod-ws, task) ->
column: self.column || "" column: self.column || ""
} }
} }
} }, self
self.render = -> self.render = ->
modal.render! modal.render!