PermissionsManager.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* eslint-disable
  2. no-return-assign,
  3. no-undef,
  4. no-unused-vars,
  5. */
  6. // TODO: This file was created by bulk-decaffeinate.
  7. // Fix any style issues and re-enable lint.
  8. /*
  9. * decaffeinate suggestions:
  10. * DS102: Remove unnecessary code created because of implicit returns
  11. * DS207: Consider shorter variations of null checks
  12. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  13. */
  14. define([], function() {
  15. let PermissionsManager
  16. return (PermissionsManager = class PermissionsManager {
  17. constructor(ide, $scope) {
  18. this.ide = ide
  19. this.$scope = $scope
  20. this.$scope.permissions = {
  21. read: false,
  22. write: false,
  23. admin: false,
  24. comment: false
  25. }
  26. this.$scope.$watch('permissionsLevel', permissionsLevel => {
  27. if (permissionsLevel != null) {
  28. if (permissionsLevel === 'readOnly') {
  29. this.$scope.permissions.read = true
  30. this.$scope.permissions.comment = true
  31. } else if (permissionsLevel === 'readAndWrite') {
  32. this.$scope.permissions.read = true
  33. this.$scope.permissions.write = true
  34. this.$scope.permissions.comment = true
  35. } else if (permissionsLevel === 'owner') {
  36. this.$scope.permissions.read = true
  37. this.$scope.permissions.write = true
  38. this.$scope.permissions.admin = true
  39. this.$scope.permissions.comment = true
  40. }
  41. }
  42. if (this.$scope.anonymous) {
  43. return (this.$scope.permissions.comment = false)
  44. }
  45. })
  46. }
  47. })
  48. })