2014-07-08 07:02:26 -04:00
|
|
|
define [], () ->
|
|
|
|
class PermissionsManager
|
|
|
|
constructor: (@ide, @$scope) ->
|
2014-07-16 06:02:45 -04:00
|
|
|
@$scope.permissions =
|
|
|
|
read: false
|
|
|
|
write: false
|
|
|
|
admin: false
|
2017-01-12 05:52:39 -05:00
|
|
|
comment: false
|
2014-07-08 07:02:26 -04:00
|
|
|
@$scope.$watch "permissionsLevel", (permissionsLevel) =>
|
2014-07-16 06:02:45 -04:00
|
|
|
|
2014-07-08 07:02:26 -04:00
|
|
|
if permissionsLevel?
|
|
|
|
if permissionsLevel == "readOnly"
|
|
|
|
@$scope.permissions.read = true
|
2017-01-12 05:52:39 -05:00
|
|
|
@$scope.permissions.comment = true
|
2014-07-08 07:02:26 -04:00
|
|
|
else if permissionsLevel == "readAndWrite"
|
|
|
|
@$scope.permissions.read = true
|
|
|
|
@$scope.permissions.write = true
|
2017-01-12 05:52:39 -05:00
|
|
|
@$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
|
2017-01-12 05:52:39 -05:00
|
|
|
@$scope.permissions.comment = true
|
|
|
|
|
|
|
|
if @$scope.anonymous
|
|
|
|
@$scope.permissions.comment = false
|