2019-12-06 21:07:39 +01:00
|
|
|
|
2019-12-07 02:55:02 +01:00
|
|
|
h = require 'maquette' .h
|
2019-12-06 21:07:39 +01:00
|
|
|
Modal = require './modal.ls'
|
2019-12-07 02:55:02 +01:00
|
|
|
UUID = require "uuid/v4"
|
|
|
|
bulma = require "./bulma.ls"
|
2019-12-06 21:07:39 +01:00
|
|
|
|
2019-12-08 02:17:55 +01:00
|
|
|
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>
|
|
|
|
|
2019-12-06 21:07:39 +01:00
|
|
|
ProjectCreationModal = (project, todod-ws) ->
|
2019-12-07 05:11:47 +01:00
|
|
|
|
|
|
|
# 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
|
2019-12-07 18:15:57 +01:00
|
|
|
# console.log "element : ", k, "value: ", v
|
2019-12-07 05:11:47 +01:00
|
|
|
new-col[k] = v
|
|
|
|
columns-copy ++= [ new-col ]
|
|
|
|
|
2019-12-06 21:07:39 +01:00
|
|
|
self = {
|
|
|
|
title: project.title || ""
|
2019-12-07 18:15:57 +01:00
|
|
|
permissions: project.permissions || [[]]
|
|
|
|
new-user: "New user"
|
2019-12-07 05:11:47 +01:00
|
|
|
new-column-input: {
|
|
|
|
title: "New column !"
|
|
|
|
}
|
|
|
|
|
2019-12-06 21:07:39 +01:00
|
|
|
extra_properties:
|
2019-12-07 05:11:47 +01:00
|
|
|
columns: columns-copy
|
2019-12-06 21:07:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
modal = Modal {
|
|
|
|
+visible
|
2019-12-07 02:55:02 +01:00
|
|
|
content-render: (self) ->
|
|
|
|
h \div.form [
|
2019-12-08 02:17:55 +01:00
|
|
|
|
|
|
|
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 []
|
2019-12-07 02:55:02 +01:00
|
|
|
|
|
|
|
bulma.field [
|
2019-12-07 18:15:57 +01:00
|
|
|
# console.log "NEW USER NAME: " + self.new-user
|
|
|
|
# bulma.label "Valeur actuelle : " + self.new-user
|
2019-12-07 02:55:02 +01:00
|
|
|
bulma.label "Adding a user"
|
|
|
|
bulma.input {
|
|
|
|
value: self.new-user
|
|
|
|
oninput: (e) ->
|
|
|
|
self.new-user := e.target.value
|
|
|
|
|
|
|
|
name: \new-user
|
|
|
|
id: \user-add
|
|
|
|
}
|
|
|
|
]
|
2019-12-06 21:07:39 +01:00
|
|
|
|
2019-12-08 02:17:55 +01:00
|
|
|
h \hr []
|
2019-12-07 02:55:02 +01:00
|
|
|
|
2019-12-07 18:15:57 +01:00
|
|
|
h \aside.menu [
|
|
|
|
h \p.menu-label [ "Permissions" ]
|
|
|
|
h \ul.menu-list self.permissions.map (permission) ->
|
|
|
|
h \li [
|
|
|
|
h \p permission.map (e, index) ->
|
|
|
|
if index == 0
|
|
|
|
"Permissions '" + e + "': "
|
|
|
|
else
|
|
|
|
"" + e + ", "
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2019-12-08 02:17:55 +01:00
|
|
|
h \hr []
|
2019-12-07 02:55:02 +01:00
|
|
|
|
2019-12-08 02:17:55 +01:00
|
|
|
h \p [ "Choose the columns" ]
|
|
|
|
|
|
|
|
for dom in (self.extra_properties.columns.map (column) -> col-to-lines column, self)
|
|
|
|
dom
|
|
|
|
|
|
|
|
h \hr []
|
|
|
|
|
|
|
|
h \input.input {
|
|
|
|
value: self.new-column-input.title
|
|
|
|
oninput: (e) ->
|
|
|
|
self.new-column-input.title := e.target.value
|
|
|
|
} [ ]
|
|
|
|
|
|
|
|
h \div.button {
|
|
|
|
onclick: ->
|
|
|
|
# TODO: create a new entry in self.extra_properties.columns
|
|
|
|
new-col = {
|
|
|
|
id: UUID!
|
|
|
|
title: self.new-column-input.title
|
|
|
|
}
|
|
|
|
self.extra_properties.columns ++= [ new-col ]
|
|
|
|
self.new-column-input.title := "New column !"
|
|
|
|
} [ "+" ]
|
2019-12-06 21:07:39 +01:00
|
|
|
]
|
2019-12-07 02:55:02 +01:00
|
|
|
|
2019-12-06 21:07:39 +01:00
|
|
|
on-validation: ->
|
|
|
|
if project.id
|
|
|
|
todod-ws.edit-list project.id, self
|
|
|
|
else
|
|
|
|
todod-ws.add-list self.title, self
|
2019-12-07 02:55:02 +01:00
|
|
|
}, self
|
2019-12-06 21:07:39 +01:00
|
|
|
|
|
|
|
self.render = ->
|
|
|
|
modal.render!
|
|
|
|
|
|
|
|
self
|
|
|
|
|
|
|
|
module.exports = ProjectCreationModal
|
|
|
|
|