2019-11-22 16:52:50 +01:00
|
|
|
h = require 'maquette' .h
|
|
|
|
bulma = require "./bulma.ls"
|
|
|
|
nmd = require "nano-markdown"
|
2019-12-06 04:10:00 +01:00
|
|
|
TaskCreationModal = require './task-creation-modal.ls'
|
2019-12-06 04:07:19 +01:00
|
|
|
TaskRemovalModal = require './task-removal-modal.ls'
|
2019-11-22 16:52:50 +01:00
|
|
|
|
2019-12-12 01:25:36 +01:00
|
|
|
display-login = (task, users) ->
|
|
|
|
if task.extra_properties && task.extra_properties.assignee-id && users && users[task.extra_properties.assignee-id] && users[task.extra_properties.assignee-id].login
|
|
|
|
h \p [ '@' + users[task.extra_properties.assignee-id].login ]
|
|
|
|
else
|
|
|
|
h \p [ '-' ]
|
2019-11-22 16:52:50 +01:00
|
|
|
|
|
|
|
|
2019-12-06 01:56:32 +01:00
|
|
|
Task = (self, project, todod-ws) ->
|
|
|
|
modal = void
|
2019-12-05 23:53:36 +01:00
|
|
|
|
2019-12-06 01:56:32 +01:00
|
|
|
self.render = ->
|
2019-12-09 03:31:11 +01:00
|
|
|
background-color = "grey"
|
|
|
|
if self.extra_properties && self.extra_properties.background-color
|
|
|
|
background-color = self.extra_properties.background-color
|
2019-12-09 03:09:06 +01:00
|
|
|
|
2019-12-09 03:31:11 +01:00
|
|
|
h "div.card.has-background-#{background-color}" {
|
2019-12-09 03:09:06 +01:00
|
|
|
key: self.id
|
|
|
|
} [
|
2019-12-06 04:07:19 +01:00
|
|
|
h \div.card-content [
|
|
|
|
h \div.media [
|
|
|
|
h \div.media-left [
|
2019-12-09 03:31:11 +01:00
|
|
|
# FIXME: assignee card image
|
2019-12-06 04:07:19 +01:00
|
|
|
"LEFT"
|
2019-12-12 01:25:36 +01:00
|
|
|
display-login self, project.users
|
2019-12-06 04:07:19 +01:00
|
|
|
]
|
2019-12-09 03:31:11 +01:00
|
|
|
|
|
|
|
h \div.media-content [ self.title ]
|
|
|
|
|
2019-12-06 04:07:19 +01:00
|
|
|
h \div.button {
|
|
|
|
onclick: ->
|
2019-12-12 01:25:36 +01:00
|
|
|
modal := TaskCreationModal project, todod-ws, self, project.users
|
2019-12-06 04:07:19 +01:00
|
|
|
} [ "Edit" ]
|
2019-12-09 03:31:11 +01:00
|
|
|
|
2019-12-10 03:34:08 +01:00
|
|
|
h \div.button.is-danger {
|
2019-12-06 04:07:19 +01:00
|
|
|
onclick: ->
|
|
|
|
modal := TaskRemovalModal project.id, todod-ws, self
|
|
|
|
} [ "X" ]
|
|
|
|
]
|
2019-12-09 03:40:00 +01:00
|
|
|
|
|
|
|
h \div.content {
|
|
|
|
key: "task-description-#{self.id}"
|
|
|
|
after-create: (dom) ->
|
|
|
|
dom.innerHTML = nmd self.description
|
|
|
|
} [ ]
|
2019-12-06 04:07:19 +01:00
|
|
|
]
|
2019-12-06 01:56:32 +01:00
|
|
|
if modal
|
|
|
|
modal.render!
|
|
|
|
]
|
2019-12-05 02:28:17 +01:00
|
|
|
|
|
|
|
self
|
2019-11-22 16:52:50 +01:00
|
|
|
|
2019-12-05 02:28:17 +01:00
|
|
|
module.exports = Task
|