hardcoded users and permissions, but still

This commit is contained in:
Philippe PITTOLI 2019-12-10 03:34:08 +01:00
parent b470ff2a37
commit a9e28065bf
3 changed files with 73 additions and 25 deletions

View File

@ -24,16 +24,28 @@ col-to-lines = (column, self) ->
} [ "DELETE" ]
]
# <div class="field has-addons">
# <p class="control">
# <input class="input" type="text" placeholder="Your email">
# </p>
# <p class="control">
# <a class="button is-static">
# @gmail.com
# </a>
# </p>
# </div>
# TODO FIXME XXX HARDCODE
users = [
{ login: "jean", id: "1003" }
{ login: "martin", id: "1004" }
{ login: "damien", id: "1005" }
]
user-form-selection = (self, user) ->
h \option {
value: user.id
} [ user.login ]
permission-groups = [
"Admin"
"Write"
"Read"
]
permission-to-form-selection = (self, permission) ->
h \option {
value: permission
} [ permission ]
ProjectCreationModal = (project, todod-ws) ->
@ -49,7 +61,11 @@ ProjectCreationModal = (project, todod-ws) ->
self = {
title: project.title || ""
permissions: project.permissions || [[]]
new-user: "New user"
# new-user: "New user"
new-user-permission: {
id: void
permission: void
}
new-column-input: {
title: "New column !"
}
@ -73,19 +89,18 @@ ProjectCreationModal = (project, todod-ws) ->
}
]
h \hr []
# h \hr []
bulma.field [
bulma.label "Adding a user"
bulma.input {
value: self.new-user
oninput: (e) ->
self.new-user := e.target.value
name: \new-user
id: \user-add
}
]
# bulma.field [
# bulma.label "Adding a user"
# bulma.input {
# value: self.new-user
# oninput: (e) ->
# self.new-user := e.target.value
# name: \new-user
# id: \user-add
# }
# ]
h \hr []
@ -103,6 +118,38 @@ ProjectCreationModal = (project, todod-ws) ->
h \hr []
h \p [ "Adding new user" ]
# TODO:
# 1. select a permission groups
# 2. select an user
h \div.field.has-addons {
key: "adding-user"
} [
h \div.select.control [
h \select {
onchange: (e) ->
self.new-user-permission.permission := e.target.value
} permission-groups.map (permission) -> permission-to-form-selection self, permission
]
h \div.select.control.is-expanded [
h \select {
onchange: (e) ->
self.new-user-permission.id := e.target.value
} users.map (user) -> user-form-selection self, user
]
h \div.control.button.is-success.is-outlined {
onclick: ->
# TODO
console.log "right: #{self.new-user-permission.permission}, user #{self.new-user-permission.id}"
} [ "+" ]
]
h \hr []
h \p [ "Choose the columns" ]
for dom in (self.extra_properties.columns.map (column) -> col-to-lines column, self)
@ -131,7 +178,6 @@ ProjectCreationModal = (project, todod-ws) ->
self.new-column-input.title := "New column !"
} [ "+" ]
]
]
on-validation: ->

View File

@ -1,4 +1,6 @@
# TODO: on modification, the description isn't updated on the client
h = require 'maquette' .h
Modal = require './modal.ls'

View File

@ -58,7 +58,7 @@ Task = (self, project, todod-ws) ->
modal := TaskCreationModal project, todod-ws, self
} [ "Edit" ]
h \div.button {
h \div.button.is-danger {
onclick: ->
modal := TaskRemovalModal project.id, todod-ws, self
} [ "X" ]