project edition can manage user permissions

This commit is contained in:
Philippe PITTOLI 2019-12-10 14:24:58 +01:00
parent 6518f71787
commit 553a23956a

View File

@ -34,6 +34,24 @@ permission-groups =
"Write" "Write"
"Admin" "Admin"
permissions-add = (self, permission, user-id) ->
perm-list = self.permissions.find (e) -> e[0] == permission
if perm-list
is-already-there = perm-list.find (e) -> (""+ e) == ("" + user-id)
if is-already-there
console.log "user #{user-id} already in #{perm-list}"
else
perm-list ++= [ user-id ]
self.permissions := self.permissions.map (e) ->
if e[0] == permission
perm-list
else
e
# console.log "adding user #{user-id} to #{perm-list[0]}: #{perm-list}"
else
console.log "Cannot find #{permission} permissions, creating it"
self.permissions ++= [ [ permission, user-id ]]
permission-to-form-selection = (self, permission) -> permission-to-form-selection = (self, permission) ->
h \option { h \option {
value: permission value: permission
@ -100,7 +118,9 @@ ProjectCreationModal = (project, todod-ws, users) ->
h \aside.menu [ h \aside.menu [
h \p.menu-label [ "Permissions" ] h \p.menu-label [ "Permissions" ]
h \ul.menu-list self.permissions.map (permission) -> h \ul.menu-list self.permissions.map (permission) ->
h \li [ h \li {
key: "permission" + permission[0]
} [
h \p permission.map (e, index) -> h \p permission.map (e, index) ->
if index == 0 if index == 0
"Permissions '" + e + "': " "Permissions '" + e + "': "
@ -142,8 +162,7 @@ ProjectCreationModal = (project, todod-ws, users) ->
# TODO: # TODO:
# adding the permissions in self.permissions # adding the permissions in self.permissions
# then editing the project in the db via todod-ws # then editing the project in the db via todod-ws
# self.permissions permissions-add self, self.tmp.new-user-permission.permission, self.tmp.new-user-permission.uid
console.log "right: #{self.tmp.new-user-permission.permission}, user #{self.tmp.new-user-permission.uid}"
} [ "+" ] } [ "+" ]
] ]