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
9e656c0f
Commit
9e656c0f
authored
Nov 10, 2014
by
gergely-ujvari
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1580 from hypothesis/unsubscribe
Ability to unsubscribe from notifications
parents
37c65e79
3927770c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
2 deletions
+46
-2
account-controller.coffee
h/static/scripts/auth/account-controller.coffee
+18
-0
auth.coffee
h/static/scripts/auth/auth.coffee
+6
-0
account.html
h/templates/client/account.html
+19
-2
account-controller-test.coffee
tests/js/auth/account-controller-test.coffee
+3
-0
No files found.
h/static/scripts/auth/account-controller.coffee
View file @
9e656c0f
...
...
@@ -2,6 +2,8 @@ class AccountController
@
inject
=
[
'$scope'
,
'$filter'
,
'flash'
,
'session'
,
'identity'
,
'formHelpers'
]
constructor
:
(
$scope
,
$filter
,
flash
,
session
,
identity
,
formHelpers
)
->
persona_filter
=
$filter
(
'persona'
)
$scope
.
subscriptionDescription
=
reply
:
'Receive notification emails when: - Someone replies to one of my annotations'
onSuccess
=
(
form
,
response
)
->
# Fire flash messages.
...
...
@@ -28,6 +30,11 @@ class AccountController
$scope
.
$broadcast
'formState'
,
form
.
$name
,
''
# Update status btn
$scope
.
tab
=
'Account'
session
.
profile
({
user_id
:
$scope
.
persona
}).
$promise
.
then
(
result
)
=>
$scope
.
subscriptions
=
result
.
subscriptions
# Data for each of the forms
$scope
.
editProfile
=
{}
$scope
.
changePassword
=
{}
...
...
@@ -66,6 +73,17 @@ class AccountController
promise
=
session
.
edit_profile
(
packet
)
promise
.
$promise
.
then
(
successHandler
,
errorHandler
)
$scope
.
updated
=
(
index
,
form
)
->
packet
=
username
:
$scope
.
persona
subscriptions
:
JSON
.
stringify
$scope
.
subscriptions
[
index
]
successHandler
=
angular
.
bind
(
null
,
onSuccess
,
form
)
errorHandler
=
angular
.
bind
(
null
,
onError
,
form
)
promise
=
session
.
edit_profile
(
packet
)
promise
.
$promise
.
then
(
successHandler
,
errorHandler
)
angular
.
module
(
'h.auth'
)
.
controller
(
'AccountController'
,
AccountController
)
h/static/scripts/auth/auth.coffee
View file @
9e656c0f
...
...
@@ -111,6 +111,12 @@ configure = [
method
:
'GET'
withCredentials
:
true
sessionProvider
.
actions
.
profile
=
method
:
'GET'
params
:
__formid__
:
'profile'
withCredentials
:
true
for
action
in
AUTH_SESSION_ACTIONS
sessionProvider
.
actions
[
action
]
=
method
:
'POST'
...
...
h/templates/client/account.html
View file @
9e656c0f
<div
class=
"tabbable"
ng-controller=
"AccountController"
>
<div
class=
"tabbable"
ng-controller=
"AccountController"
ng-model=
"tab"
>
<div
class=
"tab-pane"
title=
"Account"
>
<form
class=
"account-form form"
name=
"changePasswordForm"
ng-submit=
"submit(changePasswordForm)"
novalidate
form-validate
>
<form
class=
"account-form form"
name=
"changePasswordForm"
ng-submit=
"submit(changePasswordForm)"
novalidate
form-validate
>
<h2
class=
"form-heading"
><span>
Change Your Password
</span></h2>
<div
class=
"form-field"
>
...
...
@@ -66,4 +72,15 @@
</div>
</form>
</div>
<div
class=
"tab-pane"
title=
"Notifications"
>
<form
class=
"account-form form"
name=
"notificationsForm"
>
<p
class=
"form-description"
>
Recieve notification emails for:
</p>
<div
class=
"form-field form-checkbox-list"
>
<div
class=
"form-checkbox-item"
ng-repeat=
"subscription in subscriptions"
>
<input
id=
"checkbox-{{$index}}"
type=
"checkbox"
ng-model=
"subscription.active"
ng-change=
"updated($index, notificationsForm)"
/>
<label
class=
"form-label"
for=
"checkbox-{{$index}}"
>
{{subscriptionDescription[subscription.type]}}
</label>
</div>
</div>
</form>
</div>
</div>
tests/js/auth/account-controller-test.coffee
View file @
9e656c0f
...
...
@@ -10,6 +10,7 @@ describe 'h.auth.AccountController', ->
fakeFormHelpers
=
null
editProfilePromise
=
null
disableUserPromise
=
null
profilePromise
=
null
createController
=
null
beforeEach
module
(
'h.auth'
)
...
...
@@ -37,8 +38,10 @@ describe 'h.auth.AccountController', ->
disableUserPromise
=
{
then
:
sandbox
.
stub
()}
editProfilePromise
=
{
then
:
sandbox
.
stub
()}
profilePromise
=
{
then
:
sandbox
.
stub
()}
fakeSession
.
edit_profile
=
sandbox
.
stub
().
returns
(
$promise
:
editProfilePromise
)
fakeSession
.
disable_user
=
sandbox
.
stub
().
returns
(
$promise
:
disableUserPromise
)
fakeSession
.
profile
=
sandbox
.
stub
().
returns
(
$promise
:
profilePromise
)
createController
=
->
$controller
(
'AccountController'
,
{
$scope
:
$scope
})
...
...
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