todo-webclient/client/task-creation-modal.ls

75 lines
1.4 KiB
Plaintext

h = require 'maquette' .h
Modal = require './modal.ls'
column-form-selection = (self, column) ->
checked = false
if self.extra_properties && self.extra_properties.column == column.id
checked = true
h \label.radio [
column.title
h \input {
type: "radio"
name: "column"
checked: checked
value: column.title
onclick: ->
self.extra_properties.column := column.id
} [ ]
]
TaskCreationModal = (project, todod-ws, task) ->
task ||= {}
# copy not to override anything on cancel
self = {
title: task.title || ""
description: task.description || ""
extra_properties: {
column: ""
}
}
if task.extra_properties && task.extra_properties.column
self.extra_properties.column = task.extra_properties.column
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.control project.extra_properties.columns.map (column) -> column-form-selection self, column
]
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