todo-webclient/client/navbar.ls

76 lines
1.6 KiB
Plaintext

{h} = require "maquette"
{button, field, control} = require "./bulma.ls"
{icon} = require "./font-awesome.ls"
Modal = require "./modal.ls"
UUID = require "uuid/v4"
ProjectCreationModal = require "./project-creation-modal.ls"
Column = (title) ->
{
title: title
id: UUID! # TODO FIXME XXX
}
Navbar = ->
self = {}
self.render = (model) ->
h \div.navbar [
h \div.navbar-start [
h \div.navbar-brand [
h \a.navbar-item {
onclick: ->
if model.viewed-project
model.todod-ws.unsubscribe model.viewed-project.id
model.todod-ws.list-lists!
model.viewed-project := void
model.current-view := "project-list"
} [
"todod - kanbanc"
]
]
]
if model.current-view == "project" && model.viewed-project
model.viewed-project.inner-nav-render!
if model.current-view != "login"
h \div.navbar-end [
if model.current-view == "project-list"
h \a.navbar-item.has-text-success {
key: \new-project
onclick: ->
model.modal := ProjectCreationModal {
on-validation: (project) ->
model.todod-ws.add-list project.title, project
}
} [
h \span [ "New project" ]
icon \plus
]
else if model.current-view == "project" && model.viewed-project
model.viewed-project.right-nav-render!
h \a.navbar-item {
key: "logout"
onclick: ->
model.current-view := "login"
# TODO: remove anything related to the old session on the client
model.todod-ws.reopen!
} [
h \span [ "Logout" ]
icon \sign-out-alt
]
]
]
self
module.exports = Navbar