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 04:10:00 +01:00
|
|
|
|
TaskCreationModal = require './task-creation-modal.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 23:53:36 +01:00
|
|
|
|
|
2019-12-05 04:47:29 +01:00
|
|
|
|
h \div.column [
|
2019-12-06 05:04:55 +01:00
|
|
|
|
h \div.card { key: self.id } [
|
|
|
|
|
h \div.cart-head [
|
|
|
|
|
h \p.title.is-4 [ column.title ]
|
|
|
|
|
]
|
|
|
|
|
h \div.card-content { key: self.id } [
|
|
|
|
|
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 05:04:55 +01:00
|
|
|
|
modal := TaskCreationModal self, 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-04 04:17:38 +01:00
|
|
|
|
|
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-04 04:17:38 +01:00
|
|
|
|
|
2019-12-05 02:28:17 +01:00
|
|
|
|
self
|
2019-12-04 04:17:38 +01:00
|
|
|
|
|
2019-12-05 02:28:17 +01:00
|
|
|
|
module.exports = Project
|