Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
editoria
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yannis Barlas
editoria
Commits
ab7b4666
Commit
ab7b4666
authored
8 years ago
by
john
Browse files
Options
Downloads
Patches
Plain Diff
handle non collapsed additions on another users annotation
parent
36a15a3e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/components/SimpleEditor/elements/track_change/TrackChangesProvider.js
+27
-13
27 additions, 13 deletions
...impleEditor/elements/track_change/TrackChangesProvider.js
with
27 additions
and
13 deletions
app/components/SimpleEditor/elements/track_change/TrackChangesProvider.js
+
27
−
13
View file @
ab7b4666
...
...
@@ -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
(
d
eletions
,
(
annotation
)
=>
{
each
(
ownD
eletions
,
(
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
=
a
nnotation
.
u
ser
.
id
const
currentUser
=
this
.
config
.
user
.
id
const
annotationUser
=
this
.
getA
nnotation
U
ser
(
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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment