Merge pull request #94 from taigaio/autocomplete-bug

Fix browser autofill event problem with angular.
stable
David Barragán Merino 2014-10-11 13:03:39 +02:00
commit 1376c063bb
2 changed files with 14 additions and 11 deletions

View File

@ -172,9 +172,7 @@ module.directive("tgPublicRegisterMessage", ["$tgConfig", "$tgNavUrls", PublicRe
LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $events) -> LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $events) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
$scope.data = {} onSuccess = (response) ->
onSuccessSubmit = (response) ->
if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login") if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login")
nextUrl = $routeParams['next'] nextUrl = $routeParams['next']
else else
@ -183,16 +181,21 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $
$events.setupConnection() $events.setupConnection()
$location.path(nextUrl) $location.path(nextUrl)
onErrorSubmit = (response) -> onError = (response) ->
$confirm.notify("light-error", "According to our Oompa Loompas, your username/email $confirm.notify("light-error", "According to our Oompa Loompas, your username/email
or password are incorrect.") #TODO: i18n or password are incorrect.") #TODO: i18n
submit = -> submit = ->
form = $el.find("form").checksley() form = new checksley.Form($el.find("form.login-form"))
if not form.validate() if not form.validate()
return return
promise = $auth.login($scope.data) data = {
promise.then(onSuccessSubmit, onErrorSubmit) "username": $el.find("form.login-form input[name=username]").val(),
"password": $el.find("form.login-form input[name=password]").val()
}
promise = $auth.login(data)
return promise.then(onSuccess, onError)
$el.on "click", "a.button-login", (event) -> $el.on "click", "a.button-login", (event) ->
event.preventDefault() event.preventDefault()

View File

@ -1,16 +1,16 @@
div.login-form-container(tg-login) div.login-form-container(tg-login)
form.login-form form.login-form
fieldset fieldset
input(type="text", name="username", ng-model="data.username", data-required="true", input(type="text", name="username", data-required="true",
placeholder="Username or Email (case sensitive)") placeholder="Username or Email (case sensitive)")
fieldset.login-password fieldset.login-password
input(type="password", name="password", ng-model="data.password", data-required="true", input(type="password", name="password", data-required="true",
placeholder="Password (case sensitive)") placeholder="Password (case sensitive)")
// This should be hidden when focus on pass // This should be hidden when focus on pass
a.forgot-pass(href="", tg-nav="forgot-password", title="Did you forgot your password?") Forgot it? a.forgot-pass(href="", tg-nav="forgot-password", title="Did you forgot your password?") Forgot it?
fieldset fieldset
a.button.button-login.button-gray(href="", ng-click="ctrl.submit()", title="Sign in") Sign in a.button.button-login.button-gray(href="", title="Sign in") Sign in
input(type="submit", style="display:none") input(type="submit", style="display:none")
tg-public-register-message tg-public-register-message