Commit 65ba2482 authored by Aron Carroll's avatar Aron Carroll

Remove annotator dependency from controllers

parent 997d177f
...@@ -54,18 +54,17 @@ class UISyncController ...@@ -54,18 +54,17 @@ class UISyncController
class AppController class AppController
this.$inject = [ this.$inject = [
'$document', '$location', '$route', '$scope', '$window', '$document', '$location', '$route', '$scope', '$window', '$rootScope',
'annotator', 'auth', 'drafts', 'identity', 'auth', 'documentHelpers', 'drafts', 'identity',
'permissions', 'streamer', 'streamfilter' 'permissions', 'streamer', 'streamfilter', 'crossFrameUI',
'annotationLoader', 'threading'
] ]
constructor: ( constructor: (
$document, $location, $route, $scope, $window, $document, $location, $route, $scope, $window, $rootScope,
annotator, auth, drafts, identity, auth, documentHelpers, drafts, identity,
permissions, streamer, streamfilter, permissions, streamer, streamfilter, crossFrameUI,
annotationLoader, threading
) -> ) ->
{plugins, host, providers} = annotator
$scope.auth = auth $scope.auth = auth
isFirstRun = $location.search().hasOwnProperty('firstrun') isFirstRun = $location.search().hasOwnProperty('firstrun')
...@@ -78,10 +77,10 @@ class AppController ...@@ -78,10 +77,10 @@ class AppController
return unless data?.length return unless data?.length
switch action switch action
when 'create', 'update', 'past' when 'create', 'update', 'past'
annotator.loadAnnotations data annotationLoader.loadAnnotations data
when 'delete' when 'delete'
for annotation in data for annotation in data
annotator.publish 'annotationDeleted', (annotation) $rootScope.$emit('annotationDeleted', annotation)
streamer.onmessage = (data) -> streamer.onmessage = (data) ->
return if !data or data.type != 'annotation-notification' return if !data or data.type != 'annotation-notification'
...@@ -97,12 +96,12 @@ class AppController ...@@ -97,12 +96,12 @@ class AppController
# Clean up any annotations that need to be unloaded. # Clean up any annotations that need to be unloaded.
for id, container of $scope.threading.idTable when container.message for id, container of $scope.threading.idTable when container.message
# Remove annotations not belonging to this user when highlighting. # Remove annotations not belonging to this user when highlighting.
if annotator.tool is 'highlight' and annotation.user != auth.user if crossFrameUI.tool is 'highlight' and annotation.user != auth.user
annotator.publish 'annotationDeleted', container.message $rootScope.$emit('annotationDeleted', container.message)
drafts.remove annotation drafts.remove annotation
# Remove annotations the user is not authorized to view. # Remove annotations the user is not authorized to view.
else if not permissions.permits 'read', container.message, auth.user else if not permissions.permits 'read', container.message, auth.user
annotator.publish 'annotationDeleted', container.message $rootScope.$emit('annotationDeleted', container.message)
drafts.remove container.message drafts.remove container.message
$scope.$watch 'sort.name', (name) -> $scope.$watch 'sort.name', (name) ->
...@@ -123,7 +122,7 @@ class AppController ...@@ -123,7 +122,7 @@ class AppController
# Update any edits in progress. # Update any edits in progress.
for draft in drafts.all() for draft in drafts.all()
annotator.publish 'beforeAnnotationCreated', draft $rootScope.$emit('beforeAnnotationCreated', draft)
# Reopen the streamer. # Reopen the streamer.
streamer.close() streamer.close()
...@@ -167,18 +166,18 @@ class AppController ...@@ -167,18 +166,18 @@ class AppController
delete $scope.selectedAnnotationsCount delete $scope.selectedAnnotationsCount
$scope.sort = name: 'Location' $scope.sort = name: 'Location'
$scope.threading = plugins.Threading $scope.threading = threading
$scope.threadRoot = $scope.threading?.root $scope.threadRoot = $scope.threading?.root
class AnnotationViewerController class AnnotationViewerController
this.$inject = [ this.$inject = [
'$location', '$routeParams', '$scope', '$location', '$routeParams', '$scope',
'annotator', 'streamer', 'store', 'streamfilter' 'streamer', 'store', 'streamfilter', 'annotationLoader'
] ]
constructor: ( constructor: (
$location, $routeParams, $scope, $location, $routeParams, $scope,
annotator, streamer, store, streamfilter streamer, store, streamfilter, annotationLoader
) -> ) ->
# Tells the view that these annotations are standalone # Tells the view that these annotations are standalone
$scope.isEmbedded = false $scope.isEmbedded = false
...@@ -195,11 +194,10 @@ class AnnotationViewerController ...@@ -195,11 +194,10 @@ class AnnotationViewerController
id = $routeParams.id id = $routeParams.id
store.SearchResource.get _id: id, ({rows}) -> store.SearchResource.get _id: id, ({rows}) ->
annotator.loadAnnotations(rows) annotationLoader.loadAnnotations(rows)
$scope.threadRoot = children: [$scope.threading.getContainer(id)] $scope.threadRoot = children: [$scope.threading.getContainer(id)]
store.SearchResource.get references: id, ({rows}) -> store.SearchResource.get references: id, ({rows}) ->
annotator.loadAnnotations(rows) annotationLoader.loadAnnotations(rows)
streamfilter streamfilter
.setMatchPolicyIncludeAny() .setMatchPolicyIncludeAny()
...@@ -210,12 +208,12 @@ class AnnotationViewerController ...@@ -210,12 +208,12 @@ class AnnotationViewerController
class ViewerController class ViewerController
this.$inject = [ this.$inject = [
'$scope', '$route', '$scope', '$route', 'crossFrameUI', 'annotationLoader',
'annotator', 'auth', 'flash', 'streamer', 'streamfilter', 'store' 'auth', 'flash', 'streamer', 'streamfilter', 'store'
] ]
constructor: ( constructor: (
$scope, $route, $scope, $route, crossFrameUI, annotationLoader,
annotator, auth, flash, streamer, streamfilter, store auth, flash, streamer, streamfilter, store
) -> ) ->
# Tells the view that these annotations are embedded into the owner doc # Tells the view that these annotations are embedded into the owner doc
$scope.isEmbedded = true $scope.isEmbedded = true
...@@ -225,42 +223,42 @@ class ViewerController ...@@ -225,42 +223,42 @@ class ViewerController
loadAnnotations = -> loadAnnotations = ->
query = limit: 200 query = limit: 200
if annotator.tool is 'highlight' if crossFrameUI.tool is 'highlight'
return unless auth.user return unless auth.user
query.user = auth.user query.user = auth.user
for p in annotator.providers for p in crossFrameUI.providers
for e in p.entities when e not in loaded for e in p.entities when e not in loaded
loaded.push e loaded.push e
store.SearchResource.get angular.extend(uri: e, query), (results) -> store.SearchResource.get angular.extend(uri: e, query), (results) ->
annotator.loadAnnotations(results.rows) annotationLoader.loadAnnotations(results.rows)
streamfilter.resetFilter().addClause('/uri', 'one_of', loaded) streamfilter.resetFilter().addClause('/uri', 'one_of', loaded)
if auth.user and annotator.tool is 'highlight' if auth.user and crossFrameUI.tool is 'highlight'
streamfilter.addClause('/user', auth.user) streamfilter.addClause('/user', auth.user)
streamer.send({filter: streamfilter.getFilter()}) streamer.send({filter: streamfilter.getFilter()})
$scope.$watch (-> annotator.tool), (newVal, oldVal) -> $scope.$watch (-> crossFrameUI.tool), (newVal, oldVal) ->
return if newVal is oldVal return if newVal is oldVal
$route.reload() $route.reload()
$scope.$watchCollection (-> annotator.providers), loadAnnotations $scope.$watchCollection (-> crossFrameUI.providers), loadAnnotations
$scope.focus = (annotation) -> $scope.focus = (annotation) ->
if angular.isObject annotation if angular.isObject annotation
highlights = [annotation.$$tag] highlights = [annotation.$$tag]
else else
highlights = [] highlights = []
for p in annotator.providers for p in crossFrameUI.providers
p.channel.notify p.channel.notify
method: 'focusAnnotations' method: 'focusAnnotations'
params: highlights params: highlights
$scope.scrollTo = (annotation) -> $scope.scrollTo = (annotation) ->
if angular.isObject annotation if angular.isObject annotation
for p in annotator.providers for p in crossFrameUI.providers
p.channel.notify p.channel.notify
method: 'scrollToAnnotation' method: 'scrollToAnnotation'
params: annotation.$$tag params: annotation.$$tag
......
class StreamSearchController class StreamSearchController
this.inject = [ this.inject = [
'$scope', '$rootScope', '$routeParams', '$scope', '$rootScope', '$routeParams',
'annotator', 'auth', 'queryparser', 'searchfilter', 'store', 'auth', 'queryparser', 'searchfilter', 'store',
'streamer', 'streamfilter' 'streamer', 'streamfilter', 'annotationLoader'
] ]
constructor: ( constructor: (
$scope, $rootScope, $routeParams $scope, $rootScope, $routeParams
annotator, auth, queryparser, searchfilter, store, auth, queryparser, searchfilter, store,
streamer, streamfilter streamer, streamfilter, annotationLoader
) -> ) ->
# Initialize the base filter # Initialize the base filter
streamfilter streamfilter
......
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