92 lines
1.9 KiB
Plaintext
92 lines
1.9 KiB
Plaintext
|
||
h = require 'maquette' .h
|
||
bulma = require "./bulma.ls"
|
||
Task = require "./task.ls"
|
||
Modal = require './modal.ls'
|
||
TaskCreationModal = require './task-creation-modal.ls'
|
||
ProjectCreationModal = require "./project-creation-modal.ls"
|
||
|
||
Project = (self, todod-ws) ->
|
||
self.todod-ws = todod-ws
|
||
self.tasks = []
|
||
|
||
modal = void
|
||
|
||
self.render-column = (column, first) ->
|
||
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)
|
||
|
||
h \div.column [
|
||
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!
|
||
]
|
||
]
|
||
]
|
||
|
||
self.render-navbar = ->
|
||
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-danger.is-outlined {
|
||
onclick: ->
|
||
modal := ProjectCreationModal self, self.todod-ws
|
||
} [ "EDIT" ]
|
||
]
|
||
|
||
h \div.navbar-item [
|
||
h \div.button.is-success.is-outlined {
|
||
onclick: ->
|
||
modal := TaskCreationModal self, self.todod-ws
|
||
} [ "+" ]
|
||
]
|
||
|
||
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" ]
|
||
]
|
||
]
|
||
]
|
||
|
||
self.render = ->
|
||
|
||
# console.log "Project to render: ", self
|
||
h \div.project {} [
|
||
|
||
self.render-navbar!
|
||
|
||
h \div.columns [
|
||
if columns = self.extra_properties.columns
|
||
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
|
||
dom
|
||
]
|
||
|
||
if modal
|
||
modal.render!
|
||
]
|
||
|
||
self
|
||
|
||
module.exports = Project
|