Fixed navegation.
parent
6548576ad9
commit
3c8fdfb007
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
groupBy = @.taiga.groupBy
|
groupBy = @.taiga.groupBy
|
||||||
|
bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
module = angular.module("taigaBase", ["taigaLocales"])
|
module = angular.module("taigaBase", ["taigaLocales"])
|
||||||
|
|
||||||
|
@ -29,17 +30,7 @@ module = angular.module("taigaBase", ["taigaLocales"])
|
||||||
## Global Page Directive
|
## Global Page Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
class MainTaigaController extends taiga.Controller
|
MainTaigaDirective = ($log, $compile, $rootscope) ->
|
||||||
@.$inject = ["$scope"]
|
|
||||||
|
|
||||||
constructor: (@scope) ->
|
|
||||||
@scope.mainSection = "backlog"
|
|
||||||
|
|
||||||
setSectionName: (name) ->
|
|
||||||
@scope.mainSection = name
|
|
||||||
|
|
||||||
|
|
||||||
MainTaigaDirective = ($log, $compile) ->
|
|
||||||
template = _.template("""
|
template = _.template("""
|
||||||
<h1 class="logo"><a href="" title="Home"><img src="/images/logo.png" alt="Taiga"/></a></h1>
|
<h1 class="logo"><a href="" title="Home"><img src="/images/logo.png" alt="Taiga"/></a></h1>
|
||||||
<ul class="main-nav">
|
<ul class="main-nav">
|
||||||
|
@ -49,7 +40,7 @@ MainTaigaDirective = ($log, $compile) ->
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li data-name="backlog" tg-nav="project-backlog:project=project.slug">
|
<li data-name="backlog" tg-nav="project-backlog:project=project.slug">
|
||||||
<a href="" title="Backlog" class="active">
|
<a href="" title="Backlog" tg-nav="project-backlog:project=project.slug">
|
||||||
<span class="icon icon-backlog"></span>
|
<span class="icon icon-backlog"></span>
|
||||||
<span class="item">Backlog</span>
|
<span class="item">Backlog</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -92,52 +83,29 @@ MainTaigaDirective = ($log, $compile) ->
|
||||||
</a>
|
</a>
|
||||||
</div>""")
|
</div>""")
|
||||||
|
|
||||||
|
# WARNING: this code has traces of slighty hacky parts
|
||||||
|
# This rerenders and compiles the navigation when ng-view
|
||||||
|
# content loaded signal is raised using inner scope.
|
||||||
|
renderMainMenu = ($el, targetScope) ->
|
||||||
|
container = $el.find(".master > .wrapper")
|
||||||
|
dom = $compile(template({}))(targetScope)
|
||||||
|
|
||||||
linkMainNav = ($scope, $el, $attrs, $ctrl) ->
|
menuDom = $el.find("nav.menu")
|
||||||
menuEntriesSelector = $el.find("ul.main-nav > li")
|
menuDom.empty()
|
||||||
menuEntries = _.map(menuEntriesSelector, (x) -> angular.element(x))
|
menuDom.append(dom)
|
||||||
menuEntriesByName = groupBy(menuEntries, (x) -> x.data("name"))
|
|
||||||
|
|
||||||
$scope.$watch "mainSection", (sectionName) ->
|
sectionName = targetScope.section
|
||||||
$el.find("ul.main-nav a.active").removeClass("active")
|
menuDom.find("a.active").removeClass("active")
|
||||||
entry = menuEntriesByName[sectionName]
|
menuDom.find("[data-name=#{sectionName}] > a").addClass("active")
|
||||||
entry.find("> a").addClass("active")
|
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
$log.debug "Taiga main directive initialized."
|
$scope.$on "$viewContentLoaded", (ctx) ->
|
||||||
linkMainNav($scope, $el, $attrs, $ctrl)
|
renderMainMenu($el, ctx.targetScope.$$childHead)
|
||||||
|
|
||||||
# WARNING: this code has traces of slighty hacky parts
|
return {link:link}
|
||||||
# This rerenders and compiles the navigation when ng-view
|
|
||||||
# content loaded signal is raised using inner scope.
|
|
||||||
$scope.$on "$viewContentLoaded", ->
|
|
||||||
body = angular.element("body")
|
|
||||||
wScope = body.find(".wrapper").scope()
|
|
||||||
html = template({})
|
|
||||||
dom = $compile(html)(wScope)
|
|
||||||
|
|
||||||
menuDom = $el.find("nav.menu")
|
|
||||||
menuDom.empty()
|
|
||||||
menuDom.append(dom)
|
|
||||||
|
|
||||||
return {
|
|
||||||
controller: MainTaigaController
|
|
||||||
link: link
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SectionMarkerDirective = ($log) ->
|
module.directive("tgMain", ["$log", "$compile", "$rootScope", MainTaigaDirective])
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
|
||||||
$ctrl.setSectionName($attrs.tgSectionMarker)
|
|
||||||
|
|
||||||
return {
|
|
||||||
require: "^tgMain"
|
|
||||||
link: link
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.directive("tgMain", ["$log", "$compile", MainTaigaDirective])
|
|
||||||
module.directive("tgSectionMarker", ["$log", SectionMarkerDirective])
|
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
|
@ -85,7 +85,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
module.controller("IssuesController", IssuesController)
|
module.controller("IssuesController", IssuesController)
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Issues Controller
|
## Issues Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
paginatorTemplate = """
|
paginatorTemplate = """
|
||||||
|
@ -126,7 +126,6 @@ IssuesDirective = ($log, $location) ->
|
||||||
## Issues Pagination
|
## Issues Pagination
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
# Constants
|
|
||||||
template = _.template(paginatorTemplate)
|
template = _.template(paginatorTemplate)
|
||||||
|
|
||||||
linkPagination = ($scope, $el, $attrs, $ctrl) ->
|
linkPagination = ($scope, $el, $attrs, $ctrl) ->
|
||||||
|
@ -197,13 +196,11 @@ IssuesDirective = ($log, $location) ->
|
||||||
$location.noreload($scope).search("page", $scope.page)
|
$location.noreload($scope).search("page", $scope.page)
|
||||||
$ctrl.loadIssues()
|
$ctrl.loadIssues()
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
## Issues Link
|
## Issues Link
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
console.log "IssuesDirective:link"
|
|
||||||
$ctrl = $el.controller()
|
$ctrl = $el.controller()
|
||||||
linkPagination($scope, $el, $attrs, $ctrl)
|
linkPagination($scope, $el, $attrs, $ctrl)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ block head
|
||||||
title Taiga Project management web application with scrum in mind!
|
title Taiga Project management web application with scrum in mind!
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div.wrapper(tg-backlog, ng-controller="BacklogController as ctrl")
|
div.wrapper(tg-backlog, ng-controller="BacklogController as ctrl",
|
||||||
|
ng-init="section='backlog'")
|
||||||
sidebar.menu-secondary.extrabar.filters-bar
|
sidebar.menu-secondary.extrabar.filters-bar
|
||||||
include views/modules/filters
|
include views/modules/filters
|
||||||
section.main.backlog
|
section.main.backlog
|
||||||
|
|
|
@ -4,7 +4,8 @@ block head
|
||||||
title Taiga Project management web application with scrum in mind!
|
title Taiga Project management web application with scrum in mind!
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div.wrapper(tg-issues, ng-controller="IssuesController as ctrl")
|
div.wrapper(tg-issues, ng-controller="IssuesController as ctrl",
|
||||||
|
ng-init="section='issues'")
|
||||||
sidebar.menu-secondary.sidebar
|
sidebar.menu-secondary.sidebar
|
||||||
header
|
header
|
||||||
h1 Filters
|
h1 Filters
|
||||||
|
|
Loading…
Reference in New Issue