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) ->
|
model.todod-ws.add-event-listener \lists-list, (message) ->
|
||||||
console.log "Project list received", message
|
console.log "Project list received", message
|
||||||
|
|
||||||
model.project-list := message.lists.map (x) ->
|
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!
|
projector.schedule-render!
|
||||||
|
|
||||||
model.todod-ws.add-event-listener \new-list, (message) ->
|
model.todod-ws.add-event-listener \new-list, (message) ->
|
||||||
console.log "New project", message
|
console.log "New project", message
|
||||||
|
|
||||||
model.project-list := model.project-list ++ [ (Project message.list, model.todod-ws) ]
|
model.project-list := model.project-list ++ [ (Project message.list, model.todod-ws) ]
|
||||||
projector.schedule-render!
|
projector.schedule-render!
|
||||||
|
|
||||||
@ -186,18 +194,14 @@ model.todod-ws.add-event-listener \list-updated, (message) ->
|
|||||||
project
|
project
|
||||||
|
|
||||||
if model.viewed-project && model.viewed-project.id == message.list.id
|
if model.viewed-project && model.viewed-project.id == message.list.id
|
||||||
|
new-project.tasks = model.viewed-project.tasks
|
||||||
model.viewed-project = new-project
|
model.viewed-project = new-project
|
||||||
|
|
||||||
projector.schedule-render!
|
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) ->
|
model.todod-ws.add-event-listener \list-removed, (message) ->
|
||||||
console.log "A list has been removed", message
|
console.log "A list has been removed", message
|
||||||
|
|
||||||
if model.current-view == "project" && model.viewed-project.id == message.list
|
if model.current-view == "project" && model.viewed-project.id == message.list
|
||||||
model.current-view := "project-list"
|
model.current-view := "project-list"
|
||||||
model.viewed-project := void
|
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))
|
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) ->
|
model.todod-ws.add-event-listener \task-created, (message) ->
|
||||||
console.log "A task has been created", 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
|
if list.id == model.viewed-project.id
|
||||||
|
model.viewed-project := list
|
||||||
|
|
||||||
if list
|
if list
|
||||||
list.tasks ++= [ Task task, list, model.todod-ws ]
|
list.tasks ++= [ Task task, list, model.todod-ws ]
|
||||||
@ -222,7 +241,6 @@ model.todod-ws.add-event-listener \task-updated, (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
|
|
||||||
|
|
||||||
if list
|
if list
|
||||||
list.tasks = list.tasks.map (e) ->
|
list.tasks = list.tasks.map (e) ->
|
||||||
@ -242,7 +260,9 @@ model.todod-ws.add-event-listener \task-removed, (message) ->
|
|||||||
projector.schedule-render!
|
projector.schedule-render!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
render-navbar = ->
|
render-navbar = ->
|
||||||
|
|
||||||
h \div.navbar [
|
h \div.navbar [
|
||||||
h \div.navbar-start [
|
h \div.navbar-start [
|
||||||
h \a.navbar-item.is-size-2 {
|
h \a.navbar-item.is-size-2 {
|
||||||
@ -253,7 +273,15 @@ render-navbar = ->
|
|||||||
model.current-view := "project-list"
|
model.current-view := "project-list"
|
||||||
} [ "⌂" ]
|
} [ "⌂" ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if model.viewed-project
|
||||||
|
model.viewed-project.inner-nav-render!
|
||||||
|
|
||||||
h \div.navbar-end [
|
h \div.navbar-end [
|
||||||
|
|
||||||
|
if model.viewed-project
|
||||||
|
model.viewed-project.right-nav-render!
|
||||||
|
|
||||||
h \a.navbar-item {
|
h \a.navbar-item {
|
||||||
onclick: ->
|
onclick: ->
|
||||||
model.current-view := "login"
|
model.current-view := "login"
|
||||||
|
@ -13,6 +13,7 @@ Project = (self, todod-ws) ->
|
|||||||
modal = void
|
modal = void
|
||||||
|
|
||||||
self.render-column = (column, first) ->
|
self.render-column = (column, first) ->
|
||||||
|
|
||||||
tasks-to-display = self.tasks.filter (task) ->
|
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 && task.extra_properties.column == column.id
|
||||||
|| ((! task.extra_properties || ! task.extra_properties.column) && first)
|
|| ((! task.extra_properties || ! task.extra_properties.column) && first)
|
||||||
@ -29,43 +30,36 @@ Project = (self, todod-ws) ->
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
self.render-navbar = ->
|
self.inner-nav-render = ->
|
||||||
h \div.navbar [
|
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-item [
|
||||||
]
|
h \div.button.is-outlined {
|
||||||
|
onclick: ->
|
||||||
|
modal := ProjectCreationModal self, self.todod-ws
|
||||||
|
} [ "Edit this project" ]
|
||||||
]
|
]
|
||||||
|
|
||||||
h \div.navbar-end [
|
h \div.navbar-item [
|
||||||
|
h \div.button.is-success.is-outlined {
|
||||||
|
onclick: ->
|
||||||
|
modal := TaskCreationModal self, self.todod-ws
|
||||||
|
} [ "New task" ]
|
||||||
|
]
|
||||||
|
|
||||||
h \div.navbar-item [
|
h \div.navbar-item [
|
||||||
h \div.button.is-danger.is-outlined {
|
h \div.button.is-danger.is-outlined {
|
||||||
onclick: ->
|
onclick: ->
|
||||||
modal := ProjectCreationModal self, self.todod-ws
|
modal := Modal {
|
||||||
} [ "EDIT" ]
|
+visible
|
||||||
]
|
content:
|
||||||
|
h \p [ "Are you sure you want to remove board #{self.title}?" ]
|
||||||
h \div.navbar-item [
|
on-validation: ->
|
||||||
h \div.button.is-success.is-outlined {
|
self.todod-ws.remove-list self.id
|
||||||
onclick: ->
|
}
|
||||||
modal := TaskCreationModal self, self.todod-ws
|
} [ "Delete this project" ]
|
||||||
} [ "+" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
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" ]
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -74,8 +68,6 @@ Project = (self, todod-ws) ->
|
|||||||
# console.log "Project to render: ", self
|
# console.log "Project to render: ", self
|
||||||
h \div.project {} [
|
h \div.project {} [
|
||||||
|
|
||||||
self.render-navbar!
|
|
||||||
|
|
||||||
h \div.columns [
|
h \div.columns [
|
||||||
if columns = self.extra_properties.columns
|
if columns = self.extra_properties.columns
|
||||||
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
|
for dom in columns.map((column, index) -> self.render-column(column, index == 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user