fileEntity.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* eslint-disable
  2. max-len,
  3. no-return-assign,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * DS207: Consider shorter variations of null checks
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. import App from '../../../base'
  14. export default App.directive('fileEntity', RecursionHelper => ({
  15. restrict: 'E',
  16. scope: {
  17. entity: '=',
  18. permissions: '=',
  19. depth: '=?'
  20. },
  21. templateUrl: 'entityListItemTemplate',
  22. compile(element) {
  23. return RecursionHelper.compile(element, function(
  24. scope,
  25. element,
  26. attrs,
  27. ctrl
  28. ) {
  29. // Don't freak out if we're already in an apply callback
  30. scope.$originalApply = scope.$apply
  31. return (scope.$apply = function(fn) {
  32. if (fn == null) {
  33. fn = function() {}
  34. }
  35. const phase = this.$root.$$phase
  36. if (phase === '$apply' || phase === '$digest') {
  37. return fn()
  38. } else {
  39. return this.$originalApply(fn)
  40. }
  41. })
  42. })
  43. }
  44. }))