Add directive for public register message on login.

This removes conditional logic on template linking
process and innecesary scope mutation on login directive.
Also, it has less data bindings, because the new directive
do all work at compile time without adding additional
bindings.
stable
Andrey Antukh 2014-09-02 19:19:10 +02:00
parent 56220d6101
commit 8c46f31720
2 changed files with 26 additions and 3 deletions

View File

@ -145,6 +145,31 @@ module.service("$tgAuth", AuthService)
## Login Directive
#############################################################################
# Directive that manages the visualization of public register
# message/link on login page.
PublicRegisterMessageDirective = ($config) ->
template = _.template("""
<p class="login-text">
<span>Not registered yet?</span>
<a href="<%= url %>" tg-nav="register" title="Register"> create your free account here</a>
</p>""")
templateFn = ->
url = $config.get("publicRegisterEnabled")
if not url
return ""
return template({url:url})
return {
restrict: "AE"
scope: {}
template: templateFn
}
module.directive("tgPublicRegisterMessage", ["$tgConfig", PublicRegisterMessageDirective])
LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls) ->
link = ($scope, $el, $attrs) ->
$scope.pubblicRegisterEnabled = $config.get("pubblicRegisterEnabled")

View File

@ -13,6 +13,4 @@ div.login-form-container(tg-login)
a.button.button-login.button-gray(href="", ng-click="ctrl.submit()", title="Sign in") Sign in
input(type="submit", style="display:none")
p.login-text(ng-if="pubblicRegisterEnabled")
span Not registered yet?
a(href="", tg-nav="register", title="Register") create your free account here
tg-public-register-message