2019-12-06 04:10:00 +01:00
|
|
|
|
|
|
|
h = require 'maquette' .h
|
|
|
|
Modal = require './modal.ls'
|
|
|
|
|
2019-12-08 04:08:21 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
} [ ]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-12-06 05:04:55 +01:00
|
|
|
TaskCreationModal = (project, todod-ws, task) ->
|
2019-12-06 04:10:00 +01:00
|
|
|
task ||= {}
|
|
|
|
|
2019-12-08 02:54:07 +01:00
|
|
|
# copy not to override anything on cancel
|
2019-12-06 04:10:00 +01:00
|
|
|
self = {
|
|
|
|
title: task.title || ""
|
|
|
|
description: task.description || ""
|
2019-12-08 02:17:55 +01:00
|
|
|
extra_properties: {
|
2019-12-08 02:56:29 +01:00
|
|
|
column: ""
|
2019-12-08 02:17:55 +01:00
|
|
|
}
|
2019-12-06 04:10:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-08 02:56:29 +01:00
|
|
|
if task.extra_properties && task.extra_properties.column
|
|
|
|
self.extra_properties.column = task.extra_properties.column
|
|
|
|
|
2019-12-06 04:10:00 +01:00
|
|
|
modal = Modal {
|
|
|
|
+visible
|
2019-12-07 05:11:47 +01:00
|
|
|
content-render: (self) ->
|
|
|
|
h \div.form [
|
|
|
|
h \input.input {
|
|
|
|
value: self.title
|
|
|
|
oninput: (e) ->
|
|
|
|
self.title := e.target.value
|
|
|
|
}
|
2019-12-06 05:04:55 +01:00
|
|
|
|
2019-12-07 05:11:47 +01:00
|
|
|
h \textarea {
|
|
|
|
value: self.description
|
|
|
|
oninput: (e) ->
|
|
|
|
self.description := e.target.value
|
|
|
|
}
|
2019-12-06 21:07:39 +01:00
|
|
|
|
2019-12-08 04:08:21 +01:00
|
|
|
|
|
|
|
h \p [ "Choose the column" ]
|
|
|
|
h \div.control project.extra_properties.columns.map (column) -> column-form-selection self, column
|
|
|
|
|
2019-12-06 05:04:55 +01:00
|
|
|
]
|
2019-12-08 02:17:55 +01:00
|
|
|
|
2019-12-06 04:10:00 +01:00
|
|
|
on-validation: ->
|
|
|
|
if task.id
|
2019-12-08 02:17:55 +01:00
|
|
|
todod-ws.edit-task task.id, self
|
2019-12-06 04:10:00 +01:00
|
|
|
else
|
2019-12-08 02:17:55 +01:00
|
|
|
todod-ws.add-task project.id, self.title, self
|
2019-12-07 05:11:47 +01:00
|
|
|
}, self
|
2019-12-06 04:10:00 +01:00
|
|
|
|
|
|
|
self.render = ->
|
|
|
|
modal.render!
|
|
|
|
|
|
|
|
self
|
|
|
|
|
|
|
|
module.exports = TaskCreationModal
|