new project navbar
This commit is contained in:
parent
fb46723759
commit
7cfe504890
@ -164,13 +164,21 @@ model.todod-ws.user-on-socket-close ++= [ on-websocket-close ]
|
||||
|
||||
model.todod-ws.add-event-listener \lists-list, (message) ->
|
||||
console.log "Project list received", message
|
||||
|
||||
model.project-list := message.lists.map (x) ->
|
||||
Project x, model.todod-ws
|
||||
old-project = model.project-list.find((.id == x.id))
|
||||
new-project = Project x, model.todod-ws
|
||||
|
||||
if old-project && new-project.id == old-project.id
|
||||
new-project.tasks = old-project.tasks
|
||||
|
||||
new-project
|
||||
|
||||
projector.schedule-render!
|
||||
|
||||
model.todod-ws.add-event-listener \new-list, (message) ->
|
||||
console.log "New project", message
|
||||
|
||||
model.project-list := model.project-list ++ [ (Project message.list, model.todod-ws) ]
|
||||
projector.schedule-render!
|
||||
|
||||
@ -186,18 +194,14 @@ model.todod-ws.add-event-listener \list-updated, (message) ->
|
||||
project
|
||||
|
||||
if model.viewed-project && model.viewed-project.id == message.list.id
|
||||
new-project.tasks = model.viewed-project.tasks
|
||||
model.viewed-project = new-project
|
||||
|
||||
projector.schedule-render!
|
||||
|
||||
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
|
||||
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.id == message.list
|
||||
model.current-view := "project-list"
|
||||
model.viewed-project := void
|
||||
@ -205,12 +209,27 @@ model.todod-ws.add-event-listener \list-removed, (message) ->
|
||||
|
||||
model.project-list := model.project-list.filter((.id != message.list))
|
||||
|
||||
|
||||
# tasks
|
||||
|
||||
model.todod-ws.add-event-listener \tasks, (message) ->
|
||||
console.log "Tasks received", message
|
||||
|
||||
project = model.project-list.find((.id == message.list))
|
||||
project.tasks := message.tasks.map (e) -> Task e, project, model.todod-ws
|
||||
|
||||
if model.viewed-project.id == project.id
|
||||
model.viewed-project := project
|
||||
|
||||
projector.schedule-render!
|
||||
|
||||
model.todod-ws.add-event-listener \task-created, (message) ->
|
||||
console.log "A task has been created", message
|
||||
|
||||
task = message.task
|
||||
list = model.project-list.find((.id == task.list))
|
||||
# console.log task, list
|
||||
if list.id == model.viewed-project.id
|
||||
model.viewed-project := list
|
||||
|
||||
if list
|
||||
list.tasks ++= [ Task task, list, model.todod-ws ]
|
||||
@ -222,7 +241,6 @@ model.todod-ws.add-event-listener \task-updated, (message) ->
|
||||
|
||||
task = message.task
|
||||
list = model.project-list.find((.id == task.list))
|
||||
# console.log task, list
|
||||
|
||||
if list
|
||||
list.tasks = list.tasks.map (e) ->
|
||||
@ -242,7 +260,9 @@ model.todod-ws.add-event-listener \task-removed, (message) ->
|
||||
projector.schedule-render!
|
||||
|
||||
|
||||
|
||||
render-navbar = ->
|
||||
|
||||
h \div.navbar [
|
||||
h \div.navbar-start [
|
||||
h \a.navbar-item.is-size-2 {
|
||||
@ -253,7 +273,15 @@ render-navbar = ->
|
||||
model.current-view := "project-list"
|
||||
} [ "⌂" ]
|
||||
]
|
||||
|
||||
if model.viewed-project
|
||||
model.viewed-project.inner-nav-render!
|
||||
|
||||
h \div.navbar-end [
|
||||
|
||||
if model.viewed-project
|
||||
model.viewed-project.right-nav-render!
|
||||
|
||||
h \a.navbar-item {
|
||||
onclick: ->
|
||||
model.current-view := "login"
|
||||
|
@ -13,6 +13,7 @@ Project = (self, todod-ws) ->
|
||||
modal = void
|
||||
|
||||
self.render-column = (column, first) ->
|
||||
|
||||
tasks-to-display = self.tasks.filter (task) ->
|
||||
task.extra_properties && task.extra_properties.column && task.extra_properties.column == column.id
|
||||
|| ((! task.extra_properties || ! task.extra_properties.column) && first)
|
||||
@ -29,29 +30,23 @@ Project = (self, todod-ws) ->
|
||||
]
|
||||
]
|
||||
|
||||
self.render-navbar = ->
|
||||
h \div.navbar [
|
||||
self.inner-nav-render = ->
|
||||
h \div.navbar-item [ h \a.subtitle.is-3 [ self.title ] ]
|
||||
|
||||
h \div.navbar-brand [
|
||||
self.right-nav-render = ->
|
||||
[
|
||||
h \div.navbar-item [
|
||||
self.title
|
||||
]
|
||||
]
|
||||
|
||||
h \div.navbar-end [
|
||||
|
||||
h \div.navbar-item [
|
||||
h \div.button.is-danger.is-outlined {
|
||||
h \div.button.is-outlined {
|
||||
onclick: ->
|
||||
modal := ProjectCreationModal self, self.todod-ws
|
||||
} [ "EDIT" ]
|
||||
} [ "Edit this project" ]
|
||||
]
|
||||
|
||||
h \div.navbar-item [
|
||||
h \div.button.is-success.is-outlined {
|
||||
onclick: ->
|
||||
modal := TaskCreationModal self, self.todod-ws
|
||||
} [ "+" ]
|
||||
} [ "New task" ]
|
||||
]
|
||||
|
||||
h \div.navbar-item [
|
||||
@ -64,8 +59,7 @@ Project = (self, todod-ws) ->
|
||||
on-validation: ->
|
||||
self.todod-ws.remove-list self.id
|
||||
}
|
||||
} [ "X" ]
|
||||
]
|
||||
} [ "Delete this project" ]
|
||||
]
|
||||
]
|
||||
|
||||
@ -74,8 +68,6 @@ Project = (self, todod-ws) ->
|
||||
# console.log "Project to render: ", self
|
||||
h \div.project {} [
|
||||
|
||||
self.render-navbar!
|
||||
|
||||
h \div.columns [
|
||||
if columns = self.extra_properties.columns
|
||||
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
|
||||
|
Loading…
Reference in New Issue
Block a user