Make lazy the tg-nav directive.
parent
913ae3a5f6
commit
2715a5cda8
|
@ -35,7 +35,7 @@ class NavigationUrlsService extends taiga.Service
|
||||||
return @.urls[name]
|
return @.urls[name]
|
||||||
|
|
||||||
|
|
||||||
NavigationUrlsDirective = ($navurls, $auth, $q) ->
|
NavigationUrlsDirective = ($navurls, $auth, $q, $location) ->
|
||||||
# Example:
|
# Example:
|
||||||
# link(tg-nav="project-backlog:project='sss',")
|
# link(tg-nav="project-backlog:project='sss',")
|
||||||
|
|
||||||
|
@ -67,21 +67,26 @@ NavigationUrlsDirective = ($navurls, $auth, $q) ->
|
||||||
return url.replace(/(:\w+)/g, replacer)
|
return url.replace(/(:\w+)/g, replacer)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
parseNav($attrs.tgNav, $scope).then (result) ->
|
$el.on "click", (event) ->
|
||||||
[name, options] = result
|
event.preventDefault()
|
||||||
|
|
||||||
user = $auth.getUser()
|
parseNav($attrs.tgNav, $scope).then (result) ->
|
||||||
options.user = user.username if user
|
[name, options] = result
|
||||||
|
user = $auth.getUser()
|
||||||
|
options.user = user.username if user
|
||||||
|
|
||||||
url = $navurls.resolve(name)
|
url = $navurls.resolve(name)
|
||||||
fullUrl = formatUrl(url, options)
|
fullUrl = formatUrl(url, options)
|
||||||
$el.attr("href", fullUrl)
|
$location.url(fullUrl)
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaBase")
|
module = angular.module("taigaBase")
|
||||||
module.service("$tgNavUrls", NavigationUrlsService)
|
module.service("$tgNavUrls", NavigationUrlsService)
|
||||||
module.directive("tgNav", ["$tgNavUrls", "$tgAuth", "$q", NavigationUrlsDirective])
|
module.directive("tgNav", ["$tgNavUrls", "$tgAuth", "$q", "$location", NavigationUrlsDirective])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue