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"
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 !"
} [ "+" ]
]
]

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) && 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 ]

View File

@ -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!