Changing user permissions works.
This commit is contained in:
parent
553a23956a
commit
73b76c0852
@ -22,6 +22,7 @@ module.exports = {
|
|||||||
"update-password": 8
|
"update-password": 8
|
||||||
|
|
||||||
"list-users": 9
|
"list-users": 9
|
||||||
|
"set-permissions": 10
|
||||||
}
|
}
|
||||||
|
|
||||||
response-types = {
|
response-types = {
|
||||||
@ -114,6 +115,14 @@ module.exports = {
|
|||||||
key: "nico-nico-nii"
|
key: "nico-nico-nii"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.set-permissions = (list-id, user-id, permission) ->
|
||||||
|
self.send request-types[\set-permissions], JSON.stringify {
|
||||||
|
token: self.token
|
||||||
|
list: list-id
|
||||||
|
uid: user-id
|
||||||
|
permission: permission
|
||||||
|
}
|
||||||
|
|
||||||
# TODO: authd overhaul
|
# TODO: authd overhaul
|
||||||
#self.add-user = (login, password) ->
|
#self.add-user = (login, password) ->
|
||||||
# self.send request-types[\add-user], JSON.stringify {
|
# self.send request-types[\add-user], JSON.stringify {
|
||||||
|
@ -30,27 +30,24 @@ user-form-selection = (self, user) ->
|
|||||||
} [ user.login ]
|
} [ user.login ]
|
||||||
|
|
||||||
permission-groups =
|
permission-groups =
|
||||||
"Read"
|
"read"
|
||||||
"Write"
|
"post"
|
||||||
"Admin"
|
"edit"
|
||||||
|
"admin"
|
||||||
|
|
||||||
permissions-add = (self, permission, user-id) ->
|
permissions-add = (self, permission, user-id) ->
|
||||||
perm-list = self.permissions.find (e) -> e[0] == permission
|
perm-list = self.permissions[permission]
|
||||||
if perm-list
|
if perm-list
|
||||||
is-already-there = perm-list.find (e) -> (""+ e) == ("" + user-id)
|
is-already-there = perm-list.find (e) -> (""+ e) == ("" + user-id)
|
||||||
if is-already-there
|
if is-already-there
|
||||||
console.log "user #{user-id} already in #{perm-list}"
|
console.log "user #{user-id} already in #{perm-list}"
|
||||||
else
|
else
|
||||||
perm-list ++= [ user-id ]
|
perm-list ++= [ parseInt(user-id) ]
|
||||||
self.permissions := self.permissions.map (e) ->
|
self.permissions[permission] := perm-list
|
||||||
if e[0] == permission
|
|
||||||
perm-list
|
|
||||||
else
|
|
||||||
e
|
|
||||||
# console.log "adding user #{user-id} to #{perm-list[0]}: #{perm-list}"
|
# console.log "adding user #{user-id} to #{perm-list[0]}: #{perm-list}"
|
||||||
else
|
else
|
||||||
console.log "Cannot find #{permission} permissions, creating it"
|
console.log "Cannot find #{permission} permissions, creating it"
|
||||||
self.permissions ++= [ [ permission, user-id ]]
|
self.permissions[permission] := user-id
|
||||||
|
|
||||||
permission-to-form-selection = (self, permission) ->
|
permission-to-form-selection = (self, permission) ->
|
||||||
h \option {
|
h \option {
|
||||||
@ -70,8 +67,7 @@ ProjectCreationModal = (project, todod-ws, users) ->
|
|||||||
|
|
||||||
self = {
|
self = {
|
||||||
title: project.title || ""
|
title: project.title || ""
|
||||||
permissions: project.permissions || [[]]
|
permissions: project.permissions || {admin: [], edit: [], post: [], read: []}
|
||||||
# new-user: "New user"
|
|
||||||
|
|
||||||
tmp:
|
tmp:
|
||||||
new-user-permission:
|
new-user-permission:
|
||||||
@ -117,13 +113,13 @@ 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 Object.keys(self.permissions).map (permission) ->
|
||||||
h \li {
|
h \li {
|
||||||
key: "permission" + permission[0]
|
key: "permission" + permission
|
||||||
} [
|
} [
|
||||||
h \p permission.map (e, index) ->
|
h \p self.permissions[permission].map (e, index) ->
|
||||||
if index == 0
|
if index == 0
|
||||||
"Permissions '" + e + "': "
|
"Permissions '" + permission + "': " + e + ", "
|
||||||
else
|
else
|
||||||
"" + e + ", "
|
"" + e + ", "
|
||||||
]
|
]
|
||||||
|
@ -87,30 +87,35 @@ module.exports = {
|
|||||||
self.list-lists = ->
|
self.list-lists = ->
|
||||||
self.send request-types[\list-lists], JSON.stringify {
|
self.send request-types[\list-lists], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
|
id: "list-lists"
|
||||||
}
|
}
|
||||||
|
|
||||||
self.get-list = (list-id) ->
|
self.get-list = (list-id) ->
|
||||||
self.send request-types[\get-list], JSON.stringify {
|
self.send request-types[\get-list], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
|
id: "get-list"
|
||||||
}
|
}
|
||||||
|
|
||||||
self.get-tasks = (list-id) ->
|
self.get-tasks = (list-id) ->
|
||||||
self.send request-types[\get-tasks], JSON.stringify {
|
self.send request-types[\get-tasks], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
|
id: "get-tasks"
|
||||||
}
|
}
|
||||||
|
|
||||||
self.get-task = (task-id) ->
|
self.get-task = (task-id) ->
|
||||||
self.send request-types[\get-task], JSON.stringify {
|
self.send request-types[\get-task], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
task: task-id
|
task: task-id
|
||||||
|
id: "get-task"
|
||||||
}
|
}
|
||||||
|
|
||||||
self.remove-list = (list-id) ->
|
self.remove-list = (list-id) ->
|
||||||
self.send request-types[\remove-list], JSON.stringify {
|
self.send request-types[\remove-list], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
|
id: "remove-list"
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: extra properties
|
# TODO: extra properties
|
||||||
@ -118,6 +123,7 @@ module.exports = {
|
|||||||
payload = {
|
payload = {
|
||||||
token: self.token
|
token: self.token
|
||||||
title: title
|
title: title
|
||||||
|
id: "add-list"
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value of opts
|
for key, value of opts
|
||||||
@ -129,6 +135,7 @@ module.exports = {
|
|||||||
payload = {
|
payload = {
|
||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
|
id: "edit-list"
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value of opts
|
for key, value of opts
|
||||||
@ -140,6 +147,7 @@ module.exports = {
|
|||||||
self.send request-types[\remove-task], JSON.stringify {
|
self.send request-types[\remove-task], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
task: task-id
|
task: task-id
|
||||||
|
id: "remove-task"
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: extra properties
|
# TODO: extra properties
|
||||||
@ -148,6 +156,7 @@ module.exports = {
|
|||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
title: title
|
title: title
|
||||||
|
id: "add-task"
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value of opts
|
for key, value of opts
|
||||||
@ -159,6 +168,7 @@ module.exports = {
|
|||||||
payload = {
|
payload = {
|
||||||
token: self.token
|
token: self.token
|
||||||
task: task-id
|
task: task-id
|
||||||
|
id: "edit-task"
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value of opts
|
for key, value of opts
|
||||||
@ -170,12 +180,14 @@ module.exports = {
|
|||||||
self.send request-types[\subscribe], JSON.stringify {
|
self.send request-types[\subscribe], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
|
id: "subscribe"
|
||||||
}
|
}
|
||||||
|
|
||||||
self.unsubscribe = (list-id) ->
|
self.unsubscribe = (list-id) ->
|
||||||
self.send request-types[\unsubscribe], JSON.stringify {
|
self.send request-types[\unsubscribe], JSON.stringify {
|
||||||
token: self.token
|
token: self.token
|
||||||
list: list-id
|
list: list-id
|
||||||
|
id: "unsubscribe"
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
|
Loading…
Reference in New Issue
Block a user