almost display tasks

This commit is contained in:
Philippe PITTOLI 2019-12-05 04:47:29 +01:00
parent 038e2151fd
commit fc8a0a8d9b
2 changed files with 95 additions and 38 deletions

View File

@ -42,6 +42,7 @@ Task = require "./task.ls"
Project = require "./project.ls"
Modal = require "./modal.ls"
# ValidationModal = require "./validation-modal.ls"
UUID = require "uuid/v4"
{create-projector, h} = maquette
projector = create-projector!
@ -186,6 +187,27 @@ model.todod-ws.add-event-listener \list-removed, (message) ->
model.project-list := model.project-list.filter((.id != message.list))
model.todod-ws.add-event-listener \tasks, (message) ->
console.log message
project = model.project-list.find((.id == message.list))
if project
tasks = message.tasks.map (e) -> Task e, project, model
project.tasks = tasks
projector.schedule-render!
model.todod-ws.add-event-listener \task-created, (message) ->
console.log message
task = message.task
list = model.project-list.find((.id == task.list))
console.log task, list
if list
list.tasks ++= [ Task task, list, model ]
projector.schedule-render!
render-navbar = ->
h \div.navbar [
h \div.navbar-start [
@ -207,22 +229,36 @@ render-navbar = ->
render-project-list = ->
h \div.section model.project-list.map (project) ->
if project
h \div.box {
key: project.id
onclick: ->
model.current-view := "project"
model.viewed-project := project.id
model.todod-ws.get-list project.id
} [
bulma.title 4 project.title
]
h \div.box {
key: project.id
onclick: ->
model.current-view := "project"
model.viewed-project := project.id
model.todod-ws.get-list project.id
model.todod-ws.get-tasks project.id
} [
bulma.title 4 project.title
]
Column = (title) ->
{
title: title
id: UUID! # TODO FIXME XXX
}
render-new-project-button = ->
h \div.button.is-primary.is-large.is-fullwidth {
onclick: ->
model.todod-ws.add-list "New project", {
columns: ["Unassigned", "Work in progress", "To be checked", "Being checked", "Done"]
extra_properties: {
columns: [
Column "Unassigned"
Column "Work in progress"
Column "To be checked"
Column "Being checked"
Column "Done"
]
}
}
} [ "New project!" ]
@ -259,19 +295,6 @@ render-body = ->
render-new-project-button!
]
# FIXME: TODO: XXX: modal testing
when "testing-modals"
h \div#testing-modals [
render-navbar!
console.log "rendering a modal"
# bulma.asking-modal model, {}, [ (h \button.button {} [ "rendering a modal" ]) ]
if model.modal
model.modal.render!
render-new-project-button!
]
when "project"
h \div [
render-navbar!

View File

@ -6,31 +6,65 @@ Modal = require './modal.ls'
Project = (self, todod-ws) ->
self.todod-ws = todod-ws
self.tasks = self.tasks.map (e) -> Task e, self, model
self.tasks = self.tasks.map (e) -> Task e, self, {}
modal = void
self.render-column = (column) ->
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.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.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 self.extra_properties.columns
for dom in self.extra_properties.columns.map((column) -> self.render-column(column))
if columns = self.extra_properties.columns
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
dom
]