changeEntry.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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('changeEntry', $timeout => ({
  14. restrict: 'E',
  15. templateUrl: 'changeEntryTemplate',
  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 = 40
  29. scope.isCollapsed = true
  30. scope.needsCollapsing = 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.toggleCollapse = function () {
  41. scope.isCollapsed = !scope.isCollapsed
  42. return $timeout(() => scope.$emit('review-panel:layout'))
  43. }
  44. return scope.$watch(
  45. 'entry.content.length',
  46. contentLength =>
  47. (scope.needsCollapsing = contentLength > scope.contentLimit)
  48. )
  49. },
  50. }))