aggregateChangeEntry.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. onBodyClick: '&'
  24. },
  25. link(scope, element, attrs) {
  26. scope.contentLimit = 17
  27. scope.isDeletionCollapsed = true
  28. scope.isInsertionCollapsed = true
  29. scope.deletionNeedsCollapsing = false
  30. scope.insertionNeedsCollapsing = false
  31. element.on('click', function(e) {
  32. if (
  33. $(e.target).is(
  34. '.rp-entry, .rp-entry-description, .rp-entry-body, .rp-entry-action-icon i'
  35. )
  36. ) {
  37. return scope.onBodyClick()
  38. }
  39. })
  40. scope.toggleDeletionCollapse = function() {
  41. scope.isDeletionCollapsed = !scope.isDeletionCollapsed
  42. return $timeout(() => scope.$emit('review-panel:layout'))
  43. }
  44. scope.toggleInsertionCollapse = function() {
  45. scope.isInsertionCollapsed = !scope.isInsertionCollapsed
  46. return $timeout(() => scope.$emit('review-panel:layout'))
  47. }
  48. scope.$watch(
  49. 'entry.metadata.replaced_content.length',
  50. deletionContentLength =>
  51. (scope.deletionNeedsCollapsing =
  52. deletionContentLength > scope.contentLimit)
  53. )
  54. return scope.$watch(
  55. 'entry.content.length',
  56. insertionContentLength =>
  57. (scope.insertionNeedsCollapsing =
  58. insertionContentLength > scope.contentLimit)
  59. )
  60. }
  61. }))