Commit e3c473c1 authored by csillag's avatar csillag Committed by Randall Leeds

Hide orphan annotations in the sidebar

parent 5b861c1f
...@@ -16,6 +16,7 @@ Annotator.prototype.setupAnnotation = (annotation) -> ...@@ -16,6 +16,7 @@ Annotator.prototype.setupAnnotation = (annotation) ->
@selectedTargets = [] @selectedTargets = []
annotation.anchors = [] annotation.anchors = []
hasAnchor = false
for t in annotation.target ? [] for t in annotation.target ? []
try try
...@@ -27,13 +28,16 @@ Annotator.prototype.setupAnnotation = (annotation) -> ...@@ -27,13 +28,16 @@ Annotator.prototype.setupAnnotation = (annotation) ->
if anchor? if anchor?
t.diffHTML = anchor.diffHTML t.diffHTML = anchor.diffHTML
t.diffCaseOnly = anchor.diffCaseOnly t.diffCaseOnly = anchor.diffCaseOnly
hasAnchor = true
catch exception catch exception
console.log "Error in setupAnnotation for", annotation.id, console.log "Error in setupAnnotation for", annotation.id,
":", exception.stack ? exception ":", exception.stack ? exception
annotation if annotation.target?.length and not hasAnchor
annotation.$orphan = true
annotation
# Override deleteAnnotation to deal with anchors, not highlights. # Override deleteAnnotation to deal with anchors, not highlights.
Annotator.prototype.deleteAnnotation = (annotation) -> Annotator.prototype.deleteAnnotation = (annotation) ->
......
...@@ -20,7 +20,7 @@ module.exports = class CrossFrame ...@@ -20,7 +20,7 @@ module.exports = class CrossFrame
new Discovery($window, options) new Discovery($window, options)
createAnnotationSync = -> createAnnotationSync = ->
whitelist = ['$highlight', 'target', 'document', 'uri'] whitelist = ['$highlight', '$orphan', 'target', 'document', 'uri']
options = options =
formatter: (annotation) -> formatter: (annotation) ->
formatted = {} formatted = {}
......
...@@ -70,3 +70,5 @@ module.exports = class WidgetController ...@@ -70,3 +70,5 @@ module.exports = class WidgetController
$scope.hasFocus = (annotation) -> $scope.hasFocus = (annotation) ->
!!($scope.focusedAnnotations ? {})[annotation?.$$tag] !!($scope.focusedAnnotations ? {})[annotation?.$$tag]
$scope.notOrphan = (container) -> !container?.message?.$orphan
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
ng-mouseenter="focus(child.message)" ng-mouseenter="focus(child.message)"
ng-click="scrollTo(child.message)" ng-click="scrollTo(child.message)"
ng-mouseleave="focus()" ng-mouseleave="focus()"
ng-repeat="child in threadRoot.children | orderBy : sort.predicate" ng-repeat="child in threadRoot.children | filter:notOrphan | orderBy : sort.predicate"
ng-show="shouldShowThread(child) && (count('edit') || count('match') || !threadFilter.active())"> ng-show="shouldShowThread(child) && (count('edit') || count('match') || !threadFilter.active())">
</li> </li>
</ul> </ul>
......
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