fileEntity.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. },
  20. templateUrl: 'entityListItemTemplate',
  21. compile(element) {
  22. return RecursionHelper.compile(element, function(
  23. scope,
  24. element,
  25. attrs,
  26. ctrl
  27. ) {
  28. // Don't freak out if we're already in an apply callback
  29. scope.$originalApply = scope.$apply
  30. return (scope.$apply = function(fn) {
  31. if (fn == null) {
  32. fn = function() {}
  33. }
  34. const phase = this.$root.$$phase
  35. if (phase === '$apply' || phase === '$digest') {
  36. return fn()
  37. } else {
  38. return this.$originalApply(fn)
  39. }
  40. })
  41. })
  42. }
  43. }))