108 lines
2.0 KiB
Plaintext
108 lines
2.0 KiB
Plaintext
|
|
h = require 'maquette' .h
|
|
Modal = require './modal.ls'
|
|
|
|
colors = [
|
|
"white"
|
|
"black"
|
|
"light"
|
|
"dark"
|
|
"primary"
|
|
"info"
|
|
"link"
|
|
"success"
|
|
"warning"
|
|
"danger"
|
|
"black-bis"
|
|
"black-ter"
|
|
"grey-darker"
|
|
"grey-dark"
|
|
"grey"
|
|
"grey-light"
|
|
"grey-lighter"
|
|
"white-ter"
|
|
"white-bis"
|
|
]
|
|
|
|
column-form-selection = (self, column) ->
|
|
h \option {
|
|
value: column.id
|
|
selected: self.extra_properties && self.extra_properties.column == column.id
|
|
} [ column.title ]
|
|
|
|
color-to-form-selection = (self, color) ->
|
|
h \option {
|
|
value: color
|
|
selected: self.extra_properties && self.extra_properties.color == color
|
|
} [ color ]
|
|
|
|
TaskCreationModal = (project, todod-ws, task) ->
|
|
task ||= {}
|
|
|
|
# copy not to override anything on cancel
|
|
self = {
|
|
title: task.title || ""
|
|
description: task.description || ""
|
|
extra_properties: {
|
|
column: ""
|
|
color: ""
|
|
}
|
|
}
|
|
|
|
# copy extra properties
|
|
# currently: column + color + assignee + expected duration time
|
|
for k,v of task.extra_properties
|
|
console.log "extra_propertie: " + k + ", value: " + v
|
|
self.extra_properties[k] = v
|
|
|
|
|
|
modal = Modal {
|
|
+visible
|
|
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 \p [ "Choose the column" ]
|
|
|
|
h \div.select [
|
|
h \select {
|
|
onchange: (e) ->
|
|
self.extra_properties.column := e.target.value
|
|
} project.extra_properties.columns.map (column) -> column-form-selection self, column
|
|
]
|
|
|
|
h \p [ "Choose the color" ]
|
|
|
|
h \div.select [
|
|
h \select {
|
|
onchange: (e) ->
|
|
self.extra_properties.color := e.target.value
|
|
} colors.map (color) -> color-to-form-selection self, color
|
|
]
|
|
]
|
|
|
|
on-validation: ->
|
|
if task.id
|
|
todod-ws.edit-task task.id, self
|
|
else
|
|
todod-ws.add-task project.id, self.title, self
|
|
}, self
|
|
|
|
self.render = ->
|
|
modal.render!
|
|
|
|
self
|
|
|
|
module.exports = TaskCreationModal
|