Commit 38254022 authored by Ujvari Gergely's avatar Ujvari Gergely

Bugfix for #354: Added auth check for cascade delete and using flattenChildren() instead of replies

parent daa14376
...@@ -290,7 +290,7 @@ class Annotation ...@@ -290,7 +290,7 @@ class Annotation
$scope.action = 'edit' $scope.action = 'edit'
$scope.editing = true $scope.editing = true
$scope.origText = $scope.model.$modelValue.text $scope.origText = $scope.model.$modelValue.text
$scope.delete = -> $scope.delete = ->
annotation = $scope.thread.message annotation = $scope.thread.message
replies = $scope.thread.children?.length or 0 replies = $scope.thread.children?.length or 0
...@@ -300,10 +300,12 @@ class Annotation ...@@ -300,10 +300,12 @@ class Annotation
if replies == 0 or $scope.form.privacy.$viewValue is 'Private' if replies == 0 or $scope.form.privacy.$viewValue is 'Private'
# If we're deleting it without asking for a message, confirm first. # If we're deleting it without asking for a message, confirm first.
if confirm "Are you sure you want to delete this annotation?" if confirm "Are you sure you want to delete this annotation?"
if $scope.form.privacy.$viewValue is 'Private' if $scope.form.privacy.$viewValue is 'Private' and replies
#Cascade delete its children #Cascade delete its children
for reply in replies for reply in $scope.thread.flattenChildren()
annotator.deleteAnnotation reply if annotator.plugins?.Permissions? and
annotator.plugins.Permissions.authorize 'delete', reply
annotator.deleteAnnotation reply
annotator.deleteAnnotation annotation annotator.deleteAnnotation annotation
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment