Skip to content
Snippets Groups Projects
Commit ab7b4666 authored by john's avatar john
Browse files

handle non collapsed additions on another users annotation

parent 36a15a3e
No related branches found
No related tags found
No related merge requests found
......@@ -141,8 +141,11 @@ class TrackChangesProvider {
// after deleting all own additions, there is still text selected
// mark it as deleted and add new addition annotation at the end
// TODO -- use selection.isCollapsed()
if (selection.endOffset > selection.startOffset) {
return this.deleteSelectedAndCreateAddition(options)
this.deleteOrMergeAllOwnDeletions(selection)
this.deleteSelectedAndCreateAddition(options)
return
}
// if you got here, deleting all own additions left a collapsed selection
......@@ -285,19 +288,22 @@ class TrackChangesProvider {
}
deleteAllOwnAdditions (selection) {
// TODO -- for same user
const additions = this.getAllAnnotationsByStatus('add')
const originalSelection = selection || this.getSelection()
let shortenBy = 0
each(additions, (annotation) => {
const additions = this.getAllAnnotationsByStatus('add')
const ownAdditions = filter(additions, annotation => {
return this.isAnnotationFromTheSameUser(annotation)
})
each(ownAdditions, (annotation) => {
const selection = annotation.getSelection()
// make sure only part of annotation that is selected is deleted
// make sure only the part of the annotation that is selected is deleted
if (annotation.startOffset < originalSelection.startOffset) {
selection.startOffset = originalSelection.startOffset
}
if (annotation.endOffset > originalSelection.endOffset) {
selection.endOffset = originalSelection.endOffset
}
......@@ -311,20 +317,20 @@ class TrackChangesProvider {
deleteOrMergeAllOwnDeletions (selection) {
const deletions = clone(this.getAllAnnotationsByStatus('delete'))
// filter by own deletions
console.log(selection, deletions)
const ownDeletions = filter(deletions, annotation => {
return this.isAnnotationFromTheSameUser(annotation)
})
// const originalSelection = clone(selection)
const selectionArray = [selection]
each(deletions, (annotation) => {
each(ownDeletions, (annotation) => {
const annotationSelection = annotation.getSelection()
const contained = selection.contains(annotationSelection)
if (!contained) {
selectionArray.push(annotationSelection)
}
console.log('fkdjsjf')
this.removeTrackAnnotation(annotation)
})
......@@ -540,6 +546,10 @@ class TrackChangesProvider {
return annotations
}
getAnnotationUser (annotation) {
return annotation.user.id
}
// getDistinctAnnotationsForSelection () {
// const selection = this.getSelection()
// const annotations = this.getAllExistingTrackAnnotations()
......@@ -560,8 +570,8 @@ class TrackChangesProvider {
}
isAnnotationFromTheSameUser (annotation) {
const annotationUser = annotation.user.id
const currentUser = this.config.user.id
const annotationUser = this.getAnnotationUser(annotation)
const currentUser = this.getCurrentUser()
if (annotationUser === currentUser) return true
return false
......@@ -716,6 +726,10 @@ class TrackChangesProvider {
return this.config.commandManager
}
getCurrentUser () {
return this.config.user.id
}
getDocumentSession () {
return this.config.documentSession
}
......
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