almost display tasks
This commit is contained in:
parent
038e2151fd
commit
fc8a0a8d9b
@ -42,6 +42,7 @@ Task = require "./task.ls"
|
|||||||
Project = require "./project.ls"
|
Project = require "./project.ls"
|
||||||
Modal = require "./modal.ls"
|
Modal = require "./modal.ls"
|
||||||
# ValidationModal = require "./validation-modal.ls"
|
# ValidationModal = require "./validation-modal.ls"
|
||||||
|
UUID = require "uuid/v4"
|
||||||
|
|
||||||
{create-projector, h} = maquette
|
{create-projector, h} = maquette
|
||||||
projector = create-projector!
|
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.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 = ->
|
render-navbar = ->
|
||||||
h \div.navbar [
|
h \div.navbar [
|
||||||
h \div.navbar-start [
|
h \div.navbar-start [
|
||||||
@ -207,22 +229,36 @@ render-navbar = ->
|
|||||||
|
|
||||||
render-project-list = ->
|
render-project-list = ->
|
||||||
h \div.section model.project-list.map (project) ->
|
h \div.section model.project-list.map (project) ->
|
||||||
if project
|
|
||||||
h \div.box {
|
h \div.box {
|
||||||
key: project.id
|
key: project.id
|
||||||
onclick: ->
|
onclick: ->
|
||||||
model.current-view := "project"
|
model.current-view := "project"
|
||||||
model.viewed-project := project.id
|
model.viewed-project := project.id
|
||||||
model.todod-ws.get-list project.id
|
model.todod-ws.get-list project.id
|
||||||
|
model.todod-ws.get-tasks project.id
|
||||||
} [
|
} [
|
||||||
bulma.title 4 project.title
|
bulma.title 4 project.title
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Column = (title) ->
|
||||||
|
{
|
||||||
|
title: title
|
||||||
|
id: UUID! # TODO FIXME XXX
|
||||||
|
}
|
||||||
|
|
||||||
render-new-project-button = ->
|
render-new-project-button = ->
|
||||||
h \div.button.is-primary.is-large.is-fullwidth {
|
h \div.button.is-primary.is-large.is-fullwidth {
|
||||||
onclick: ->
|
onclick: ->
|
||||||
model.todod-ws.add-list "New project", {
|
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!" ]
|
} [ "New project!" ]
|
||||||
|
|
||||||
@ -259,19 +295,6 @@ render-body = ->
|
|||||||
render-new-project-button!
|
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"
|
when "project"
|
||||||
h \div [
|
h \div [
|
||||||
render-navbar!
|
render-navbar!
|
||||||
|
@ -6,17 +6,48 @@ Modal = require './modal.ls'
|
|||||||
|
|
||||||
Project = (self, todod-ws) ->
|
Project = (self, todod-ws) ->
|
||||||
self.todod-ws = 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
|
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 = ->
|
self.render = ->
|
||||||
|
|
||||||
# console.log "Project to render: ", self
|
# console.log "Project to render: ", self
|
||||||
h \div.project {} [
|
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 {
|
h \div.button.is-danger.is-outlined {
|
||||||
onclick: ->
|
onclick: ->
|
||||||
modal := Modal {
|
modal := Modal {
|
||||||
@ -27,10 +58,13 @@ Project = (self, todod-ws) ->
|
|||||||
self.todod-ws.remove-list self.id
|
self.todod-ws.remove-list self.id
|
||||||
}
|
}
|
||||||
} [ "X" ]
|
} [ "X" ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
h \div.columns [
|
h \div.columns [
|
||||||
if self.extra_properties.columns
|
if columns = self.extra_properties.columns
|
||||||
for dom in self.extra_properties.columns.map((column) -> self.render-column(column))
|
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
|
||||||
dom
|
dom
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user