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
dbc860f9
Commit
dbc860f9
authored
Jan 22, 2016
by
Nick Stenning
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2880 from hypothesis/move-login-form-to-directive
Extract the login form into its own directive
parents
14ede411
fb6013b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
68 deletions
+89
-68
app.coffee
h/static/scripts/app.coffee
+1
-1
login-form.js
h/static/scripts/directive/login-form.js
+18
-2
login-form-test.coffee
h/static/scripts/test/login-form-test.coffee
+5
-5
auth.html
h/templates/client/auth.html
+0
-60
login_form.html
h/templates/client/login_form.html
+65
-0
No files found.
h/static/scripts/app.coffee
View file @
dbc860f9
...
@@ -101,7 +101,6 @@ module.exports = angular.module('h', [
...
@@ -101,7 +101,6 @@ module.exports = angular.module('h', [
.
controller
(
'AppController'
,
require
(
'./app-controller'
))
.
controller
(
'AppController'
,
require
(
'./app-controller'
))
.
controller
(
'AnnotationUIController'
,
require
(
'./annotation-ui-controller'
))
.
controller
(
'AnnotationUIController'
,
require
(
'./annotation-ui-controller'
))
.
controller
(
'AnnotationViewerController'
,
require
(
'./annotation-viewer-controller'
))
.
controller
(
'AnnotationViewerController'
,
require
(
'./annotation-viewer-controller'
))
.
controller
(
'AuthController'
,
require
(
'./auth-controller'
))
.
controller
(
'StreamController'
,
require
(
'./stream-controller'
))
.
controller
(
'StreamController'
,
require
(
'./stream-controller'
))
.
controller
(
'WidgetController'
,
require
(
'./widget-controller'
))
.
controller
(
'WidgetController'
,
require
(
'./widget-controller'
))
...
@@ -112,6 +111,7 @@ module.exports = angular.module('h', [
...
@@ -112,6 +111,7 @@ module.exports = angular.module('h', [
.
directive
(
'formValidate'
,
require
(
'./directive/form-validate'
))
.
directive
(
'formValidate'
,
require
(
'./directive/form-validate'
))
.
directive
(
'groupList'
,
require
(
'./directive/group-list'
).
directive
)
.
directive
(
'groupList'
,
require
(
'./directive/group-list'
).
directive
)
.
directive
(
'hAutofocus'
,
require
(
'./directive/h-autofocus'
))
.
directive
(
'hAutofocus'
,
require
(
'./directive/h-autofocus'
))
.
directive
(
'loginForm'
,
require
(
'./directive/login-form'
).
directive
)
.
directive
(
'markdown'
,
require
(
'./directive/markdown'
))
.
directive
(
'markdown'
,
require
(
'./directive/markdown'
))
.
directive
(
'simpleSearch'
,
require
(
'./directive/simple-search'
))
.
directive
(
'simpleSearch'
,
require
(
'./directive/simple-search'
))
.
directive
(
'statusButton'
,
require
(
'./directive/status-button'
))
.
directive
(
'statusButton'
,
require
(
'./directive/status-button'
))
...
...
h/static/scripts/
auth-controller
.js
→
h/static/scripts/
directive/login-form
.js
View file @
dbc860f9
'use strict'
;
// @ngInject
// @ngInject
function
Auth
Controller
(
$scope
,
$timeout
,
flash
,
session
,
formRespond
)
{
function
Controller
(
$scope
,
$timeout
,
flash
,
session
,
formRespond
)
{
var
pendingTimeout
=
null
;
var
pendingTimeout
=
null
;
function
success
(
data
)
{
function
success
(
data
)
{
...
@@ -87,4 +89,18 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
...
@@ -87,4 +89,18 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
});
});
}
}
module
.
exports
=
AuthController
;
module
.
exports
=
{
directive
:
function
()
{
return
{
bindToController
:
true
,
controller
:
Controller
,
controllerAs
:
'vm'
,
restrict
:
'E'
,
scope
:
{
onClose
:
'&'
,
},
templateUrl
:
'login_form.html'
,
};
},
Controller
:
Controller
,
};
h/static/scripts/test/
auth-controller
-test.coffee
→
h/static/scripts/test/
login-form
-test.coffee
View file @
dbc860f9
...
@@ -18,7 +18,7 @@ class MockSession
...
@@ -18,7 +18,7 @@ class MockSession
mockFlash
=
info
:
sandbox
.
spy
()
mockFlash
=
info
:
sandbox
.
spy
()
mockFormRespond
=
sandbox
.
spy
()
mockFormRespond
=
sandbox
.
spy
()
describe
'
h:Auth
Controller'
,
->
describe
'
loginForm.
Controller'
,
->
$scope
=
null
$scope
=
null
$timeout
=
null
$timeout
=
null
auth
=
null
auth
=
null
...
@@ -27,7 +27,7 @@ describe 'h:AuthController', ->
...
@@ -27,7 +27,7 @@ describe 'h:AuthController', ->
before
->
before
->
angular
.
module
(
'h'
,
[])
angular
.
module
(
'h'
,
[])
.
controller
(
'
AuthController'
,
require
(
'../auth-controller'
)
)
.
controller
(
'
loginFormController'
,
require
(
'../directive/login-form'
).
Controller
)
beforeEach
module
(
'h'
)
beforeEach
module
(
'h'
)
beforeEach
module
(
'h.templates'
)
beforeEach
module
(
'h.templates'
)
...
@@ -43,7 +43,7 @@ describe 'h:AuthController', ->
...
@@ -43,7 +43,7 @@ describe 'h:AuthController', ->
$scope
=
$rootScope
.
$new
()
$scope
=
$rootScope
.
$new
()
$timeout
=
_$timeout_
$timeout
=
_$timeout_
$controller
=
_$controller_
$controller
=
_$controller_
auth
=
$controller
'
Auth
Controller'
,
{
$scope
}
auth
=
$controller
'
loginForm
Controller'
,
{
$scope
}
session
=
_session_
session
=
_session_
sandbox
.
spy
session
,
'login'
sandbox
.
spy
session
,
'login'
...
@@ -95,7 +95,7 @@ describe 'h:AuthController', ->
...
@@ -95,7 +95,7 @@ describe 'h:AuthController', ->
# Get an AuthController object with our mock session.
# Get an AuthController object with our mock session.
authCtrl
=
$controller
(
authCtrl
=
$controller
(
'
Auth
Controller'
,
{
$scope
:
$scope
,
session
:
myMockSession
})
'
loginForm
Controller'
,
{
$scope
:
$scope
,
session
:
myMockSession
})
form
=
{
$name
:
'register'
,
$valid
:
true
}
form
=
{
$name
:
'register'
,
$valid
:
true
}
...
@@ -113,7 +113,7 @@ describe 'h:AuthController', ->
...
@@ -113,7 +113,7 @@ describe 'h:AuthController', ->
$promise
:
{
finally
:
sandbox
.
stub
()}
$promise
:
{
finally
:
sandbox
.
stub
()}
authCtrl
=
$controller
(
authCtrl
=
$controller
(
'
Auth
Controller'
,
{
$scope
:
$scope
,
session
:
myMockSession
})
'
loginForm
Controller'
,
{
$scope
:
$scope
,
session
:
myMockSession
})
form
=
{
$name
:
'register'
,
$valid
:
true
}
form
=
{
$name
:
'register'
,
$valid
:
true
}
...
...
h/templates/client/auth.html
deleted
100644 → 0
View file @
14ede411
<div
class=
"form-vertical"
ng-controller=
"AuthController as vm"
ng-form=
"form"
ng-submit=
"vm.submit(form['login'])"
>
<div
class=
"tab-content"
>
<form
data-value=
"login"
class=
"form"
name=
"login"
form-validate
novalidate
>
<p
class=
"form-description form-error"
ng-show=
"login.responseErrorMessage"
>
{{login.responseErrorMessage}}
</p>
<div
class=
"form-field"
>
<label
class=
"form-label"
for=
"field-login-username"
>
Username or email address:
</label>
<input
class=
"form-input"
type=
"text"
id=
"field-login-username"
name=
"username"
value=
""
ng-model=
"model.username"
required
autocapitalize=
"false"
h-autofocus
/>
<ul
class=
"form-error-list"
>
<li
class=
"form-error"
ng-show=
"login.username.$error.required"
>
Please enter your username or email address.
</li>
<li
class=
"form-error"
ng-show=
"login.username.$error.response"
>
{{login.username.responseErrorMessage}}
</li>
</ul>
</div>
<div
class=
"form-field"
>
<label
class=
"form-label"
for=
"field-login-password"
>
Password:
</label>
<input
class=
"form-input"
id=
"field-login-password"
type=
"password"
name=
"password"
value=
""
ng-model=
"model.password"
required
autocapitalize=
"false"
autocorrect=
"false"
/>
<ul
class=
"form-error-list"
>
<li
class=
"form-error"
ng-show=
"login.password.$error.required"
>
Please enter your password.
</li>
<li
class=
"form-error"
ng-show=
"login.password.$error.response"
>
{{login.password.responseErrorMessage}}
</li>
</ul>
</div>
<div
class=
"form-actions"
>
<div
class=
"form-actions-message"
>
<a
href=
"/forgot_password"
target=
"_blank"
>
Forgot your password?
</a>
</div>
<div
class=
"form-actions-buttons"
>
<button
class=
"btn btn-primary"
type=
"submit"
name=
"login"
status-button=
"login"
>
Sign in
</button>
</div>
</div>
</form>
</div>
<!-- /.tab-content -->
</div>
h/templates/client/login_form.html
0 → 100644
View file @
dbc860f9
<div
class=
"sheet"
>
<i
class=
"close h-icon-close"
role=
"button"
title=
"Close"
ng-click=
"vm.onClose()"
></i>
<div
class=
"form-vertical"
ng-form=
"form"
ng-submit=
"vm.submit(form['login'])"
>
<div
class=
"tab-content"
>
<form
data-value=
"login"
class=
"form"
name=
"login"
form-validate
novalidate
>
<p
class=
"form-description form-error"
ng-show=
"login.responseErrorMessage"
>
{{login.responseErrorMessage}}
</p>
<div
class=
"form-field"
>
<label
class=
"form-label"
for=
"field-login-username"
>
Username or email address:
</label>
<input
class=
"form-input"
type=
"text"
id=
"field-login-username"
name=
"username"
value=
""
ng-model=
"model.username"
required
autocapitalize=
"false"
h-autofocus
/>
<ul
class=
"form-error-list"
>
<li
class=
"form-error"
ng-show=
"login.username.$error.required"
>
Please enter your username or email address.
</li>
<li
class=
"form-error"
ng-show=
"login.username.$error.response"
>
{{login.username.responseErrorMessage}}
</li>
</ul>
</div>
<div
class=
"form-field"
>
<label
class=
"form-label"
for=
"field-login-password"
>
Password:
</label>
<input
class=
"form-input"
id=
"field-login-password"
type=
"password"
name=
"password"
value=
""
ng-model=
"model.password"
required
autocapitalize=
"false"
autocorrect=
"false"
/>
<ul
class=
"form-error-list"
>
<li
class=
"form-error"
ng-show=
"login.password.$error.required"
>
Please enter your password.
</li>
<li
class=
"form-error"
ng-show=
"login.password.$error.response"
>
{{login.password.responseErrorMessage}}
</li>
</ul>
</div>
<div
class=
"form-actions"
>
<div
class=
"form-actions-message"
>
<a
href=
"/forgot_password"
target=
"_blank"
>
Forgot your password?
</a>
</div>
<div
class=
"form-actions-buttons"
>
<button
class=
"btn btn-primary"
type=
"submit"
name=
"login"
status-button=
"login"
>
Sign in
</button>
</div>
</div>
</form>
</div>
</div>
</div>
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