2019-12-12 21:49:15 +01:00
|
|
|
{h} = require "maquette"
|
|
|
|
|
|
|
|
{button, field, control} = require "./bulma.ls"
|
2019-12-20 01:34:41 +01:00
|
|
|
{icon} = require "./font-awesome.ls"
|
2019-12-12 21:49:15 +01:00
|
|
|
|
2019-12-20 01:34:41 +01:00
|
|
|
Modal = require "./modal.ls"
|
|
|
|
UUID = require "uuid/v4"
|
|
|
|
|
|
|
|
ProjectCreationModal = require "./project-creation-modal.ls"
|
2019-12-12 21:49:15 +01:00
|
|
|
|
2019-12-20 01:34:41 +01:00
|
|
|
Column = (title) ->
|
|
|
|
{
|
|
|
|
title: title
|
|
|
|
id: UUID! # TODO FIXME XXX
|
|
|
|
}
|
2019-12-12 21:49:15 +01:00
|
|
|
|
|
|
|
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"
|
2019-12-20 01:34:41 +01:00
|
|
|
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
|
2019-12-12 21:49:15 +01:00
|
|
|
]
|
|
|
|
else if model.current-view == "project" && model.viewed-project
|
|
|
|
model.viewed-project.right-nav-render!
|
|
|
|
|
2019-12-20 01:34:41 +01:00
|
|
|
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
|
2019-12-12 21:49:15 +01:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
self
|
|
|
|
|
|
|
|
module.exports = Navbar
|
|
|
|
|