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
449d4cfc
Commit
449d4cfc
authored
Mar 29, 2017
by
Sheetal Umesh Kumar
Committed by
GitHub
Mar 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #316 from hypothesis/annotation-viewer-component
Convert AnnotationViewerController to a component
parents
55cc1f0f
84b78431
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
36 deletions
+32
-36
app.js
src/sidebar/app.js
+2
-4
annotation-viewer-content.js
src/sidebar/components/annotation-viewer-content.js
+16
-13
annotation-viewer-content-test.js
...sidebar/components/test/annotation-viewer-content-test.js
+11
-16
annotation_viewer_content.html
src/sidebar/templates/annotation_viewer_content.html
+3
-3
No files found.
src/sidebar/app.js
View file @
449d4cfc
...
...
@@ -62,8 +62,7 @@ function configureLocation($locationProvider) {
function
configureRoutes
(
$routeProvider
)
{
$routeProvider
.
when
(
'/a/:id'
,
{
controller
:
'AnnotationViewerController'
,
template
:
require
(
'./templates/annotation_viewer_content.html'
),
template
:
'<annotation-viewer-content search="search"></annotation-viewer-content>'
,
reloadOnSearch
:
false
,
resolve
:
resolve
,
});
...
...
@@ -128,8 +127,6 @@ module.exports = angular.module('h', [
'ngRaven'
,
])
.
controller
(
'AnnotationViewerController'
,
require
(
'./annotation-viewer-controller'
))
// The root component for the application
.
directive
(
'hypothesisApp'
,
require
(
'./directive/app'
))
...
...
@@ -137,6 +134,7 @@ module.exports = angular.module('h', [
.
component
(
'annotation'
,
require
(
'./components/annotation'
).
component
)
.
component
(
'annotationShareDialog'
,
require
(
'./components/annotation-share-dialog'
))
.
component
(
'annotationThread'
,
require
(
'./components/annotation-thread'
))
.
component
(
'annotationViewerContent'
,
require
(
'./components/annotation-viewer-content'
))
.
component
(
'dropdownMenuBtn'
,
require
(
'./components/dropdown-menu-btn'
))
.
component
(
'excerpt'
,
require
(
'./components/excerpt'
))
.
component
(
'groupList'
,
require
(
'./components/group-list'
))
...
...
src/sidebar/
annotation-viewer-controller
.js
→
src/sidebar/
components/annotation-viewer-content
.js
View file @
449d4cfc
'use strict'
;
var
angular
=
require
(
'angular'
);
/**
* Fetch all annotations in the same thread as `id`.
*
...
...
@@ -25,27 +23,25 @@ function fetchThread(store, id) {
}
// @ngInject
function
AnnotationViewerController
(
$location
,
$routeParams
,
$scop
e
,
annotationUI
,
rootThread
,
streamer
,
store
,
streamFilter
,
annotationMapper
function
AnnotationViewerCont
entCont
roller
(
$location
,
$routeParams
,
annotationUI
,
rootThread
,
streamer
,
stor
e
,
streamFilter
,
annotationMapper
)
{
var
self
=
this
;
annotationUI
.
setAppIsSidebar
(
false
);
var
id
=
$routeParams
.
id
;
// Provide no-ops until these methods are moved elsewere. They only apply
// to annotations loaded into the stream.
$scope
.
focus
=
angular
.
noop
;
$scope
.
search
.
update
=
function
(
query
)
{
this
.
search
.
update
=
function
(
query
)
{
$location
.
path
(
'/stream'
).
search
(
'q'
,
query
);
};
annotationUI
.
subscribe
(
function
()
{
$scope
.
rootThread
=
rootThread
.
thread
(
annotationUI
.
getState
());
self
.
rootThread
=
rootThread
.
thread
(
annotationUI
.
getState
());
});
$scope
.
setCollapsed
=
function
(
id
,
collapsed
)
{
this
.
setCollapsed
=
function
(
id
,
collapsed
)
{
annotationUI
.
setCollapsed
(
id
,
collapsed
);
};
...
...
@@ -77,4 +73,11 @@ function AnnotationViewerController (
});
}
module
.
exports
=
AnnotationViewerController
;
module
.
exports
=
{
controller
:
AnnotationViewerContentController
,
controllerAs
:
'vm'
,
bindings
:
{
search
:
'<'
,
},
template
:
require
(
'../templates/annotation_viewer_content.html'
),
};
src/sidebar/
test/annotation-viewer-controller
-test.js
→
src/sidebar/
components/test/annotation-viewer-content
-test.js
View file @
449d4cfc
...
...
@@ -30,32 +30,20 @@ function FakeStore(annots) {
};
}
describe
(
'
AnnotationViewerController
'
,
function
()
{
describe
(
'
annotationViewerContent
'
,
function
()
{
before
(
function
()
{
angular
.
module
(
'h'
,
[])
.
co
ntroller
(
'AnnotationViewerController
'
,
require
(
'../annotation-viewer-cont
roller
'
));
.
co
mponent
(
'annotationViewerContent
'
,
require
(
'../annotation-viewer-cont
ent
'
));
});
beforeEach
(
angular
.
mock
.
module
(
'h'
));
// Return the $controller service from Angular.
function
getControllerService
()
{
var
$controller
;
angular
.
mock
.
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
});
return
$controller
;
}
function
createController
(
opts
)
{
var
locals
=
{
$location
:
{},
$routeParams
:
{
id
:
'test_annotation_id'
},
$scope
:
{
search
:
{},
},
annotationUI
:
{
setAppIsSidebar
:
sinon
.
stub
(),
setCollapsed
:
sinon
.
stub
(),
...
...
@@ -84,7 +72,14 @@ describe('AnnotationViewerController', function () {
loadAnnotations
:
sinon
.
spy
(),
},
};
locals
.
ctrl
=
getControllerService
()(
'AnnotationViewerController'
,
locals
);
var
$componentController
;
angular
.
mock
.
inject
(
function
(
_$componentController_
)
{
$componentController
=
_$componentController_
;
});
locals
.
ctrl
=
$componentController
(
'annotationViewerContent'
,
locals
,
{
search
:
{},
});
return
locals
;
}
...
...
src/sidebar/templates/annotation_viewer_content.html
View file @
449d4cfc
<thread-list
on-change-collapsed=
"setCollapsed(id, collapsed)"
on-force-visible=
"forceVisible(thread)"
on-change-collapsed=
"
vm.
setCollapsed(id, collapsed)"
on-force-visible=
"
vm.
forceVisible(thread)"
show-document-info=
"true"
thread=
"rootThread"
>
thread=
"
vm.
rootThread"
>
</thread-list>
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