h = require 'maquette' .h bulma = require "./bulma.ls" Task = require "./task.ls" Modal = require './modal.ls' Project = (self, todod-ws) -> self.todod-ws = todod-ws self.tasks = self.tasks.map (e) -> Task e, self, {} modal = void self.render-column = (column, first) -> # FIXME: display unregistred tasks in the first column h \div.column [ bulma.title 4 column.title self.tasks.filter (task) -> task-column = task.extra_properties.column task-column == column.id || (! task-column && first) ] self.render = -> # console.log "Project to render: ", self h \div.project {} [ 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: -> modal := Modal { +visible content: h \p [ "New task lol?" ] on-validation: -> self.todod-ws.add-task self.id, "Hello There", {} } } [ "+" ] ] 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" ] ] ] ] 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