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
a1ae261d
Commit
a1ae261d
authored
Dec 04, 2014
by
Gergely Ujvari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store persona in the rootScope
parent
3765a865
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
23 deletions
+26
-23
account-controller.coffee
h/static/scripts/account/account-controller.coffee
+8
-6
controllers.coffee
h/static/scripts/controllers.coffee
+7
-7
annotation.coffee
h/static/scripts/directives/annotation.coffee
+11
-10
No files found.
h/static/scripts/account/account-controller.coffee
View file @
a1ae261d
class
AccountController
@
inject
=
[
'$scope'
,
'$filter'
,
'flash'
,
'session'
,
'identity'
,
'formHelpers'
]
constructor
:
(
$scope
,
$filter
,
flash
,
session
,
identity
,
formHelpers
)
->
@
inject
=
[
'$rootScope'
,
'$scope'
,
'$filter'
,
'flash'
,
'session'
,
'identity'
,
'formHelpers'
]
constructor
:
(
$rootScope
,
$scope
,
$filter
,
flash
,
session
,
identity
,
formHelpers
)
->
persona_filter
=
$filter
(
'persona'
)
$scope
.
subscriptionDescription
=
reply
:
'Receive notification emails when: - Someone replies to one of my annotations'
...
...
@@ -31,7 +33,7 @@ class AccountController
$scope
.
$broadcast
'formState'
,
form
.
$name
,
''
# Update status btn
$scope
.
tab
=
'Account'
session
.
profile
({
user_id
:
$
s
cope
.
persona
}).
$promise
session
.
profile
({
user_id
:
$
rootS
cope
.
persona
}).
$promise
.
then
(
result
)
=>
$scope
.
subscriptions
=
result
.
subscriptions
...
...
@@ -45,7 +47,7 @@ class AccountController
# The extension is then removed from the page.
# Confirmation of success is given.
return
unless
form
.
$valid
username
=
persona_filter
$
s
cope
.
persona
username
=
persona_filter
$
rootS
cope
.
persona
packet
=
username
:
username
pwd
:
form
.
pwd
.
$modelValue
...
...
@@ -60,7 +62,7 @@ class AccountController
formHelpers
.
applyValidationErrors
(
form
)
return
unless
form
.
$valid
username
=
persona_filter
$
s
cope
.
persona
username
=
persona_filter
$
rootS
cope
.
persona
packet
=
username
:
username
pwd
:
form
.
pwd
.
$modelValue
...
...
@@ -75,7 +77,7 @@ class AccountController
$scope
.
updated
=
(
index
,
form
)
->
packet
=
username
:
$
s
cope
.
persona
username
:
$
rootS
cope
.
persona
subscriptions
:
JSON
.
stringify
$scope
.
subscriptions
[
index
]
successHandler
=
angular
.
bind
(
null
,
onSuccess
,
form
)
...
...
h/static/scripts/controllers.coffee
View file @
a1ae261d
...
...
@@ -81,7 +81,7 @@ class AppController
Store
=
plugins
.
Store
delete
plugins
.
Store
if
$
s
cope
.
persona
or
annotator
.
socialView
.
name
is
'none'
if
$
rootS
cope
.
persona
or
annotator
.
socialView
.
name
is
'none'
annotator
.
addPlugin
'Store'
,
annotator
.
options
.
Store
$scope
.
store
=
plugins
.
Store
...
...
@@ -106,7 +106,7 @@ class AppController
Store
.
updateAnnotation
=
angular
.
noop
# Sort out which annotations should remain in place.
user
=
$
s
cope
.
persona
user
=
$
rootS
cope
.
persona
view
=
annotator
.
socialView
.
name
cull
=
(
acc
,
annotation
)
->
if
view
is
'single-player'
and
annotation
.
user
!=
user
...
...
@@ -147,7 +147,7 @@ class AppController
user
:
token
.
userId
userAuthorize
:
authorizeAction
$scope
.
$apply
->
$
s
cope
.
persona
=
token
.
userId
$
rootS
cope
.
persona
=
token
.
userId
reset
()
onlogout
=
->
...
...
@@ -159,15 +159,15 @@ class AppController
plugins
.
Permissions
?
.
destroy
()
delete
plugins
.
Permissions
$
s
cope
.
persona
=
null
$
rootS
cope
.
persona
=
null
checkingToken
=
false
reset
()
onready
=
->
if
not
checkingToken
and
typeof
$
s
cope
.
persona
==
'undefined'
if
not
checkingToken
and
typeof
$
rootS
cope
.
persona
==
'undefined'
# If we're not checking the token and persona is undefined, onlogin
# hasn't run, which means we aren't authenticated.
$
s
cope
.
persona
=
null
$
rootS
cope
.
persona
=
null
reset
()
if
isFirstRun
...
...
@@ -193,7 +193,7 @@ class AppController
$scope
.
$watch
'socialView.name'
,
(
newValue
,
oldValue
)
->
return
if
newValue
is
oldValue
initStore
()
if
newValue
is
'single-player'
and
not
$
s
cope
.
persona
if
newValue
is
'single-player'
and
not
$
rootS
cope
.
persona
annotator
.
show
()
flash
'info'
,
'You will need to sign in for your highlights to be saved.'
...
...
h/static/scripts/directives/annotation.coffee
View file @
a1ae261d
...
...
@@ -37,9 +37,9 @@ validate = (value) ->
# {@link annotator annotator service} for persistence.
###
AnnotationController = [
'$scope', '$timeout',
'$
rootScope', '$
scope', '$timeout',
'annotator', 'drafts', 'flash', 'documentHelpers', 'timeHelpers',
($scope, $timeout,
($
rootScope, $
scope, $timeout,
annotator, drafts, flash, documentHelpers, timeHelpers
) ->
@annotation = {}
...
...
@@ -182,15 +182,16 @@ AnnotationController = [
reply = {references, uri}
annotator.publish 'beforeAnnotationCreated', reply
reply.permissions.update = [model.user]
reply.permissions.delete = [model.user]
reply.permissions.admin = [model.user]
if $rootScope.persona?
reply.permissions.update = [$rootScope.persona]
reply.permissions.delete = [$rootScope.persona]
reply.permissions.admin = [$rootScope.persona]
# If replying to a public annotation make the response public.
if 'group:__world__' in (model.permissions.read or [])
reply.permissions.read = ['group:__world__']
else
reply.permissions.read = [model.user
]
# If replying to a public annotation make the response public.
if 'group:__world__' in (model.permissions.read or [])
reply.permissions.read = ['group:__world__']
else
reply.permissions.read = [$rootScope.persona
]
###
*
# @ngdoc method
...
...
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