changeEntry.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. onBodyClick: '&'
  24. },
  25. link(scope, element, attrs) {
  26. scope.contentLimit = 40
  27. scope.isCollapsed = true
  28. scope.needsCollapsing = false
  29. element.on('click', function(e) {
  30. if (
  31. $(e.target).is(
  32. '.rp-entry, .rp-entry-description, .rp-entry-body, .rp-entry-action-icon i'
  33. )
  34. ) {
  35. return scope.onBodyClick()
  36. }
  37. })
  38. scope.toggleCollapse = function() {
  39. scope.isCollapsed = !scope.isCollapsed
  40. return $timeout(() => scope.$emit('review-panel:layout'))
  41. }
  42. return scope.$watch(
  43. 'entry.content.length',
  44. contentLength =>
  45. (scope.needsCollapsing = contentLength > scope.contentLimit)
  46. )
  47. }
  48. }))