2019-12-06 04:10:00 +01:00
|
|
|
|
|
|
|
h = require 'maquette' .h
|
|
|
|
Modal = require './modal.ls'
|
|
|
|
|
2019-12-06 05:04:55 +01:00
|
|
|
TaskCreationModal = (project, todod-ws, task) ->
|
2019-12-06 04:10:00 +01:00
|
|
|
task ||= {}
|
|
|
|
|
|
|
|
self = {
|
|
|
|
title: task.title || ""
|
|
|
|
description: task.description || ""
|
2019-12-06 05:04:55 +01:00
|
|
|
columns: []
|
|
|
|
column: void
|
2019-12-06 04:10:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
modal = Modal {
|
|
|
|
+visible
|
|
|
|
content: 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
|
|
|
|
}
|
2019-12-06 05:04:55 +01:00
|
|
|
|
2019-12-06 21:07:39 +01:00
|
|
|
h \aside.menu [
|
2019-12-06 05:04:55 +01:00
|
|
|
h \p.menu-label [ "Choose the column" ]
|
|
|
|
h \ul.menu-list project.extra_properties.columns.map (column) ->
|
2019-12-06 21:07:39 +01:00
|
|
|
|
2019-12-06 05:04:55 +01:00
|
|
|
h \li [
|
2019-12-06 21:07:39 +01:00
|
|
|
h \a {
|
|
|
|
classes: {
|
|
|
|
is-active: self.extra_properties && self.extra_properties.column == column.id
|
|
|
|
}
|
2019-12-06 05:04:55 +01:00
|
|
|
onclick: ->
|
|
|
|
self.column := column.id
|
|
|
|
} [ column.title ]
|
|
|
|
]
|
|
|
|
|
|
|
|
]
|
2019-12-06 04:10:00 +01:00
|
|
|
]
|
|
|
|
on-validation: ->
|
|
|
|
if task.id
|
|
|
|
todod-ws.edit-task task.id, {
|
|
|
|
title: self.title
|
|
|
|
description: self.description
|
2019-12-06 05:04:55 +01:00
|
|
|
extra_properties: {
|
|
|
|
column: self.column || ""
|
|
|
|
}
|
2019-12-06 04:10:00 +01:00
|
|
|
}
|
|
|
|
else
|
2019-12-06 05:04:55 +01:00
|
|
|
todod-ws.add-task project.id, self.title, {
|
2019-12-06 04:10:00 +01:00
|
|
|
description: self.description
|
2019-12-06 05:04:55 +01:00
|
|
|
extra_properties: {
|
|
|
|
column: self.column || ""
|
|
|
|
}
|
2019-12-06 04:10:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self.render = ->
|
|
|
|
modal.render!
|
|
|
|
|
|
|
|
self
|
|
|
|
|
|
|
|
module.exports = TaskCreationModal
|