Commit 876b07f3 authored by Randall Leeds's avatar Randall Leeds

Start to factor out cross-cutting drafts concerns

parent 6ec8baae
...@@ -13,12 +13,29 @@ imports = [ ...@@ -13,12 +13,29 @@ imports = [
configure = [ configure = [
'$locationProvider', '$routeProvider', '$sceDelegateProvider', '$locationProvider', '$provide', '$routeProvider', '$sceDelegateProvider',
( (
$locationProvider, $routeProvider, $sceDelegateProvider, $locationProvider, $provide, $routeProvider, $sceDelegateProvider
) -> ) ->
$locationProvider.html5Mode(true) $locationProvider.html5Mode(true)
# Disable annotating while drafting
$provide.decorator 'drafts', [
'annotator', '$delegate',
(annotator, $delegate) ->
{add, remove} = $delegate
$delegate.add = (draft) ->
add.call $delegate, draft
annotator.disableAnnotating $delegate.isEmpty()
$delegate.remove = (draft) ->
remove.call $delegate, draft
annotator.enableAnnotating $delegate.isEmpty()
$delegate
]
$routeProvider.when '/editor', $routeProvider.when '/editor',
controller: 'EditorController' controller: 'EditorController'
templateUrl: 'editor.html' templateUrl: 'editor.html'
......
...@@ -533,7 +533,6 @@ class Annotation ...@@ -533,7 +533,6 @@ class Annotation
$event?.stopPropagation() $event?.stopPropagation()
$scope.editing = false $scope.editing = false
drafts.remove $scope.model drafts.remove $scope.model
annotator.enableAnnotating drafts.isEmpty()
switch $scope.action switch $scope.action
when 'create' when 'create'
...@@ -564,7 +563,6 @@ class Annotation ...@@ -564,7 +563,6 @@ class Annotation
$scope.editing = false $scope.editing = false
drafts.remove annotation drafts.remove annotation
annotator.enableAnnotating drafts.isEmpty()
switch $scope.action switch $scope.action
when 'create' when 'create'
...@@ -596,7 +594,6 @@ class Annotation ...@@ -596,7 +594,6 @@ class Annotation
annotator.publish 'beforeAnnotationCreated', [reply] annotator.publish 'beforeAnnotationCreated', [reply]
drafts.add reply drafts.add reply
annotator.disableAnnotating()
$scope.edit = ($event) -> $scope.edit = ($event) ->
$event?.stopPropagation() $event?.stopPropagation()
...@@ -605,7 +602,6 @@ class Annotation ...@@ -605,7 +602,6 @@ class Annotation
$scope.origText = $scope.model.text $scope.origText = $scope.model.text
$scope.origTags = $scope.model.tags $scope.origTags = $scope.model.tags
drafts.add $scope.model, -> $scope.cancel() drafts.add $scope.model, -> $scope.cancel()
annotator.disableAnnotating()
$scope.delete = ($event) -> $scope.delete = ($event) ->
$event?.stopPropagation() $event?.stopPropagation()
......
...@@ -56,11 +56,11 @@ class Hypothesis extends Annotator ...@@ -56,11 +56,11 @@ class Hypothesis extends Annotator
this.$inject = [ this.$inject = [
'$document', '$location', '$rootScope', '$route', '$window', '$document', '$location', '$rootScope', '$route', '$window',
'authentication', 'drafts' 'authentication'
] ]
constructor: ( constructor: (
$document, $location, $rootScope, $route, $window, $document, $location, $rootScope, $route, $window,
authentication, drafts authentication
) -> ) ->
Gettext.prototype.parse_locale_data annotator_locale_data Gettext.prototype.parse_locale_data annotator_locale_data
super ($document.find 'body') super ($document.find 'body')
......
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