overleaf/services/web/public/coffee/ide/permissions/PermissionsManager.coffee

27 lines
807 B
CoffeeScript
Raw Normal View History

2014-07-08 07:02:26 -04:00
define [], () ->
class PermissionsManager
constructor: (@ide, @$scope) ->
@$scope.permissions =
read: false
write: false
admin: false
comment: false
2014-07-08 07:02:26 -04:00
@$scope.$watch "permissionsLevel", (permissionsLevel) =>
2014-07-08 07:02:26 -04:00
if permissionsLevel?
if permissionsLevel == "readOnly"
@$scope.permissions.read = true
@$scope.permissions.comment = true
2014-07-08 07:02:26 -04:00
else if permissionsLevel == "readAndWrite"
@$scope.permissions.read = true
@$scope.permissions.write = true
@$scope.permissions.comment = true
2014-07-08 07:02:26 -04:00
else if permissionsLevel == "owner"
@$scope.permissions.read = true
@$scope.permissions.write = true
@$scope.permissions.admin = true
@$scope.permissions.comment = true
if @$scope.anonymous
@$scope.permissions.comment = false