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,68 +50,22 @@ describe 'h:directives.thread', ->
controller = createController()
count = sinon.stub()
describe 'when root', ->
beforeEach -> controller.isRoot = true
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 'shows the reply if the thread is collapsed and has children', ->
count.withArgs('message').returns(1)
controller.toggleCollapsed(true)
assert.isTrue(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 'when reply', ->
beforeEach -> controller.isRoot = false
describe 'and when not filtered', ->
it 'shows the reply if the thread is not collapsed and has children', ->
describe 'when not filtered', ->
it 'shows the reply if the thread 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', ->
it 'does not show the reply if the thread 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', ->
describe 'when filtered with children', ->
it 'shows the reply', ->
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', ->
it 'does not show the reply if 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))
......@@ -141,15 +95,6 @@ describe 'h:directives.thread', ->
afterEach ->
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', ->
$element.scope().$emit('annotationUpdate')
assert.called(fakePulse)
......
......@@ -18,7 +18,6 @@ ThreadController = [
->
@container = null
@collapsed = false
@isRoot = false
###*
# @ngdoc method
......@@ -41,10 +40,9 @@ ThreadController = [
# the thread is currently filtered.
###
this.shouldShowReply = (count, isFilterActive) ->
isCollapsedReply = (@collapsed && !@isRoot)
hasChildren = count('message') > 0
hasFilterMatch = !isFilterActive || count('message') == count('match')
!isCollapsedReply && hasChildren && hasFilterMatch
hasChildren && hasFilterMatch
this
]
......@@ -96,8 +94,6 @@ thread = [
'$parse', '$window', 'pulse', 'render',
($parse, $window, pulse, render) ->
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.
elem.on 'click', (event) ->
......
......@@ -36,8 +36,6 @@
ng-class="{'js-hover': hasFocus(child.message)}"
deep-count="count"
thread="child" thread-filter
thread-collapsed="!search.query"
thread-root="true"
ng-include="'thread.html'"
ng-mouseenter="focus(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