todo-webclient/client/project.ls

74 lines
1.6 KiB
Plaintext
Raw Normal View History

2019-11-22 16:52:50 +01:00
h = require 'maquette' .h
bulma = require "./bulma.ls"
Task = require "./task.ls"
2019-12-05 02:28:17 +01:00
Modal = require './modal.ls'
2019-12-06 01:56:32 +01:00
TaskCreationModal = require './TaskCreationModal.ls'
2019-11-22 16:52:50 +01:00
2019-12-05 02:28:17 +01:00
Project = (self, todod-ws) ->
self.todod-ws = todod-ws
2019-12-06 01:56:32 +01:00
self.tasks = []
2019-11-22 16:52:50 +01:00
2019-12-05 02:28:17 +01:00
modal = void
2019-11-22 16:52:50 +01:00
2019-12-05 04:47:29 +01:00
self.render-column = (column, first) ->
2019-12-06 01:56:32 +01:00
tasks-to-display = self.tasks.filter (task) ->
task.extra_properties && task.extra_properties.column && task.extra_properties.column == column.id
|| ((! task.extra_properties || ! task.extra_properties.column) && first)
2019-12-05 04:47:29 +01:00
h \div.column [
bulma.title 4 column.title
2019-12-06 00:13:59 +01:00
for task in tasks-to-display
task.render!
2019-12-05 04:47:29 +01:00
]
2019-11-22 16:52:50 +01:00
2019-12-05 02:28:17 +01:00
self.render = ->
2019-11-22 16:52:50 +01:00
2019-12-05 02:28:17 +01:00
# console.log "Project to render: ", self
h \div.project {} [
2019-12-05 04:47:29 +01:00
h \div.navbar [
h \div.navbar-brand [
h \div.navbar-item [
self.title
]
]
h \div.navbar-end [
h \div.navbar-item [
h \div.button.is-success.is-outlined {
onclick: ->
2019-12-06 01:56:32 +01:00
modal := TaskCreationModal self.id, self.todod-ws
2019-12-05 04:47:29 +01:00
} [ "+" ]
]
h \div.navbar-item [
h \div.button.is-danger.is-outlined {
onclick: ->
modal := Modal {
+visible
content:
h \p [ "Are you sure you want to remove board #{self.title}?" ]
on-validation: ->
self.todod-ws.remove-list self.id
}
} [ "X" ]
]
]
]
2019-12-05 02:28:17 +01:00
h \div.columns [
2019-12-05 04:47:29 +01:00
if columns = self.extra_properties.columns
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
2019-12-05 02:28:17 +01:00
dom
2019-11-22 16:52:50 +01:00
]
2019-12-05 02:28:17 +01:00
if modal
modal.render!
]
2019-12-05 02:28:17 +01:00
self
2019-12-05 02:28:17 +01:00
module.exports = Project