aggregateChangeEntry.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. import App from '../../../base'
  13. export default App.directive('aggregateChangeEntry', $timeout => ({
  14. restrict: 'E',
  15. templateUrl: 'aggregateChangeEntryTemplate',
  16. scope: {
  17. entry: '=',
  18. user: '=',
  19. permissions: '=',
  20. onAccept: '&',
  21. onReject: '&',
  22. onIndicatorClick: '&',
  23. onMouseEnter: '&',
  24. onMouseLeave: '&',
  25. onBodyClick: '&',
  26. },
  27. link(scope, element, attrs) {
  28. scope.contentLimit = 17
  29. scope.isDeletionCollapsed = true
  30. scope.isInsertionCollapsed = true
  31. scope.deletionNeedsCollapsing = false
  32. scope.insertionNeedsCollapsing = false
  33. element.on('click', function (e) {
  34. if (
  35. $(e.target).is(
  36. '.rp-entry, .rp-entry-description, .rp-entry-body, .rp-entry-action-icon i'
  37. )
  38. ) {
  39. return scope.onBodyClick()
  40. }
  41. })
  42. scope.toggleDeletionCollapse = function () {
  43. scope.isDeletionCollapsed = !scope.isDeletionCollapsed
  44. return $timeout(() => scope.$emit('review-panel:layout'))
  45. }
  46. scope.toggleInsertionCollapse = function () {
  47. scope.isInsertionCollapsed = !scope.isInsertionCollapsed
  48. return $timeout(() => scope.$emit('review-panel:layout'))
  49. }
  50. scope.$watch(
  51. 'entry.metadata.replaced_content.length',
  52. deletionContentLength =>
  53. (scope.deletionNeedsCollapsing =
  54. deletionContentLength > scope.contentLimit)
  55. )
  56. return scope.$watch(
  57. 'entry.content.length',
  58. insertionContentLength =>
  59. (scope.insertionNeedsCollapsing =
  60. insertionContentLength > scope.contentLimit)
  61. )
  62. },
  63. }))