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
|
|
|
|
|
|
|
ProjectCreationModal = (project, todod-ws) ->
|
|
|
|
self = {
|
|
|
|
title: project.title || ""
|
2019-12-07 02:55:02 +01:00
|
|
|
new-user: "Coucou 2 le retour"
|
2019-12-06 21:07:39 +01:00
|
|
|
extra_properties:
|
|
|
|
columns: project.extra_properties.columns || []
|
|
|
|
}
|
|
|
|
|
|
|
|
modal = Modal {
|
|
|
|
+visible
|
|
|
|
new-column-input: "New column !"
|
|
|
|
|
2019-12-07 02:55:02 +01:00
|
|
|
content-render: (self) ->
|
|
|
|
h \div.form [
|
|
|
|
h \input.input {
|
|
|
|
value: self.title
|
|
|
|
oninput: (e) ->
|
|
|
|
self.title := e.target.value
|
|
|
|
}
|
|
|
|
|
|
|
|
bulma.field [
|
|
|
|
console.log "THEAFOEIOEAI JOAEJFOI JOJFOAEJ USER NAME: " + self.new-user
|
|
|
|
bulma.label "Valeur actuelle : " + self.new-user
|
|
|
|
bulma.label "Adding a user"
|
|
|
|
bulma.input {
|
|
|
|
value: self.new-user
|
|
|
|
oninput: (e) ->
|
|
|
|
self.new-user := e.target.value
|
|
|
|
console.log "NEW USER NAME: " + self.new-user
|
|
|
|
|
|
|
|
name: \new-user
|
|
|
|
id: \user-add
|
|
|
|
}
|
|
|
|
]
|
2019-12-06 21:07:39 +01:00
|
|
|
|
|
|
|
h \input.input {
|
2019-12-07 02:55:02 +01:00
|
|
|
value: self.title
|
2019-12-06 21:07:39 +01:00
|
|
|
oninput: (e) ->
|
2019-12-07 02:55:02 +01:00
|
|
|
self.title := e.target.value
|
|
|
|
}
|
|
|
|
|
|
|
|
h \aside.menu [
|
|
|
|
h \p.menu-label [ "Choose the columns" ]
|
|
|
|
|
|
|
|
h \ul.menu-list self.extra_properties.columns.map (column) ->
|
|
|
|
|
|
|
|
h \li [
|
|
|
|
h \input.input {
|
|
|
|
key: column.id
|
|
|
|
value: column.title
|
|
|
|
oninput: (e) ->
|
|
|
|
self.extra_properties.columns.find((.id == column.id)).title := e.target.value
|
|
|
|
} [ ]
|
|
|
|
|
|
|
|
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))
|
|
|
|
} [ "X" ]
|
|
|
|
]
|
|
|
|
|
|
|
|
h \input.input {
|
|
|
|
value: self.new-column-input
|
|
|
|
oninput: (e) ->
|
|
|
|
self.new-column-input := 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 !"
|
|
|
|
} [ "+" ]
|
|
|
|
]
|
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
|
|
|
|
|