From fe814797fd48454ac138057bbb4b51a4393fb9c4 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Sun, 8 Dec 2019 04:08:21 +0100 Subject: [PATCH] small fixes --- client/index.ls | 2 +- client/modal.ls | 7 +++-- client/project-creation-modal.ls | 47 ++++++++++++++++---------------- client/project.ls | 5 ---- client/task-creation-modal.ls | 37 +++++++++++++++---------- 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/client/index.ls b/client/index.ls index a24a5e7..08c8125 100644 --- a/client/index.ls +++ b/client/index.ls @@ -187,7 +187,7 @@ model.todod-ws.add-event-listener \list-updated, (message) -> new-project = Project message.list, model.todod-ws - model.project-list.map (project) -> + model.project-list := model.project-list.map (project) -> if project.id == message.list.id new-project else diff --git a/client/modal.ls b/client/modal.ls index a5d6f9a..ae79ebd 100644 --- a/client/modal.ls +++ b/client/modal.ls @@ -11,7 +11,10 @@ Modal = (args, caller) -> visible: args.visible || false content: args.content || [] content-render: args.content-render || -> - background-args: args.background-args || [] + background-args: args.background-args || { onclick: -> + self.visible := false + self.on-cancellation! + } on-validation: args.on-validation || -> on-cancellation: args.on-cancellation || -> validation-label: args.validation-label || "Ok" @@ -19,8 +22,6 @@ Modal = (args, caller) -> } self.render = -> - console.log "Rendering a modal: ", self, self.content - is-active = (if self.visible == true then \.is-active else "") h \div.modal + is-active, self.modal-args, [ h \div.modal-background self.background-args diff --git a/client/project-creation-modal.ls b/client/project-creation-modal.ls index 31a0371..da13103 100644 --- a/client/project-creation-modal.ls +++ b/client/project-creation-modal.ls @@ -8,7 +8,7 @@ col-to-lines = (column, self) -> h \div.field.has-addons { key: "field" + column.id } [ - h \p.control [ + h \p.control.is-expanded [ h \input.input { key: "input" + column.id value: column.title @@ -17,12 +17,10 @@ col-to-lines = (column, self) -> } [ ] ] - h \div.control.button.is-primary { + h \div.control.button.is-danger.is-outlined { key: "button" + column.id onclick: -> - # console.log "BEFORE REMOVING THE COLUMN: ", self.extra_properties.columns self.extra_properties.columns := self.extra_properties.columns.filter((.id != column.id)) - # console.log "AFTER REMOVING THE COLUMN: ", self.extra_properties.columns } [ "DELETE" ] ] @@ -45,7 +43,6 @@ ProjectCreationModal = (project, todod-ws) -> for col in project.extra_properties.columns new-col = {} for k,v of col - # console.log "element : ", k, "value: ", v new-col[k] = v columns-copy ++= [ new-col ] @@ -67,8 +64,6 @@ ProjectCreationModal = (project, todod-ws) -> h \div.form [ bulma.field [ - # console.log "NEW USER NAME: " + self.new-user - # bulma.label "Valeur actuelle : " + self.new-user bulma.label "Project title" h \input.input { @@ -81,8 +76,6 @@ ProjectCreationModal = (project, todod-ws) -> h \hr [] bulma.field [ - # console.log "NEW USER NAME: " + self.new-user - # bulma.label "Valeur actuelle : " + self.new-user bulma.label "Adding a user" bulma.input { value: self.new-user @@ -117,22 +110,28 @@ ProjectCreationModal = (project, todod-ws) -> h \hr [] - h \input.input { - value: self.new-column-input.title - oninput: (e) -> - self.new-column-input.title := e.target.value - } [ ] + h \div.field.has-addons { + key: "adding-field" + } [ + h \p.control.is-expanded [ + h \input.input { + value: self.new-column-input.title + oninput: (e) -> + self.new-column-input.title := e.target.value + } [ ] + ] + + h \div.control.button.is-success.is-outlined { + onclick: -> + new-col = { + id: UUID! + title: self.new-column-input.title + } + self.extra_properties.columns ++= [ new-col ] + self.new-column-input.title := "New column !" + } [ "+" ] + ] - h \div.button { - onclick: -> - # TODO: create a new entry in self.extra_properties.columns - new-col = { - id: UUID! - title: self.new-column-input.title - } - self.extra_properties.columns ++= [ new-col ] - self.new-column-input.title := "New column !" - } [ "+" ] ] on-validation: -> diff --git a/client/project.ls b/client/project.ls index fa9ffef..a2db8c1 100644 --- a/client/project.ls +++ b/client/project.ls @@ -28,15 +28,11 @@ Project = (self, todod-ws) -> self.render-column = (column, first) -> - console.log "tasks: ", self.tasks - tasks-to-display = self.tasks.filter (task) -> is-right-column task, column.id if first tasks-to-display ++= orphan-tasks self.tasks, self.extra_properties.columns - console.log "column: #{column.id}: ", tasks-to-display - h \div.column { key: column.id } [ @@ -86,7 +82,6 @@ Project = (self, todod-ws) -> self.render = -> - # console.log "Project to render: ", self h \div.project {} [ h \div.columns [ diff --git a/client/task-creation-modal.ls b/client/task-creation-modal.ls index 5df5ee6..f3ffca7 100644 --- a/client/task-creation-modal.ls +++ b/client/task-creation-modal.ls @@ -2,6 +2,26 @@ h = require 'maquette' .h Modal = require './modal.ls' + +column-form-selection = (self, column) -> + checked = false + + if self.extra_properties && self.extra_properties.column == column.id + checked = true + + h \label.radio [ + column.title + h \input { + type: "radio" + name: "column" + checked: checked + value: column.title + onclick: -> + self.extra_properties.column := column.id + } [ ] + ] + + TaskCreationModal = (project, todod-ws, task) -> task ||= {} @@ -33,21 +53,10 @@ TaskCreationModal = (project, todod-ws, task) -> self.description := e.target.value } - h \aside.menu [ - h \p.menu-label [ "Choose the column" ] - h \ul.menu-list project.extra_properties.columns.map (column) -> - h \li { - classes: { - is-active: self.extra_properties && self.extra_properties.column == column.id - } - } [ - h \a { - onclick: -> - self.extra_properties.column := column.id - } [ column.title ] - ] - ] + h \p [ "Choose the column" ] + h \div.control project.extra_properties.columns.map (column) -> column-form-selection self, column + ] on-validation: ->