task modals

dev
Philippe PITTOLI 2019-12-06 04:10:00 +01:00
parent 23abce6d6c
commit 0e7fdb9ecf
7 changed files with 136 additions and 6 deletions

View File

@ -37,7 +37,7 @@ main.js: main.bundle.js
$(Q)npx babel --minified main.bundle.js -o main.js
main.bundle.js: client/index.ls client/authd.ls client/bulma.ls client/card.ls client/modal.ls client/project.ls client/TaskCreationModal.ls client/task.ls client/task-removal-modal.ls client/todowebsocket.ls client/validation-modal.ls
main.bundle.js: client/index.ls client/authd.ls client/bulma.ls client/card.ls client/modal.ls client/project.ls client/task-creation-modal.ls client/task.ls client/task-removal-modal.ls client/todowebsocket.ls client/validation-modal.ls
@echo ' BUN > main.bundle.js'
$(Q)npx browserify -t browserify-livescript client/index.ls -o main.bundle.js
@ -121,7 +121,7 @@ $(PACKAGE)-$(VERSION).tar.gz: distdir
$(PACKAGE)-$(VERSION)/client/card.ls \
$(PACKAGE)-$(VERSION)/client/modal.ls \
$(PACKAGE)-$(VERSION)/client/project.ls \
$(PACKAGE)-$(VERSION)/client/TaskCreationModal.ls \
$(PACKAGE)-$(VERSION)/client/task-creation-modal.ls \
$(PACKAGE)-$(VERSION)/client/task.ls \
$(PACKAGE)-$(VERSION)/client/task-removal-modal.ls \
$(PACKAGE)-$(VERSION)/client/todowebsocket.ls \
@ -139,7 +139,7 @@ $(PACKAGE)-$(VERSION).tar.xz: distdir
$(PACKAGE)-$(VERSION)/client/card.ls \
$(PACKAGE)-$(VERSION)/client/modal.ls \
$(PACKAGE)-$(VERSION)/client/project.ls \
$(PACKAGE)-$(VERSION)/client/TaskCreationModal.ls \
$(PACKAGE)-$(VERSION)/client/task-creation-modal.ls \
$(PACKAGE)-$(VERSION)/client/task.ls \
$(PACKAGE)-$(VERSION)/client/task-removal-modal.ls \
$(PACKAGE)-$(VERSION)/client/todowebsocket.ls \
@ -157,7 +157,7 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir
$(PACKAGE)-$(VERSION)/client/card.ls \
$(PACKAGE)-$(VERSION)/client/modal.ls \
$(PACKAGE)-$(VERSION)/client/project.ls \
$(PACKAGE)-$(VERSION)/client/TaskCreationModal.ls \
$(PACKAGE)-$(VERSION)/client/task-creation-modal.ls \
$(PACKAGE)-$(VERSION)/client/task.ls \
$(PACKAGE)-$(VERSION)/client/task-removal-modal.ls \
$(PACKAGE)-$(VERSION)/client/todowebsocket.ls \

41
client/card.ls Normal file
View File

@ -0,0 +1,41 @@
h = require 'maquette' .h
TaskCard = (key, head-left, head-content, content, on-click) ->
self = {
key: key
head-left: head-left
head-content: head-content
content: content
modal: void
}
self.render = ->
h \div.card { key: self.key } [
h \div.card-content [
h \div.media [
h \div.media-left [
self.head-left
]
h \div.media-content [
self.head-content
]
]
h \div.content [
self.title
h \div.button {
onclick: -> on-click!
modal := TaskCreationModal project.id, todod-ws, self
} [ "Edit" ]
if self.modal
self.modal.render!
]
]
]
self
module.exports = Card

View File

@ -3,7 +3,7 @@ h = require 'maquette' .h
bulma = require "./bulma.ls"
Task = require "./task.ls"
Modal = require './modal.ls'
TaskCreationModal = require './TaskCreationModal.ls'
TaskCreationModal = require './task-creation-modal.ls'
Project = (self, todod-ws) ->
self.todod-ws = todod-ws

View File

@ -0,0 +1,45 @@
h = require 'maquette' .h
Modal = require './modal.ls'
TaskCreationModal = (project-id, todod-ws, task) ->
task ||= {}
self = {
title: task.title || ""
description: task.description || ""
}
modal = Modal {
+visible
content: h \div.form [
h \input.input {
value: self.title
oninput: (e) ->
self.title := e.target.value
}
h \textarea {
value: self.description
oninput: (e) ->
self.description := e.target.value
}
]
on-validation: ->
if task.id
todod-ws.edit-task task.id, {
title: self.title
description: self.description
}
else
todod-ws.add-task project-id, self.title, {
description: self.description
}
}
self.render = ->
modal.render!
self
module.exports = TaskCreationModal

View File

@ -0,0 +1,28 @@
h = require 'maquette' .h
Modal = require './modal.ls'
TaskRemovalModal = (project-id, todod-ws, task) ->
task ||= {}
self = {
title: task.title || ""
description: task.description || ""
}
modal = Modal {
+visible
content: h \div.is-danger [ "Do you want to remove the task ?" ]
on-validation: ->
if task.id
todod-ws.remove-task task.id
}
self.render = ->
modal.render!
self
module.exports = TaskRemovalModal

View File

@ -5,7 +5,7 @@
h = require 'maquette' .h
bulma = require "./bulma.ls"
nmd = require "nano-markdown"
TaskCreationModal = require './TaskCreationModal.ls'
TaskCreationModal = require './task-creation-modal.ls'
TaskRemovalModal = require './task-removal-modal.ls'
#

View File

@ -0,0 +1,16 @@
h = require 'maquette' .h
Modal = require './modal.ls'
# ValidationModal = (args) ->
# m = Modal (args)
# m.result = void
# m.on-validation = ->
# m.result = true
# m.on-cancellation = ->
# m.result = false
# m
module.exports = ValidationModal