basic display of tasks in right columns
This commit is contained in:
parent
fc8a0a8d9b
commit
d511523934
@ -59,6 +59,7 @@ model = {
|
|||||||
# { uid => user data }
|
# { uid => user data }
|
||||||
users: {}
|
users: {}
|
||||||
|
|
||||||
|
# list of Project objects
|
||||||
project-list: []
|
project-list: []
|
||||||
|
|
||||||
port: 9999
|
port: 9999
|
||||||
@ -162,7 +163,7 @@ model.todod-ws.user-on-socket-error ++= [ on-websocket-error ]
|
|||||||
model.todod-ws.user-on-socket-close ++= [ on-websocket-close ]
|
model.todod-ws.user-on-socket-close ++= [ on-websocket-close ]
|
||||||
|
|
||||||
model.todod-ws.add-event-listener \lists-list, (message) ->
|
model.todod-ws.add-event-listener \lists-list, (message) ->
|
||||||
console.log message
|
# console.log message
|
||||||
model.project-list := message.lists.map (x) ->
|
model.project-list := message.lists.map (x) ->
|
||||||
Project x, model.todod-ws
|
Project x, model.todod-ws
|
||||||
|
|
||||||
@ -174,12 +175,13 @@ model.todod-ws.add-event-listener \new-list, (message) ->
|
|||||||
projector.schedule-render!
|
projector.schedule-render!
|
||||||
|
|
||||||
model.todod-ws.add-event-listener \tasks, (message) ->
|
model.todod-ws.add-event-listener \tasks, (message) ->
|
||||||
console.log message
|
console.log "RECEIVED TASKS MESSAGE", message
|
||||||
model.project-list.find((.id == message.list)).tasks := message.tasks
|
model.project-list.find((.id == message.list)).tasks := message.tasks
|
||||||
|
model.project-list.find((.id == message.list)).tasks-updated!
|
||||||
projector.schedule-render!
|
projector.schedule-render!
|
||||||
|
|
||||||
model.todod-ws.add-event-listener \list-removed, (message) ->
|
model.todod-ws.add-event-listener \list-removed, (message) ->
|
||||||
console.log message
|
console.log "A list has been removed", message
|
||||||
if model.current-view == "project" && model.viewed-project == message.list
|
if model.current-view == "project" && model.viewed-project == message.list
|
||||||
model.current-view := "project-list"
|
model.current-view := "project-list"
|
||||||
model.viewed-project := void
|
model.viewed-project := void
|
||||||
@ -187,22 +189,12 @@ 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) ->
|
model.todod-ws.add-event-listener \task-created, (message) ->
|
||||||
console.log message
|
console.log "A task has been created", message
|
||||||
|
|
||||||
task = message.task
|
task = message.task
|
||||||
list = model.project-list.find((.id == task.list))
|
list = model.project-list.find((.id == task.list))
|
||||||
console.log task, list
|
# console.log task, list
|
||||||
|
|
||||||
if list
|
if list
|
||||||
list.tasks ++= [ Task task, list, model ]
|
list.tasks ++= [ Task task, list, model ]
|
||||||
@ -272,14 +264,6 @@ render-project = (project-id) ->
|
|||||||
bulma.title 3 "Error, we did not get the project id " + project-id
|
bulma.title 3 "Error, we did not get the project id " + project-id
|
||||||
]
|
]
|
||||||
|
|
||||||
#
|
|
||||||
# Pages:
|
|
||||||
# login
|
|
||||||
# project-list
|
|
||||||
# project
|
|
||||||
# network-error
|
|
||||||
#
|
|
||||||
|
|
||||||
render-body = ->
|
render-body = ->
|
||||||
h \div.section [
|
h \div.section [
|
||||||
switch model.current-view
|
switch model.current-view
|
||||||
|
@ -6,18 +6,26 @@ 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, {}
|
self.tasks-objects = self.tasks.map (e) -> Task e, self, {}
|
||||||
|
|
||||||
modal = void
|
modal = void
|
||||||
|
|
||||||
|
self.tasks-updated = ->
|
||||||
|
self.tasks-objects = self.tasks.map (e) -> Task e, self, {}
|
||||||
|
|
||||||
self.render-column = (column, first) ->
|
self.render-column = (column, first) ->
|
||||||
# FIXME: display unregistred tasks in the first column
|
# FIXME: display unregistred tasks in the first column
|
||||||
|
tasks-to-display = self.tasks-objects.filter (task) ->
|
||||||
|
task.extra_properties && task.extra_properties.column && task.extra_properties.column == column.id || ((! task.extra_properties || ! task.extra_properties.column) && first)
|
||||||
|
|
||||||
|
console.log "TASKS", self.tasks
|
||||||
|
console.log "TASKS-OBJECTS", self.tasks-objects
|
||||||
|
console.log "TASKS TO DISPLAY", tasks-to-display
|
||||||
|
|
||||||
h \div.column [
|
h \div.column [
|
||||||
bulma.title 4 column.title
|
bulma.title 4 column.title
|
||||||
self.tasks.filter (task) ->
|
tasks-to-display.map (task) ->
|
||||||
task-column = task.extra_properties.column
|
h \div [ task.title ]
|
||||||
task-column == column.id || (! task-column && first)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
self.render = ->
|
self.render = ->
|
||||||
|
357
client/task.ls
357
client/task.ls
@ -32,197 +32,200 @@ get-next = (collection, element) ->
|
|||||||
|
|
||||||
Task = (self, project, model) ->
|
Task = (self, project, model) ->
|
||||||
self.render = ->
|
self.render = ->
|
||||||
author = model.users[self.author]
|
h \div [ "coucou" ]
|
||||||
if typeof(author) != "object" and author != "request sent"
|
|
||||||
model.users[self.author] = "request sent"
|
|
||||||
# FIXME: This should go directly to authd.
|
|
||||||
model.todod-ws.get-user self.author
|
|
||||||
|
|
||||||
assigned_to = model.users[self.assigned_to]
|
# self.render-old = ->
|
||||||
if self.assigned_to and typeof(assigned_to) != "object" and assigned_to != "request sent"
|
# author = model.users[self.author]
|
||||||
model.users[self.assigned_to] = "request sent"
|
# if typeof(author) != "object" and author != "request sent"
|
||||||
# FIXME: This should go directly to authd.
|
# model.users[self.author] = "request sent"
|
||||||
model.todod-ws.get-user self.assigned_to
|
# # FIXME: This should go directly to authd.
|
||||||
|
# model.todod-ws.get-user self.author
|
||||||
|
|
||||||
is-selected = model.selected == self.id
|
# assigned_to = model.users[self.assigned_to]
|
||||||
|
# if self.assigned_to and typeof(assigned_to) != "object" and assigned_to != "request sent"
|
||||||
|
# model.users[self.assigned_to] = "request sent"
|
||||||
|
# # FIXME: This should go directly to authd.
|
||||||
|
# model.todod-ws.get-user self.assigned_to
|
||||||
|
|
||||||
h (\div.card.is- + (self.color || "dark")), {
|
# is-selected = model.selected == self.id
|
||||||
key: self.id
|
|
||||||
classes: {
|
|
||||||
"is-selected": is-selected
|
|
||||||
}
|
|
||||||
onclick: ->
|
|
||||||
model.selected := self.id
|
|
||||||
} [
|
|
||||||
h \div.card-content [
|
|
||||||
h \div.media [
|
|
||||||
h \div.media-left [
|
|
||||||
h \img.image.is-48x48.avatar {
|
|
||||||
alt: "user image"
|
|
||||||
src: if typeof(assigned_to) == "object"
|
|
||||||
assigned_to.avatar
|
|
||||||
else
|
|
||||||
"https://bulma.io/images/placeholders/96x96.png"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
h \div.media-content [
|
|
||||||
if model.editing == self.id + ".title"
|
|
||||||
h \input.input {
|
|
||||||
value: self.title
|
|
||||||
onchange: (e) ->
|
|
||||||
model.editing := undefined
|
|
||||||
model.todod-ws.edit-task project.id, self.id, {
|
|
||||||
title: e.target.value
|
|
||||||
}
|
|
||||||
} [ self.title ]
|
|
||||||
else
|
|
||||||
h \a [
|
|
||||||
bulma.title 4 self.title
|
|
||||||
]
|
|
||||||
|
|
||||||
if typeof(model.users[self.assigned_to]) == "object"
|
# h (\div.card.is- + (self.color || "dark")), {
|
||||||
user = model.users[self.assigned_to]
|
# key: self.id
|
||||||
|
# classes: {
|
||||||
|
# "is-selected": is-selected
|
||||||
|
# }
|
||||||
|
# onclick: ->
|
||||||
|
# model.selected := self.id
|
||||||
|
# } [
|
||||||
|
# h \div.card-content [
|
||||||
|
# h \div.media [
|
||||||
|
# h \div.media-left [
|
||||||
|
# h \img.image.is-48x48.avatar {
|
||||||
|
# alt: "user image"
|
||||||
|
# src: if typeof(assigned_to) == "object"
|
||||||
|
# assigned_to.avatar
|
||||||
|
# else
|
||||||
|
# "https://bulma.io/images/placeholders/96x96.png"
|
||||||
|
# }
|
||||||
|
# ]
|
||||||
|
# h \div.media-content [
|
||||||
|
# if model.editing == self.id + ".title"
|
||||||
|
# h \input.input {
|
||||||
|
# value: self.title
|
||||||
|
# onchange: (e) ->
|
||||||
|
# model.editing := undefined
|
||||||
|
# model.todod-ws.edit-task project.id, self.id, {
|
||||||
|
# title: e.target.value
|
||||||
|
# }
|
||||||
|
# } [ self.title ]
|
||||||
|
# else
|
||||||
|
# h \a [
|
||||||
|
# bulma.title 4 self.title
|
||||||
|
# ]
|
||||||
|
|
||||||
h \div.subtitle.is-6 [
|
# if typeof(model.users[self.assigned_to]) == "object"
|
||||||
"@" + (user.full_name || user.login)
|
# user = model.users[self.assigned_to]
|
||||||
]
|
|
||||||
]
|
|
||||||
if ! is-selected && self.description != ""
|
|
||||||
h \div.media-right {key: "description-icon"} [
|
|
||||||
h \span.icon.is-size-1 [ "🗎" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
if is-selected
|
# h \div.subtitle.is-6 [
|
||||||
h \div.media-right {key: "edit"} [
|
# "@" + (user.full_name || user.login)
|
||||||
h \a.small {
|
# ]
|
||||||
onclick: ->
|
# ]
|
||||||
if model.editing == self.id + ".title"
|
# if ! is-selected && self.description != ""
|
||||||
model.editing := undefined
|
# h \div.media-right {key: "description-icon"} [
|
||||||
else
|
# h \span.icon.is-size-1 [ "🗎" ]
|
||||||
model.editing := self.id + ".title"
|
# ]
|
||||||
} [
|
|
||||||
"Edit"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
if is-selected
|
# if is-selected
|
||||||
h \div.media-right {key: "delete"} [
|
# h \div.media-right {key: "edit"} [
|
||||||
h \a.small {
|
# h \a.small {
|
||||||
onclick: ->
|
# onclick: ->
|
||||||
model.editing := self.id + ".delete"
|
# if model.editing == self.id + ".title"
|
||||||
} [
|
# model.editing := undefined
|
||||||
"Delete"
|
# else
|
||||||
]
|
# model.editing := self.id + ".title"
|
||||||
]
|
# } [
|
||||||
]
|
# "Edit"
|
||||||
|
# ]
|
||||||
|
# ]
|
||||||
|
|
||||||
if is-selected
|
# if is-selected
|
||||||
h \div.content {
|
# h \div.media-right {key: "delete"} [
|
||||||
key: self.description
|
# h \a.small {
|
||||||
after-create: (dom) ->
|
# onclick: ->
|
||||||
dom.innerHTML = nmd self.description
|
# model.editing := self.id + ".delete"
|
||||||
} [
|
# } [
|
||||||
if model.editing == self.id + ".description"
|
# "Delete"
|
||||||
h \form.form [
|
# ]
|
||||||
h \textarea.textarea {
|
# ]
|
||||||
value: model.editing-data
|
# ]
|
||||||
oninput: (e) ->
|
|
||||||
model.editing-data := e.target.value
|
|
||||||
}
|
|
||||||
h \div.button.is-fullwidth {
|
|
||||||
onclick: ->
|
|
||||||
model.todod-ws.edit-task project.id, self.id, {
|
|
||||||
description: model.editing-data
|
|
||||||
}
|
|
||||||
model.editing-data := undefined
|
|
||||||
model.editing := undefined
|
|
||||||
} [ "Update" ]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
if is-selected
|
# if is-selected
|
||||||
h \span.button.is-small {
|
# h \div.content {
|
||||||
onclick: ->
|
# key: self.description
|
||||||
model.editing-data := self.description
|
# after-create: (dom) ->
|
||||||
model.editing := self.id + ".description"
|
# dom.innerHTML = nmd self.description
|
||||||
} [
|
# } [
|
||||||
"edit"
|
# if model.editing == self.id + ".description"
|
||||||
]
|
# h \form.form [
|
||||||
]
|
# h \textarea.textarea {
|
||||||
|
# value: model.editing-data
|
||||||
|
# oninput: (e) ->
|
||||||
|
# model.editing-data := e.target.value
|
||||||
|
# }
|
||||||
|
# h \div.button.is-fullwidth {
|
||||||
|
# onclick: ->
|
||||||
|
# model.todod-ws.edit-task project.id, self.id, {
|
||||||
|
# description: model.editing-data
|
||||||
|
# }
|
||||||
|
# model.editing-data := undefined
|
||||||
|
# model.editing := undefined
|
||||||
|
# } [ "Update" ]
|
||||||
|
# ]
|
||||||
|
# ]
|
||||||
|
|
||||||
if is-selected
|
# if is-selected
|
||||||
h \div.card-footer {key: "assign"} [
|
# h \span.button.is-small {
|
||||||
if model.editing == self.id + ".assigned_to"
|
# onclick: ->
|
||||||
h \div.card-footer-item {
|
# model.editing-data := self.description
|
||||||
key: "assign.clicked"
|
# model.editing := self.id + ".description"
|
||||||
} [
|
# } [
|
||||||
h \input.input {
|
# "edit"
|
||||||
onchange: (e) ->
|
# ]
|
||||||
model.editing := undefined
|
# ]
|
||||||
model.todod-ws.edit-task project.id, self.id, {
|
|
||||||
assigned_to: Number e.target.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else
|
|
||||||
h \a.card-footer-item {
|
|
||||||
key: "assign"
|
|
||||||
onclick: ->
|
|
||||||
model.editing := self.id + ".assigned_to"
|
|
||||||
} [ "Assign" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
if is-selected
|
# if is-selected
|
||||||
h \div.card-footer {key: "color"} [
|
# h \div.card-footer {key: "assign"} [
|
||||||
if model.editing == self.id + ".color"
|
# if model.editing == self.id + ".assigned_to"
|
||||||
h \div.card-footer-item {
|
# h \div.card-footer-item {
|
||||||
key: "color.clicked"
|
# key: "assign.clicked"
|
||||||
} [
|
# } [
|
||||||
h \input.input {
|
# h \input.input {
|
||||||
onchange: (e) ->
|
# onchange: (e) ->
|
||||||
model.editing := undefined
|
# model.editing := undefined
|
||||||
model.todod-ws.edit-task project.id, self.id, {
|
# model.todod-ws.edit-task project.id, self.id, {
|
||||||
color: e.target.value
|
# assigned_to: Number e.target.value
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
]
|
# ]
|
||||||
else
|
# else
|
||||||
h \a.card-footer-item {
|
# h \a.card-footer-item {
|
||||||
key: "assign"
|
# key: "assign"
|
||||||
onclick: ->
|
# onclick: ->
|
||||||
model.editing := self.id + ".color"
|
# model.editing := self.id + ".assigned_to"
|
||||||
} [ "Change Color" ]
|
# } [ "Assign" ]
|
||||||
]
|
# ]
|
||||||
|
|
||||||
if is-selected
|
# if is-selected
|
||||||
h \div.card-footer {key: "move"} [
|
# h \div.card-footer {key: "color"} [
|
||||||
h \a.card-footer-item {
|
# if model.editing == self.id + ".color"
|
||||||
key: "⇐"
|
# h \div.card-footer-item {
|
||||||
onclick: ->
|
# key: "color.clicked"
|
||||||
model.todod-ws.edit-task project.id, self.id, {
|
# } [
|
||||||
column: get-previous project.columns.map((.id)), self.column
|
# h \input.input {
|
||||||
}
|
# onchange: (e) ->
|
||||||
} [ "⇐" ]
|
# model.editing := undefined
|
||||||
|
# model.todod-ws.edit-task project.id, self.id, {
|
||||||
|
# color: e.target.value
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# ]
|
||||||
|
# else
|
||||||
|
# h \a.card-footer-item {
|
||||||
|
# key: "assign"
|
||||||
|
# onclick: ->
|
||||||
|
# model.editing := self.id + ".color"
|
||||||
|
# } [ "Change Color" ]
|
||||||
|
# ]
|
||||||
|
|
||||||
if model.editing == self.id + ".delete"
|
# if is-selected
|
||||||
h \a.card-footer-item {
|
# h \div.card-footer {key: "move"} [
|
||||||
key: "delete"
|
# h \a.card-footer-item {
|
||||||
} [
|
# key: "⇐"
|
||||||
h \div.button.is-danger {
|
# onclick: ->
|
||||||
onclick: ->
|
# model.todod-ws.edit-task project.id, self.id, {
|
||||||
model.todod-ws.delete-task project.id, self.id
|
# column: get-previous project.columns.map((.id)), self.column
|
||||||
} [ "Delete! For real!" ]
|
# }
|
||||||
]
|
# } [ "⇐" ]
|
||||||
|
|
||||||
h \a.card-footer-item {
|
# if model.editing == self.id + ".delete"
|
||||||
key: "⇒"
|
# h \a.card-footer-item {
|
||||||
onclick: ->
|
# key: "delete"
|
||||||
model.todod-ws.edit-task project.id, self.id, {
|
# } [
|
||||||
column: get-next project.columns.map((.id)), self.column
|
# h \div.button.is-danger {
|
||||||
}
|
# onclick: ->
|
||||||
} [ "⇒" ]
|
# model.todod-ws.delete-task project.id, self.id
|
||||||
]
|
# } [ "Delete! For real!" ]
|
||||||
]
|
# ]
|
||||||
|
|
||||||
|
# h \a.card-footer-item {
|
||||||
|
# key: "⇒"
|
||||||
|
# onclick: ->
|
||||||
|
# model.todod-ws.edit-task project.id, self.id, {
|
||||||
|
# column: get-next project.columns.map((.id)), self.column
|
||||||
|
# }
|
||||||
|
# } [ "⇒" ]
|
||||||
|
# ]
|
||||||
|
# ]
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user