mirror of
https://github.com/steedos/steedos-platform
synced 2024-11-23 01:16:43 +00:00
主表加入权限判断
This commit is contained in:
parent
346f61ccac
commit
b4d91bf181
@ -10,12 +10,19 @@ Template.creator_list.helpers
|
||||
return Creator.TabularTables[Session.get("object_name")]
|
||||
|
||||
hasPermission: (permissionName)->
|
||||
permissions = Creator.Objects[Session.get("object_name")]?.permissions?.default
|
||||
permissions = Creator.getPermissions()
|
||||
if permissions
|
||||
return permissions[permissionName]
|
||||
|
||||
selector: ()->
|
||||
return {space: Session.get("spaceId")}
|
||||
if Session.get("spaceId")
|
||||
permissions = Creator.getPermissions()
|
||||
if permissions.viewAllRecords
|
||||
return {space: Session.get("spaceId")}
|
||||
else if permissions.allowRead and Meteor.userId()
|
||||
return {space: Session.get("spaceId"), owner: Meteor.userId()}
|
||||
return {_id: "nothing to return"}
|
||||
|
||||
|
||||
Template.creator_list.events
|
||||
# 'click .table-creator tr': (event) ->
|
||||
|
@ -198,6 +198,38 @@ Creator.getObjectRecord = (object_name, record_id)->
|
||||
return collection.findOne(record_id)
|
||||
|
||||
|
||||
Creator.getPermissions = ()->
|
||||
if !Session.get("object_name")
|
||||
permissions =
|
||||
allowCreate: false
|
||||
allowDelete: false
|
||||
allowEdit: false
|
||||
allowRead: false
|
||||
modifyAllRecords: false
|
||||
viewAllRecords: false
|
||||
else
|
||||
permissions = Creator.Objects[Session.get("object_name")]?.permissions?.default
|
||||
|
||||
if Steedos.isSpaceAdmin()
|
||||
permissions =
|
||||
allowCreate: true
|
||||
allowDelete: true
|
||||
allowEdit: true
|
||||
allowRead: true
|
||||
modifyAllRecords: true
|
||||
viewAllRecords: true
|
||||
|
||||
if !permissions
|
||||
permissions =
|
||||
allowCreate: true
|
||||
allowDelete: true
|
||||
allowEdit: true
|
||||
allowRead: true
|
||||
modifyAllRecords: false
|
||||
viewAllRecords: false
|
||||
|
||||
return permissions
|
||||
|
||||
# 切换工作区时,重置下拉框的选项
|
||||
if Meteor.isClient
|
||||
Tracker.autorun ()->
|
||||
|
Loading…
Reference in New Issue
Block a user