Commit b2200aea authored by Sean Hammond's avatar Sean Hammond

Merge pull request #2576 from robertknight/gh2553-fix_selection_filter

Re-implement filtering of annotations based on the current selection
parents 2aa5b3f1 e7a14441
......@@ -8,7 +8,9 @@ describe 'thread', ->
fakeGroups = null
fakePulse = null
fakeRender = null
fakeAnnotationUI = null
sandbox = null
selectedAnnotations = []
createDirective = ->
$element = angular.element('<div thread>')
......@@ -29,9 +31,16 @@ describe 'thread', ->
}
fakePulse = sandbox.spy()
fakeRender = sandbox.spy()
fakeAnnotationUI = {
hasSelectedAnnotations: ->
selectedAnnotations.length > 0
isAnnotationSelected: (id) ->
selectedAnnotations.indexOf(id) != -1
}
$provide.value 'groups', fakeGroups
$provide.value 'pulse', fakePulse
$provide.value 'render', fakeRender
$provide.value 'annotationUI', fakeAnnotationUI
return
beforeEach inject (_$compile_, $rootScope) ->
......@@ -172,6 +181,25 @@ describe 'thread', ->
fakeGroups.focused.returns({id: 'wibble'})
assert.isTrue(controller.shouldShow())
describe 'filters messages based on the selection', ->
messageID = 456
beforeEach ->
controller.container =
message:
id: messageID
it 'shows all annotations when there is no selection', ->
assert.isTrue(controller.shouldShow())
it 'hides annotations that are not selected', ->
selectedAnnotations = ['some-other-message-id']
assert.isFalse(controller.shouldShow())
it 'shows annotations that are selected', ->
selectedAnnotations = [messageID]
assert.isTrue(controller.shouldShow())
describe '#shouldShowAsReply', ->
count = null
......
......@@ -13,8 +13,8 @@ uuid = require('node-uuid')
# the collapsing behavior.
###
ThreadController = [
'$scope', 'groups',
($scope, groups) ->
'$scope', 'groups', 'annotationUI'
($scope, groups, annotationUI) ->
@container = null
@collapsed = true
@parent = null
......@@ -52,6 +52,12 @@ ThreadController = [
if this.isNew() and group and group != groups.focused().id
return false
# when there is a selection, hide unselected annotations
annotationID = this.container?.message?.id
if annotationUI.hasSelectedAnnotations() &&
!annotationUI.isAnnotationSelected(annotationID)
return false
if this.container?.message?.$orphan == true
# Hide unless show_unanchored_annotations is turned on
if not $scope.feature('show_unanchored_annotations')
......
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