主表加入权限判断

This commit is contained in:
Jack Zhuang 2017-12-15 17:24:54 +08:00
parent 346f61ccac
commit b4d91bf181
2 changed files with 41 additions and 2 deletions

View File

@ -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) ->

View File

@ -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 ()->