Update project list every time we get the project list page.
This commit is contained in:
parent
5fa8f32d77
commit
fb46723759
@ -163,19 +163,19 @@ model.todod-ws.user-on-socket-error ++= [ on-websocket-error ]
|
||||
model.todod-ws.user-on-socket-close ++= [ on-websocket-close ]
|
||||
|
||||
model.todod-ws.add-event-listener \lists-list, (message) ->
|
||||
# console.log message
|
||||
console.log "Project list received", message
|
||||
model.project-list := message.lists.map (x) ->
|
||||
Project x, model.todod-ws
|
||||
|
||||
projector.schedule-render!
|
||||
|
||||
model.todod-ws.add-event-listener \new-list, (message) ->
|
||||
console.log message
|
||||
console.log "New project", message
|
||||
model.project-list := model.project-list ++ [ (Project message.list, model.todod-ws) ]
|
||||
projector.schedule-render!
|
||||
|
||||
model.todod-ws.add-event-listener \list-updated, (message) ->
|
||||
console.log message
|
||||
console.log "Project updated", message
|
||||
|
||||
new-project = Project message.list, model.todod-ws
|
||||
|
||||
@ -194,12 +194,11 @@ model.todod-ws.add-event-listener \tasks, (message) ->
|
||||
console.log "Tasks received", message
|
||||
project = model.project-list.find((.id == message.list))
|
||||
model.project-list.find((.id == message.list)).tasks := message.tasks.map (e) -> Task e, project, model.todod-ws
|
||||
console.log "Once done: ", model.project-list.find((.id == message.list)).tasks
|
||||
projector.schedule-render!
|
||||
|
||||
model.todod-ws.add-event-listener \list-removed, (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.id == message.list
|
||||
model.current-view := "project-list"
|
||||
model.viewed-project := void
|
||||
projector.schedule-render!
|
||||
@ -249,6 +248,7 @@ render-navbar = ->
|
||||
h \a.navbar-item.is-size-2 {
|
||||
onclick: ->
|
||||
model.todod-ws.unsubscribe model.viewed-project.id
|
||||
model.todod-ws.list-lists!
|
||||
model.viewed-project := void
|
||||
model.current-view := "project-list"
|
||||
} [ "⌂" ]
|
||||
@ -269,7 +269,7 @@ render-project-list = ->
|
||||
key: project.id
|
||||
onclick: ->
|
||||
model.current-view := "project"
|
||||
model.viewed-project := project.id
|
||||
model.viewed-project := project
|
||||
model.todod-ws.subscribe project.id
|
||||
model.todod-ws.get-list project.id
|
||||
model.todod-ws.get-tasks project.id
|
||||
@ -299,14 +299,12 @@ render-new-project-button = ->
|
||||
}
|
||||
} [ "New project!" ]
|
||||
|
||||
render-project = (project-id) ->
|
||||
project = model.project-list.find((.id == project-id))
|
||||
|
||||
render-project = (project) ->
|
||||
if project
|
||||
project.render!
|
||||
else
|
||||
h \div.notification.is-error [
|
||||
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
|
||||
]
|
||||
|
||||
render-body = ->
|
||||
|
Loading…
Reference in New Issue
Block a user