Grooming.
This commit is contained in:
parent
8983e000c0
commit
f70f8a17f3
220
client/index.ls
220
client/index.ls
@ -33,19 +33,13 @@ Task = (self, project) ->
|
||||
if typeof(author) != "object" and author != "request sent"
|
||||
model.users[self.author] = "request sent"
|
||||
# FIXME: This should go directly to authd.
|
||||
socket.send JSON.stringify {
|
||||
type: "get-user"
|
||||
uid: self.author
|
||||
}
|
||||
socket.get-user self.author
|
||||
|
||||
assigned_to = model.users[self.assigned_to]
|
||||
if self.assigned_to and typeof(assigned_to) != "object" and assigned_to != "request sent"
|
||||
model.users[self.assigned_to] = "request sent"
|
||||
# FIXME: This should go directly to authd.
|
||||
socket.send JSON.stringify {
|
||||
type: "get-user"
|
||||
uid: self.assigned_to
|
||||
}
|
||||
socket.get-user self.assigned_to
|
||||
|
||||
is-selected = model.selected == self.id
|
||||
|
||||
@ -74,10 +68,7 @@ Task = (self, project) ->
|
||||
value: self.title
|
||||
onchange: (e) ->
|
||||
model.editing := undefined
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
socket.edit-task project.id, self.id, {
|
||||
title: e.target.value
|
||||
}
|
||||
} [ self.title ]
|
||||
@ -137,10 +128,7 @@ Task = (self, project) ->
|
||||
}
|
||||
h \div.button.is-fullwidth {
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
socket.edit-task project.id, self.id, {
|
||||
description: model.editing-data
|
||||
}
|
||||
model.editing-data := undefined
|
||||
@ -168,10 +156,7 @@ Task = (self, project) ->
|
||||
h \input.input {
|
||||
onchange: (e) ->
|
||||
model.editing := undefined
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
socket.edit-task project.id, self.id, {
|
||||
assigned_to: Number e.target.value
|
||||
}
|
||||
}
|
||||
@ -193,10 +178,7 @@ Task = (self, project) ->
|
||||
h \input.input {
|
||||
onchange: (e) ->
|
||||
model.editing := undefined
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
socket.edit-task project.id, self.id, {
|
||||
color: e.target.value
|
||||
}
|
||||
}
|
||||
@ -214,10 +196,7 @@ Task = (self, project) ->
|
||||
h \a.card-footer-item {
|
||||
key: "⇐"
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
socket.edit-task project.id, self.id, {
|
||||
column: get-previous project.columns.map((.id)), self.column
|
||||
}
|
||||
} [ "⇐" ]
|
||||
@ -228,21 +207,14 @@ Task = (self, project) ->
|
||||
} [
|
||||
h \div.button.is-danger {
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "delete-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
}
|
||||
socket.delete-task project.id, self.id
|
||||
} [ "Delete! For real!" ]
|
||||
]
|
||||
|
||||
h \a.card-footer-item {
|
||||
key: "⇒"
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-task"
|
||||
project: project.id
|
||||
task: self.id
|
||||
socket.edit-task project.id, self.id, {
|
||||
column: get-next project.columns.map((.id)), self.column
|
||||
}
|
||||
} [ "⇒" ]
|
||||
@ -270,10 +242,7 @@ Project = (self) ->
|
||||
console.log "onchange??"
|
||||
model.editing := undefined
|
||||
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-column"
|
||||
project: self.id
|
||||
column: column.id
|
||||
socket.edit-column self.id, column.id, {
|
||||
name: e.target.value
|
||||
}
|
||||
}
|
||||
@ -306,11 +275,7 @@ Project = (self) ->
|
||||
h \div.card-content [
|
||||
h \div.button.is-fullwidth.is-danger {
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "delete-column"
|
||||
project: self.id
|
||||
column: column.id
|
||||
}
|
||||
socket.delete-column self.id, column.id
|
||||
} [ "Delete me!"]
|
||||
]
|
||||
]
|
||||
@ -322,10 +287,7 @@ Project = (self) ->
|
||||
|
||||
h \div.button.is-fullwidth {
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "new-task"
|
||||
project: self.id
|
||||
column: column.id
|
||||
socket.new-task self.id, column.id, {
|
||||
title: "General Kenobi…"
|
||||
description: ""
|
||||
}
|
||||
@ -350,9 +312,7 @@ Project = (self) ->
|
||||
h \input.input {
|
||||
onchange: (e) ->
|
||||
model.editing := undefined
|
||||
socket.send JSON.stringify {
|
||||
type: "edit-project"
|
||||
project: self.id
|
||||
socket.edit-project self.id, {
|
||||
name: e.target.value
|
||||
}
|
||||
value: self.name
|
||||
@ -371,11 +331,7 @@ Project = (self) ->
|
||||
} [
|
||||
h \div.button.is-fullwidth {
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "new-column"
|
||||
project: self.id
|
||||
name: "Hello, there!"
|
||||
}
|
||||
socket.new-column self.id, "Hello, there!"
|
||||
} [ "New Column" ]
|
||||
]
|
||||
]
|
||||
@ -398,21 +354,131 @@ socket-url = protocol + '://' + location.hostname + port + "/socket"
|
||||
|
||||
console.log socket-url
|
||||
|
||||
socket = new WebSocket socket-url
|
||||
KanbanSocket = (socket-url) ->
|
||||
self = {}
|
||||
|
||||
socket.onopen = (event) ->
|
||||
# Nothing to do here ATM.
|
||||
self.open-socket = ->
|
||||
self.socket := new WebSocket socket-url
|
||||
|
||||
socket.onerror = (event) ->
|
||||
model.state = "websocket-error"
|
||||
projector.schedule-render!
|
||||
self.socket.onerror = (event) ->
|
||||
console.log "WebSocket error.", event
|
||||
model.state := "websocket-error"
|
||||
self.socket.close!
|
||||
projector.schedule-render!
|
||||
|
||||
socket.onclose = (event) ->
|
||||
model.state = "websocket-error"
|
||||
model.websocket-error = event.reason
|
||||
projector.schedule-render!
|
||||
self.socket.onclose = (event) ->
|
||||
# Exporting the error in case the UI is able to deal with it.
|
||||
model.previous-state := model.state
|
||||
model.state := "websocket-error"
|
||||
model.websocket-error := event.reason
|
||||
projector.schedule-render!
|
||||
|
||||
socket.onmessage = (event) ->
|
||||
self.socket.onmessage = (event) ->
|
||||
self.on-message event
|
||||
|
||||
self.open-socket!
|
||||
|
||||
self.send = (opts) ->
|
||||
self.socket.send opts
|
||||
|
||||
self.get-project = (project-id) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "project",
|
||||
project: project-id
|
||||
}
|
||||
|
||||
self.login = (login, password) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "login",
|
||||
login: login
|
||||
password: password
|
||||
}
|
||||
|
||||
self.get-user = (uid) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "get-user"
|
||||
uid: uid
|
||||
}
|
||||
|
||||
self.new-project = (name) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "new-project"
|
||||
name: name
|
||||
}
|
||||
|
||||
self.edit-task = (project-id, task-id, options) ->
|
||||
payload = {
|
||||
type: "edit-task"
|
||||
project: project-id
|
||||
task: task-id
|
||||
}
|
||||
|
||||
for key, value of options
|
||||
payload[key] = value
|
||||
|
||||
self.socket.send JSON.stringify payload
|
||||
|
||||
self.delete-task = (project-id, task-id) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "delete-task"
|
||||
project: project-id
|
||||
task: task-id
|
||||
}
|
||||
|
||||
self.edit-column = (project-id, column-id, options) ->
|
||||
payload = {
|
||||
type: "edit-column"
|
||||
project: project-id
|
||||
column: column-id
|
||||
}
|
||||
|
||||
for key, value of options
|
||||
payload[key] = value
|
||||
|
||||
self.socket.send JSON.stringify payload
|
||||
|
||||
self.delete-column = (project-id, column-id) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "delete-column"
|
||||
project: project-id
|
||||
column: column-id
|
||||
}
|
||||
|
||||
self.new-column = (project-id, name) ->
|
||||
self.socket.send JSON.stringify {
|
||||
type: "new-column"
|
||||
project: project-id
|
||||
name: name
|
||||
}
|
||||
|
||||
self.new-task = (project-id, column-id, options) ->
|
||||
payload = {
|
||||
type: "new-task"
|
||||
project: project-id
|
||||
column: column-id
|
||||
}
|
||||
|
||||
for key, value of options
|
||||
payload[key] = value
|
||||
|
||||
self.socket.send JSON.stringify payload
|
||||
|
||||
self.edit-project = (project-id, options) ->
|
||||
payload = {
|
||||
type: "edit-project"
|
||||
project: project-id
|
||||
}
|
||||
|
||||
for key, value of options
|
||||
payload[key] = value
|
||||
|
||||
self.socket.send JSON.stringify payload
|
||||
|
||||
self
|
||||
|
||||
socket = KanbanSocket socket-url
|
||||
|
||||
socket.on-message = (event) ->
|
||||
console.log event.data
|
||||
|
||||
message = JSON.parse event.data
|
||||
@ -466,11 +532,7 @@ renderer = ->
|
||||
onclick: (e) ->
|
||||
e.prevent-default!
|
||||
|
||||
socket.send JSON.stringify {
|
||||
type: "login",
|
||||
login: model.login
|
||||
password: model.password
|
||||
}
|
||||
socket.login model.login, model.password
|
||||
} [ "Letsu go!" ]
|
||||
]
|
||||
]
|
||||
@ -498,20 +560,14 @@ renderer = ->
|
||||
onclick: ->
|
||||
model.current-view := "project"
|
||||
model.viewed-project := project.id
|
||||
socket.send JSON.stringify {
|
||||
type: "project",
|
||||
project: project.id
|
||||
}
|
||||
socket.get-project project.id
|
||||
} [
|
||||
bulma.title 3 project.name
|
||||
]
|
||||
|
||||
h \div.button.is-primary.is-large.is-fullwidth {
|
||||
onclick: ->
|
||||
socket.send JSON.stringify {
|
||||
type: "new-project"
|
||||
name: "Hello, there!"
|
||||
}
|
||||
socket.new-project "Hello, there!"
|
||||
} [ "New project! (random atm)" ]
|
||||
]
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user