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
3bc44117
Unverified
Commit
3bc44117
authored
Jun 07, 2019
by
Hannah Stepanek
Committed by
GitHub
Jun 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1155 from hypothesis/move-force-visible
Move onForceVisible to annotation-thread
parents
7479fadd
699a6fe3
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
57 deletions
+54
-57
annotation-thread.js
src/sidebar/components/annotation-thread.js
+12
-10
sidebar-content.js
src/sidebar/components/sidebar-content.js
+0
-7
stream-content.js
src/sidebar/components/stream-content.js
+0
-3
annotation-thread-test.js
src/sidebar/components/test/annotation-thread-test.js
+40
-9
sidebar-content-test.js
src/sidebar/components/test/sidebar-content-test.js
+0
-18
thread-list.js
src/sidebar/components/thread-list.js
+0
-5
annotation-thread.html
src/sidebar/templates/annotation-thread.html
+1
-1
sidebar-content.html
src/sidebar/templates/sidebar-content.html
+0
-1
stream-content.html
src/sidebar/templates/stream-content.html
+0
-1
thread-list.html
src/sidebar/templates/thread-list.html
+1
-2
No files found.
src/sidebar/components/annotation-thread.js
View file @
3bc44117
...
@@ -21,21 +21,21 @@ function visibleCount(thread) {
...
@@ -21,21 +21,21 @@ function visibleCount(thread) {
}
}
function
showAllChildren
(
thread
,
showFn
)
{
function
showAllChildren
(
thread
,
showFn
)
{
thread
.
children
.
forEach
(
function
(
child
)
{
thread
.
children
.
forEach
(
child
=>
{
showFn
(
{
thread
:
child
}
);
showFn
(
child
);
showAllChildren
(
child
,
showFn
);
showAllChildren
(
child
,
showFn
);
});
});
}
}
function
showAllParents
(
thread
,
showFn
)
{
function
showAllParents
(
thread
,
showFn
)
{
while
(
thread
.
parent
&&
thread
.
parent
.
annotation
)
{
while
(
thread
.
parent
&&
thread
.
parent
.
annotation
)
{
showFn
(
{
thread
:
thread
.
parent
}
);
showFn
(
thread
.
parent
);
thread
=
thread
.
parent
;
thread
=
thread
.
parent
;
}
}
}
}
// @ngInject
// @ngInject
function
AnnotationThreadController
()
{
function
AnnotationThreadController
(
store
)
{
// Flag that tracks whether the content of the annotation is hovered,
// Flag that tracks whether the content of the annotation is hovered,
// excluding any replies.
// excluding any replies.
this
.
annotationHovered
=
false
;
this
.
annotationHovered
=
false
;
...
@@ -78,7 +78,7 @@ function AnnotationThreadController() {
...
@@ -78,7 +78,7 @@ function AnnotationThreadController() {
*/
*/
this
.
showThreadAndReplies
=
function
()
{
this
.
showThreadAndReplies
=
function
()
{
showAllParents
(
this
.
thread
,
this
.
onForceVisible
);
showAllParents
(
this
.
thread
,
this
.
onForceVisible
);
this
.
onForceVisible
(
{
thread
:
this
.
thread
}
);
this
.
onForceVisible
(
this
.
thread
);
showAllChildren
(
this
.
thread
,
this
.
onForceVisible
);
showAllChildren
(
this
.
thread
,
this
.
onForceVisible
);
};
};
...
@@ -98,6 +98,13 @@ function AnnotationThreadController() {
...
@@ -98,6 +98,13 @@ function AnnotationThreadController() {
this
.
shouldShowReply
=
function
(
child
)
{
this
.
shouldShowReply
=
function
(
child
)
{
return
visibleCount
(
child
)
>
0
;
return
visibleCount
(
child
)
>
0
;
};
};
this
.
onForceVisible
=
function
(
thread
)
{
store
.
setForceVisible
(
thread
.
id
,
true
);
if
(
thread
.
parent
)
{
store
.
setCollapsed
(
thread
.
parent
.
id
,
false
);
}
};
}
}
/**
/**
...
@@ -116,11 +123,6 @@ module.exports = {
...
@@ -116,11 +123,6 @@ module.exports = {
showDocumentInfo
:
'<'
,
showDocumentInfo
:
'<'
,
/** Called when the user clicks on the expand/collapse replies toggle. */
/** Called when the user clicks on the expand/collapse replies toggle. */
onChangeCollapsed
:
'&'
,
onChangeCollapsed
:
'&'
,
/**
* Called when the user clicks the button to show this thread or
* one of its replies.
*/
onForceVisible
:
'&'
,
},
},
template
:
require
(
'../templates/annotation-thread.html'
),
template
:
require
(
'../templates/annotation-thread.html'
),
};
};
src/sidebar/components/sidebar-content.js
View file @
3bc44117
...
@@ -276,13 +276,6 @@ function SidebarContentController(
...
@@ -276,13 +276,6 @@ function SidebarContentController(
store
.
setCollapsed
(
id
,
collapsed
);
store
.
setCollapsed
(
id
,
collapsed
);
};
};
this
.
forceVisible
=
function
(
thread
)
{
store
.
setForceVisible
(
thread
.
id
,
true
);
if
(
thread
.
parent
)
{
store
.
setCollapsed
(
thread
.
parent
.
id
,
false
);
}
};
this
.
focus
=
focusAnnotation
;
this
.
focus
=
focusAnnotation
;
this
.
scrollTo
=
scrollToAnnotation
;
this
.
scrollTo
=
scrollToAnnotation
;
...
...
src/sidebar/components/stream-content.js
View file @
3bc44117
...
@@ -59,9 +59,6 @@ function StreamContentController(
...
@@ -59,9 +59,6 @@ function StreamContentController(
fetch
(
20
);
fetch
(
20
);
this
.
setCollapsed
=
store
.
setCollapsed
;
this
.
setCollapsed
=
store
.
setCollapsed
;
this
.
forceVisible
=
function
(
id
)
{
store
.
setForceVisible
(
id
,
true
);
};
store
.
subscribe
(
function
()
{
store
.
subscribe
(
function
()
{
self
.
rootThread
=
rootThread
.
thread
(
store
.
getState
());
self
.
rootThread
=
rootThread
.
thread
(
store
.
getState
());
...
...
src/sidebar/components/test/annotation-thread-test.js
View file @
3bc44117
...
@@ -36,8 +36,16 @@ describe('annotationThread', function() {
...
@@ -36,8 +36,16 @@ describe('annotationThread', function() {
});
});
});
});
let
fakeStore
;
beforeEach
(
function
()
{
beforeEach
(
function
()
{
angular
.
mock
.
module
(
'app'
);
fakeStore
=
{
setForceVisible
:
sinon
.
stub
(),
setCollapsed
:
sinon
.
stub
(),
getState
:
sinon
.
stub
(),
};
angular
.
mock
.
module
(
'app'
,
{
store
:
fakeStore
});
});
});
it
(
'renders the tree structure of parent and child annotations'
,
function
()
{
it
(
'renders the tree structure of parent and child annotations'
,
function
()
{
...
@@ -75,6 +83,33 @@ describe('annotationThread', function() {
...
@@ -75,6 +83,33 @@ describe('annotationThread', function() {
assert
.
isTrue
(
pageObject
.
isHidden
(
pageObject
.
annotations
()[
0
]));
assert
.
isTrue
(
pageObject
.
isHidden
(
pageObject
.
annotations
()[
0
]));
});
});
describe
(
'onForceVisible'
,
()
=>
{
it
(
'shows the thread'
,
()
=>
{
const
thread
=
{
id
:
'1'
,
children
:
[],
};
const
element
=
util
.
createDirective
(
document
,
'annotationThread'
,
{
thread
:
thread
,
});
element
.
ctrl
.
onForceVisible
(
thread
);
assert
.
calledWith
(
fakeStore
.
setForceVisible
,
thread
.
id
,
true
);
});
it
(
'uncollapses the parent'
,
()
=>
{
const
thread
=
{
id
:
'2'
,
children
:
[],
parent
:
{
id
:
'3'
},
};
const
element
=
util
.
createDirective
(
document
,
'annotationThread'
,
{
thread
:
thread
,
});
element
.
ctrl
.
onForceVisible
(
thread
);
assert
.
calledWith
(
fakeStore
.
setCollapsed
,
thread
.
parent
.
id
,
false
);
});
});
it
(
'shows replies if not collapsed'
,
function
()
{
it
(
'shows replies if not collapsed'
,
function
()
{
const
element
=
util
.
createDirective
(
document
,
'annotationThread'
,
{
const
element
=
util
.
createDirective
(
document
,
'annotationThread'
,
{
thread
:
{
thread
:
{
...
@@ -166,7 +201,6 @@ describe('annotationThread', function() {
...
@@ -166,7 +201,6 @@ describe('annotationThread', function() {
describe
(
'#showThreadAndReplies'
,
function
()
{
describe
(
'#showThreadAndReplies'
,
function
()
{
it
(
'reveals all parents and replies'
,
function
()
{
it
(
'reveals all parents and replies'
,
function
()
{
const
onForceVisible
=
sinon
.
stub
();
const
thread
=
{
const
thread
=
{
id
:
'123'
,
id
:
'123'
,
annotation
:
{
id
:
'123'
},
annotation
:
{
id
:
'123'
},
...
@@ -184,15 +218,12 @@ describe('annotationThread', function() {
...
@@ -184,15 +218,12 @@ describe('annotationThread', function() {
};
};
const
element
=
util
.
createDirective
(
document
,
'annotationThread'
,
{
const
element
=
util
.
createDirective
(
document
,
'annotationThread'
,
{
thread
:
thread
,
thread
:
thread
,
onForceVisible
:
{
args
:
[
'thread'
],
callback
:
onForceVisible
,
},
});
});
element
.
ctrl
.
showThreadAndReplies
();
element
.
ctrl
.
showThreadAndReplies
();
assert
.
calledWith
(
onForceVisible
,
thread
.
parent
);
assert
.
calledWith
(
fakeStore
.
setForceVisible
,
thread
.
parent
.
id
,
true
);
assert
.
calledWith
(
onForceVisible
,
thread
);
assert
.
calledWith
(
fakeStore
.
setForceVisible
,
thread
.
id
,
true
);
assert
.
calledWith
(
onForceVisible
,
thread
.
children
[
0
]);
assert
.
calledWith
(
fakeStore
.
setForceVisible
,
thread
.
children
[
0
].
id
,
true
);
assert
.
calledWith
(
fakeStore
.
setCollapsed
,
thread
.
parent
.
id
,
false
);
});
});
});
});
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
3bc44117
...
@@ -717,24 +717,6 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -717,24 +717,6 @@ describe('sidebar.components.sidebar-content', function() {
});
});
});
});
describe
(
'#forceVisible'
,
function
()
{
it
(
'shows the thread'
,
function
()
{
const
thread
=
{
id
:
'1'
};
ctrl
.
forceVisible
(
thread
);
assert
.
deepEqual
(
store
.
getState
().
forceVisible
,
{
1
:
true
});
});
it
(
'uncollapses the parent'
,
function
()
{
const
thread
=
{
id
:
'2'
,
parent
:
{
id
:
'3'
},
};
assert
.
equal
(
store
.
getState
().
expanded
[
thread
.
parent
.
id
],
undefined
);
ctrl
.
forceVisible
(
thread
);
assert
.
equal
(
store
.
getState
().
expanded
[
thread
.
parent
.
id
],
true
);
});
});
describe
(
'#visibleCount'
,
function
()
{
describe
(
'#visibleCount'
,
function
()
{
it
(
'returns the total number of visible annotations or replies'
,
function
()
{
it
(
'returns the total number of visible annotations or replies'
,
function
()
{
fakeRootThread
.
thread
.
returns
({
fakeRootThread
.
thread
.
returns
({
...
...
src/sidebar/components/thread-list.js
View file @
3bc44117
...
@@ -185,11 +185,6 @@ module.exports = {
...
@@ -185,11 +185,6 @@ module.exports = {
thread
:
'<'
,
thread
:
'<'
,
showDocumentInfo
:
'<'
,
showDocumentInfo
:
'<'
,
/**
* Called when the user clicks a link to show an annotation that does not
* match the current filter.
*/
onForceVisible
:
'&'
,
/** Called when the user focuses an annotation by hovering it. */
/** Called when the user focuses an annotation by hovering it. */
onFocus
:
'&'
,
onFocus
:
'&'
,
/** Called when a user selects an annotation. */
/** Called when a user selects an annotation. */
...
...
src/sidebar/templates/annotation-thread.html
View file @
3bc44117
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
show-document-info=
"false"
show-document-info=
"false"
thread=
"child"
thread=
"child"
on-change-collapsed=
"vm.onChangeCollapsed({id:id, collapsed:collapsed})"
on-change-collapsed=
"vm.onChangeCollapsed({id:id, collapsed:collapsed})"
on-force-visible=
"vm.onForceVisible(
{thread:thread}
)"
>
on-force-visible=
"vm.onForceVisible(
thread
)"
>
</annotation-thread>
</annotation-thread>
</li>
</li>
</ul>
</ul>
...
...
src/sidebar/templates/sidebar-content.html
View file @
3bc44117
...
@@ -47,7 +47,6 @@
...
@@ -47,7 +47,6 @@
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-clear-selection=
"vm.clearSelection()"
on-clear-selection=
"vm.clearSelection()"
on-focus=
"vm.focus(annotation)"
on-focus=
"vm.focus(annotation)"
on-force-visible=
"vm.forceVisible(thread)"
on-select=
"vm.scrollTo(annotation)"
on-select=
"vm.scrollTo(annotation)"
show-document-info=
"false"
show-document-info=
"false"
ng-if=
"!vm.selectedGroupUnavailable()"
ng-if=
"!vm.selectedGroupUnavailable()"
...
...
src/sidebar/templates/stream-content.html
View file @
3bc44117
<span
window-scroll=
"vm.loadMore(20)"
>
<span
window-scroll=
"vm.loadMore(20)"
>
<thread-list
<thread-list
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-force-visible=
"vm.forceVisible(thread)"
show-document-info=
"true"
show-document-info=
"true"
thread=
"vm.rootThread"
>
thread=
"vm.rootThread"
>
</thread-list>
</thread-list>
...
...
src/sidebar/templates/thread-list.html
View file @
3bc44117
...
@@ -11,8 +11,7 @@
...
@@ -11,8 +11,7 @@
<annotation-thread
<annotation-thread
thread=
"child"
thread=
"child"
show-document-info=
"vm.showDocumentInfo"
show-document-info=
"vm.showDocumentInfo"
on-change-collapsed=
"vm.onChangeCollapsed({id: id, collapsed: collapsed})"
on-change-collapsed=
"vm.onChangeCollapsed({id: id, collapsed: collapsed})"
>
on-force-visible=
"vm.onForceVisible({thread: thread})"
>
</annotation-thread>
</annotation-thread>
</div>
</div>
<hr
ng-if=
"vm.isThemeClean"
<hr
ng-if=
"vm.isThemeClean"
...
...
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