Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
848d0694
Commit
848d0694
authored
Jan 23, 2015
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move logic for toggling threads into the controller
parent
243e6c65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
1 deletion
+89
-1
thread.coffee
h/static/scripts/directives/thread.coffee
+14
-0
thread.html
h/templates/client/thread.html
+1
-1
thread-test.coffee
tests/js/directives/thread-test.coffee
+74
-0
No files found.
h/static/scripts/directives/thread.coffee
View file @
848d0694
...
...
@@ -29,6 +29,20 @@ ThreadController = [
this.toggleCollapsed = ->
@collapsed = not @collapsed
###
*
# @ngdoc method
# @name thread.ThreadController#shouldShowReply
# @description
# Determines if the reply counter should be rendered. Requires the
# `count` directive to be passed and a boolean that indicates whether
# 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
this
]
...
...
h/templates/client/thread.html
View file @
848d0694
...
...
@@ -17,7 +17,7 @@
</article>
<!-- Reply count -->
<div
class=
"thread-reply"
ng-show=
"
!(vm.collapsed && !vm.isRoot) && count('message') > 0 && (!threadFilter.active() || count('message') == count('match'
))"
>
<div
class=
"thread-reply"
ng-show=
"
vm.shouldShowReply(count, threadFilter.active(
))"
>
<a
class=
"reply-count small"
href=
""
ng-pluralize
count=
"count('message') - 1"
...
...
tests/js/directives/thread-test.coffee
View file @
848d0694
...
...
@@ -23,6 +23,80 @@ describe 'h.directives.thread.ThreadController', ->
after
=
controller
.
collapsed
assert
.
equal
(
before
,
!
after
)
describe
'#shouldShowReply'
,
->
count
=
null
controller
=
null
beforeEach
->
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
.
collapsed
=
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
.
collapsed
=
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
.
collapsed
=
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
.
collapsed
=
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
'h.directives.thread.thread'
,
->
$element
=
null
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment