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

Relieve the thread directive of list responsibilities

The thread directive is doing rather a lot:

- rendering a list of cards
- rendering a card
- rendering a reply within a card

This change relieves the thread directive of the first of these
responsibilities.
parent 10ad1675
......@@ -5,28 +5,17 @@ sinon.assert.expose assert, prefix: null
describe 'h:directives.thread', ->
fakeRender = null
sandbox = null
before ->
angular.module('h', [])
require('../thread')
beforeEach module('h')
beforeEach module ($provide) ->
sandbox = sinon.sandbox.create()
fakeRender = sandbox.spy()
$provide.value 'render', fakeRender
return
afterEach ->
sandbox.restore()
describe '.ThreadController', ->
$scope = null
createController = null
beforeEach module('h')
beforeEach inject ($controller, $rootScope) ->
$scope = $rootScope.$new()
......@@ -120,18 +109,26 @@ describe 'h:directives.thread', ->
describe '.thread', ->
createElement = null
$element = null
$isolateScope = null
fakePulse = null
fakeRender = null
sandbox = null
beforeEach module('h')
beforeEach module ($provide) ->
sandbox = sinon.sandbox.create()
fakePulse = sandbox.spy()
fakeRender = sandbox.spy()
$provide.value 'pulse', fakePulse
$provide.value 'render', fakeRender
return
beforeEach inject ($compile, $rootScope) ->
createElement = (html) -> $compile(html or '<div thread></div>')($rootScope.$new())
$element = createElement()
$isolateScope = $element.scope()
$element = $compile('<div thread></div>')($rootScope.$new())
$rootScope.$digest()
afterEach ->
sandbox.restore()
it 'sets the threadRoot on the controller to false', ->
controller = $element.controller('thread')
......
......@@ -42,6 +42,7 @@
thread="child" thread-filter
ng-include="'thread.html'"
ng-init="child.message.id || threadFilter.active(false)"
ng-class="{'thread-collapsed': vm.collapsed}"
ng-repeat="child in vm.container.children
| orderBy : 'message.updated' : true"
ng-show="count('edit') || count('match') || !threadFilter.active()">
......
<!-- Thread view -->
<ul class="stream-list"
deep-count="count"
thread="threadRoot"
thread-filter="search.query">
<li ng-show="threadFilter.active()"
><span ng-pluralize
......@@ -43,9 +42,8 @@
ng-mouseenter="focus(child.message)"
ng-click="scrollTo(child.message)"
ng-mouseleave="focus()"
ng-repeat="child in vm.container.children | orderBy : sort.predicate"
ng-show="vm.container && shouldShowThread(child) &&
(count('edit') || count('match') || !threadFilter.active())">
ng-repeat="child in threadRoot.children | orderBy : sort.predicate"
ng-show="shouldShowThread(child) && (count('edit') || count('match') || !threadFilter.active())">
</li>
</ul>
<!-- / Thread view -->
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