Commit be2abd94 authored by Nick Stenning's avatar Nick Stenning Committed by Randall Leeds

Remove unnecessary isRoot property

With the viewer template managing the root container, this is no longer
necessary.
parent 24334ac8
...@@ -50,71 +50,25 @@ describe 'h:directives.thread', -> ...@@ -50,71 +50,25 @@ describe 'h:directives.thread', ->
controller = createController() controller = createController()
count = sinon.stub() count = sinon.stub()
describe 'when root', -> describe 'when not filtered', ->
beforeEach -> controller.isRoot = true it 'shows the reply if the thread has children', ->
count.withArgs('message').returns(1)
describe 'and when not filtered', -> assert.isTrue(controller.shouldShowReply(count, false))
it 'shows the reply if the thread is not collapsed and has children', ->
count.withArgs('message').returns(1) it 'does not show the reply if the thread has no children', ->
assert.isTrue(controller.shouldShowReply(count, false)) count.withArgs('message').returns(0)
assert.isFalse(controller.shouldShowReply(count, false))
it 'does not show the reply if the thread is not collapsed and has no children', ->
count.withArgs('message').returns(0) describe 'when filtered with children', ->
assert.isFalse(controller.shouldShowReply(count, false)) it 'shows the reply', ->
count.withArgs('match').returns(1)
it 'shows the reply if the thread is collapsed and has children', -> count.withArgs('message').returns(1)
count.withArgs('message').returns(1) assert.isTrue(controller.shouldShowReply(count, true))
controller.toggleCollapsed(true)
assert.isTrue(controller.shouldShowReply(count, false)) it 'does not show the reply if the message count does not match the match count', ->
count.withArgs('match').returns(0)
it 'does not show the reply if the thread is collapsed and has no children', -> count.withArgs('message').returns(1)
count.withArgs('message').returns(0) assert.isFalse(controller.shouldShowReply(count, true))
controller.toggleCollapsed(true)
assert.isFalse(controller.shouldShowReply(count, false))
describe 'and when filtered with children', ->
it 'shows the reply if the thread is not collapsed', ->
count.withArgs('match').returns(1)
count.withArgs('message').returns(1)
assert.isTrue(controller.shouldShowReply(count, true))
it 'does not show the reply if the thread is not collapsed and the message count does not match the match count', ->
count.withArgs('match').returns(0)
count.withArgs('message').returns(1)
assert.isFalse(controller.shouldShowReply(count, true))
describe 'when reply', ->
beforeEach -> controller.isRoot = false
describe 'and when not filtered', ->
it 'shows the reply if the thread is not collapsed and has children', ->
count.withArgs('message').returns(1)
assert.isTrue(controller.shouldShowReply(count, false))
it 'does not show the reply if the thread is not collapsed and has no children', ->
count.withArgs('message').returns(0)
assert.isFalse(controller.shouldShowReply(count, false))
it 'does not show the reply if the thread is collapsed and has children', ->
count.withArgs('message').returns(1)
controller.toggleCollapsed(true)
assert.isFalse(controller.shouldShowReply(count, false))
it 'does not show the reply if the thread is collapsed and has no children', ->
count.withArgs('message').returns(0)
controller.toggleCollapsed(true)
assert.isFalse(controller.shouldShowReply(count, false))
describe 'and when filtered with children', ->
it 'shows the reply if the thread is not collapsed', ->
count.withArgs('match').returns(1)
count.withArgs('message').returns(1)
assert.isTrue(controller.shouldShowReply(count, true))
it 'does not show the reply if the thread is not collapsed and the message count does not match the match count', ->
count.withArgs('match').returns(0)
count.withArgs('message').returns(1)
assert.isFalse(controller.shouldShowReply(count, true))
describe '.thread', -> describe '.thread', ->
...@@ -141,15 +95,6 @@ describe 'h:directives.thread', -> ...@@ -141,15 +95,6 @@ describe 'h:directives.thread', ->
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
it 'sets the threadRoot on the controller to false', ->
controller = $element.controller('thread')
assert.isFalse(controller.isRoot)
it 'sets the threadRoot on the controller to true when the thread-root attr is set', ->
$element = createElement('<div thread thread-root="true"></div>')
controller = $element.controller('thread')
assert.isTrue(controller.isRoot)
it 'pulses the current thread on an annotationUpdated event', -> it 'pulses the current thread on an annotationUpdated event', ->
$element.scope().$emit('annotationUpdate') $element.scope().$emit('annotationUpdate')
assert.called(fakePulse) assert.called(fakePulse)
......
...@@ -18,7 +18,6 @@ ThreadController = [ ...@@ -18,7 +18,6 @@ ThreadController = [
-> ->
@container = null @container = null
@collapsed = false @collapsed = false
@isRoot = false
###* ###*
# @ngdoc method # @ngdoc method
...@@ -41,10 +40,9 @@ ThreadController = [ ...@@ -41,10 +40,9 @@ ThreadController = [
# the thread is currently filtered. # the thread is currently filtered.
### ###
this.shouldShowReply = (count, isFilterActive) -> this.shouldShowReply = (count, isFilterActive) ->
isCollapsedReply = (@collapsed && !@isRoot)
hasChildren = count('message') > 0 hasChildren = count('message') > 0
hasFilterMatch = !isFilterActive || count('message') == count('match') hasFilterMatch = !isFilterActive || count('message') == count('match')
!isCollapsedReply && hasChildren && hasFilterMatch hasChildren && hasFilterMatch
this this
] ]
...@@ -96,8 +94,6 @@ thread = [ ...@@ -96,8 +94,6 @@ thread = [
'$parse', '$window', 'pulse', 'render', '$parse', '$window', 'pulse', 'render',
($parse, $window, pulse, render) -> ($parse, $window, pulse, render) ->
linkFn = (scope, elem, attrs, [ctrl, counter]) -> linkFn = (scope, elem, attrs, [ctrl, counter]) ->
# Determine if this is a top level thread.
ctrl.isRoot = $parse(attrs.threadRoot)(scope) == true
# Toggle collapse on click. # Toggle collapse on click.
elem.on 'click', (event) -> elem.on 'click', (event) ->
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
ng-class="{'js-hover': hasFocus(child.message)}" ng-class="{'js-hover': hasFocus(child.message)}"
deep-count="count" deep-count="count"
thread="child" thread-filter thread="child" thread-filter
thread-collapsed="!search.query"
thread-root="true"
ng-include="'thread.html'" ng-include="'thread.html'"
ng-mouseenter="focus(child.message)" ng-mouseenter="focus(child.message)"
ng-click="scrollTo(child.message)" ng-click="scrollTo(child.message)"
......
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