This commit is contained in:
Philippe PITTOLI 2019-12-05 01:45:21 +01:00
parent 65084c3247
commit 9b6179eccf
3 changed files with 65 additions and 47 deletions

View File

@ -37,7 +37,7 @@ main.js: main.bundle.js
$(Q)npx babel --minified main.bundle.js -o main.js $(Q)npx babel --minified main.bundle.js -o main.js
main.bundle.js: client/index.ls client/authd.ls client/bulma.ls client/modal.ls client/project.ls client/task.ls client/todowebsocket.ls main.bundle.js: client/index.ls client/authd.ls client/bulma.ls client/modal.ls client/project.ls client/task.ls client/todowebsocket.ls client/validation-modal.ls
@echo ' BUN > main.bundle.js' @echo ' BUN > main.bundle.js'
$(Q)npx browserify -t browserify-livescript client/index.ls -o main.bundle.js $(Q)npx browserify -t browserify-livescript client/index.ls -o main.bundle.js
@ -121,7 +121,8 @@ $(PACKAGE)-$(VERSION).tar.gz: distdir
$(PACKAGE)-$(VERSION)/client/modal.ls \ $(PACKAGE)-$(VERSION)/client/modal.ls \
$(PACKAGE)-$(VERSION)/client/project.ls \ $(PACKAGE)-$(VERSION)/client/project.ls \
$(PACKAGE)-$(VERSION)/client/task.ls \ $(PACKAGE)-$(VERSION)/client/task.ls \
$(PACKAGE)-$(VERSION)/client/todowebsocket.ls $(PACKAGE)-$(VERSION)/client/todowebsocket.ls \
$(PACKAGE)-$(VERSION)/client/validation-modal.ls
dist-xz: $(PACKAGE)-$(VERSION).tar.xz dist-xz: $(PACKAGE)-$(VERSION).tar.xz
$(PACKAGE)-$(VERSION).tar.xz: distdir $(PACKAGE)-$(VERSION).tar.xz: distdir
@ -135,7 +136,8 @@ $(PACKAGE)-$(VERSION).tar.xz: distdir
$(PACKAGE)-$(VERSION)/client/modal.ls \ $(PACKAGE)-$(VERSION)/client/modal.ls \
$(PACKAGE)-$(VERSION)/client/project.ls \ $(PACKAGE)-$(VERSION)/client/project.ls \
$(PACKAGE)-$(VERSION)/client/task.ls \ $(PACKAGE)-$(VERSION)/client/task.ls \
$(PACKAGE)-$(VERSION)/client/todowebsocket.ls $(PACKAGE)-$(VERSION)/client/todowebsocket.ls \
$(PACKAGE)-$(VERSION)/client/validation-modal.ls
dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2 dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
$(PACKAGE)-$(VERSION).tar.bz2: distdir $(PACKAGE)-$(VERSION).tar.bz2: distdir
@ -149,7 +151,8 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir
$(PACKAGE)-$(VERSION)/client/modal.ls \ $(PACKAGE)-$(VERSION)/client/modal.ls \
$(PACKAGE)-$(VERSION)/client/project.ls \ $(PACKAGE)-$(VERSION)/client/project.ls \
$(PACKAGE)-$(VERSION)/client/task.ls \ $(PACKAGE)-$(VERSION)/client/task.ls \
$(PACKAGE)-$(VERSION)/client/todowebsocket.ls $(PACKAGE)-$(VERSION)/client/todowebsocket.ls \
$(PACKAGE)-$(VERSION)/client/validation-modal.ls
help: help:
@echo ' :: todo-webclient-0.1' @echo ' :: todo-webclient-0.1'

View File

@ -33,14 +33,15 @@
# #
# page 3: (TODO) pages about # page 3: (TODO) pages about
maquette = require "maquette" maquette = require "maquette"
nmd = require "nano-markdown" nmd = require "nano-markdown"
authd = require "./authd.ls" authd = require "./authd.ls"
todows = require "./todowebsocket.ls" todows = require "./todowebsocket.ls"
bulma = require "./bulma.ls" bulma = require "./bulma.ls"
Task = require "./task.ls" Task = require "./task.ls"
Project = require "./project.ls" Project = require "./project.ls"
Modal = require "./modal.ls" Modal = require "./modal.ls"
# ValidationModal = require "./validation-modal.ls"
{create-projector, h} = maquette {create-projector, h} = maquette
projector = create-projector! projector = create-projector!
@ -48,22 +49,15 @@ projector = create-projector!
model = { model = {
# view: login, todo-list, todo, network-error (TODO: other views, such as rights) # view: login, todo-list, todo, network-error (TODO: other views, such as rights)
# XXX FIXME TODO: TESTING THINGS # XXX FIXME TODO: TESTING THINGS
# current-view: "login" current-view: "login"
current-view: "testing-modals"
# TODO: currently-editing viewed-project: void
editing: undefined
# TODO: currently-selected
selected: undefined
current-modal: true # current-view: "testing-modals"
# { uid => user data } # { uid => user data }
users: {} users: {}
# list of todos-list
projects: {}
todo-list: [] todo-list: []
port: 9999 port: 9999
@ -80,9 +74,6 @@ model = {
jwt: undefined jwt: undefined
} }
# TODO XXX FIXME
model.modal = Modal {+visible}
model.authd-url = model.authd-url =
(if location.protocol == 'https' then 'wss' else 'ws') + (if location.protocol == 'https' then 'wss' else 'ws') +
'://' + location.hostname + \: + '://' + location.hostname + \: +
@ -168,37 +159,42 @@ on-websocket-close = (event) ->
projector.schedule-render! projector.schedule-render!
# model.projects[message.project.id] = Project.new message.project, model
# record changes that need to happen on a network event # record changes that need to happen on a network event
model.todod-ws.user-on-socket-error ++= [ on-websocket-error ] model.todod-ws.user-on-socket-error ++= [ on-websocket-error ]
model.todod-ws.user-on-socket-close ++= [ on-websocket-close ] 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 message console.log message
model.todo-list := message.lists model.todo-list := message.lists.map (x) ->
for list in model.todo-list Project.new x, model
model.projects[list.id] := Project.new list, model
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 message console.log message
model.todo-list := model.todo-list ++ [ message.list ] model.todo-list := model.todo-list ++ [ (Project.new message.list, model) ]
model.projects[message.list.id] := Project.new message.list, model
projector.schedule-render! projector.schedule-render!
model.todod-ws.add-event-listener \tasks, (message) -> model.todod-ws.add-event-listener \tasks, (message) ->
console.log message console.log message
model.projects[message.list].tasks := message.tasks model.todo-list.find((.id == message.list)).tasks := message.tasks
projector.schedule-render! projector.schedule-render!
model.todod-ws.add-event-listener \list-removed, (message) ->
console.log message
if model.current-view == "todo" && model.viewed-project == message.list
model.current-view := "todo-list"
model.viewed-project := void
projector.schedule-render!
model.todo-list := model.todo-list.filter((.id != message.list))
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 {
onclick: -> onclick: ->
model.viewed-project := undefined model.viewed-project := void
model.current-view := "todo-list" model.current-view := "todo-list"
} [ "⌂" ] } [ "⌂" ]
] ]
@ -214,15 +210,16 @@ render-navbar = ->
render-todo-list = -> render-todo-list = ->
h \div.section model.todo-list.map (project) -> h \div.section model.todo-list.map (project) ->
h \a.box { if project
key: project.id h \div.box {
onclick: -> key: project.id
model.current-view := "todo" onclick: ->
model.viewed-project := project.id model.current-view := "todo"
model.todod-ws.get-list model.jwt, project.id model.viewed-project := project.id
} [ model.todod-ws.get-list model.jwt, project.id
bulma.title 4 project.title } [
] bulma.title 4 project.title
]
render-new-project-button = -> render-new-project-button = ->
h \div.button.is-primary.is-large.is-fullwidth { h \div.button.is-primary.is-large.is-fullwidth {
@ -233,8 +230,23 @@ render-new-project-button = ->
} [ "New project!" ] } [ "New project!" ]
render-todo = (todo-id) -> render-todo = (todo-id) ->
if model.projects[todo-id] todo = model.todo-list.find((.id == todo-id))
model.projects[todo-id].render! if todo
todo.render!
h \div.button.is-danger.is-outlined {
onclick: ->
console.log "La modal est crée"
model.modal := Modal {
+visible
content:
h \p [ "Are you sure you want to remove board #{todo.title}?" ]
on-validation: ->
model.todod-ws.remove-list model.jwt, todo.id
}
console.log "La modal est crée 2 le retour", model.modal
projector.schedule-render!
} [ "X" ]
else else
h \div.notification.is-error [ h \div.notification.is-error [
bulma.title 3 "Error, we did not get the todo id " + todo-id bulma.title 3 "Error, we did not get the todo id " + todo-id
@ -287,6 +299,9 @@ render-body = ->
h \div.notification.is-error [ h \div.notification.is-error [
"Wait, what? Internal error!" "Wait, what? Internal error!"
] ]
if model.modal
model.modal.render!
] ]

View File

@ -10,7 +10,7 @@ module.exports = {
self.render-column = (column) -> self.render-column = (column) ->
console.log "render column: ", column console.log "render column: ", column
bulma.modal {} [(h \div {} [ "rendering " + column ])] # bulma.modal {} [(h \div {} [ "rendering " + column ])]
# h \div.column.is-3 { # h \div.column.is-3 {
# key: column # key: column