todo-webclient/client/task.ls

59 lines
1.4 KiB
Plaintext

h = require 'maquette' .h
bulma = require "./bulma.ls"
nmd = require "nano-markdown"
TaskCreationModal = require './task-creation-modal.ls'
TaskRemovalModal = require './task-removal-modal.ls'
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 [ '-' ]
Task = (self, project, todod-ws) ->
modal = void
self.render = ->
background-color = "grey"
if self.extra_properties && self.extra_properties.background-color
background-color = self.extra_properties.background-color
h "div.card.has-background-#{background-color}" {
key: self.id
} [
h \div.card-content [
h \div.media [
h \div.media-left [
# FIXME: assignee card image
"LEFT"
display-login self, project.users
]
h \div.media-content [ self.title ]
h \div.button {
onclick: ->
modal := TaskCreationModal project, todod-ws, self, project.users
} [ "Edit" ]
h \div.button.is-danger {
onclick: ->
modal := TaskRemovalModal project.id, todod-ws, self
} [ "X" ]
]
h \div.content {
key: "task-description-#{self.id}"
after-create: (dom) ->
dom.innerHTML = nmd self.description
} [ ]
]
if modal
modal.render!
]
self
module.exports = Task