2017-05-31 09:47:25 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
App.directive "aggregateChangeEntry", ($timeout) ->
|
|
|
|
restrict: "E"
|
|
|
|
templateUrl: "aggregateChangeEntryTemplate"
|
|
|
|
scope:
|
|
|
|
entry: "="
|
|
|
|
user: "="
|
|
|
|
permissions: "="
|
|
|
|
onAccept: "&"
|
|
|
|
onReject: "&"
|
|
|
|
onIndicatorClick: "&"
|
|
|
|
onBodyClick: "&"
|
|
|
|
link: (scope, element, attrs) ->
|
2018-09-01 10:36:02 -04:00
|
|
|
scope.contentLimit = 17
|
|
|
|
scope.isDeletionCollapsed = true
|
|
|
|
scope.isInsertionCollapsed = true
|
|
|
|
scope.deletionNeedsCollapsing = false
|
|
|
|
scope.insertionNeedsCollapsing = false
|
2017-05-31 09:47:25 -04:00
|
|
|
|
|
|
|
element.on "click", (e) ->
|
|
|
|
if $(e.target).is('.rp-entry, .rp-entry-description, .rp-entry-body, .rp-entry-action-icon i')
|
|
|
|
scope.onBodyClick()
|
|
|
|
|
2018-09-01 10:36:02 -04:00
|
|
|
scope.toggleDeletionCollapse = () ->
|
|
|
|
scope.isDeletionCollapsed = !scope.isDeletionCollapsed
|
2017-05-31 09:47:25 -04:00
|
|
|
$timeout () ->
|
|
|
|
scope.$emit "review-panel:layout"
|
|
|
|
|
2018-09-01 10:36:02 -04:00
|
|
|
scope.toggleInsertionCollapse = () ->
|
|
|
|
scope.isInsertionCollapsed = !scope.isInsertionCollapsed
|
|
|
|
$timeout () ->
|
|
|
|
scope.$emit "review-panel:layout"
|
|
|
|
|
|
|
|
scope.$watch "entry.metadata.replaced_content.length", (deletionContentLength) ->
|
|
|
|
scope.deletionNeedsCollapsing = deletionContentLength > scope.contentLimit
|
|
|
|
|
|
|
|
scope.$watch "entry.content.length", (insertionContentLength) ->
|
|
|
|
scope.insertionNeedsCollapsing = insertionContentLength > scope.contentLimit
|