diff --git a/app/coffee/modules/base.coffee b/app/coffee/modules/base.coffee
index 3cbec6dc..39fb32cf 100644
--- a/app/coffee/modules/base.coffee
+++ b/app/coffee/modules/base.coffee
@@ -21,6 +21,7 @@
taiga = @.taiga
groupBy = @.taiga.groupBy
+bindOnce = @.taiga.bindOnce
module = angular.module("taigaBase", ["taigaLocales"])
@@ -29,17 +30,7 @@ module = angular.module("taigaBase", ["taigaLocales"])
## Global Page Directive
#############################################################################
-class MainTaigaController extends taiga.Controller
- @.$inject = ["$scope"]
-
- constructor: (@scope) ->
- @scope.mainSection = "backlog"
-
- setSectionName: (name) ->
- @scope.mainSection = name
-
-
-MainTaigaDirective = ($log, $compile) ->
+MainTaigaDirective = ($log, $compile, $rootscope) ->
template = _.template("""

@@ -49,7 +40,7 @@ MainTaigaDirective = ($log, $compile) ->
-
-
+
Backlog
@@ -92,52 +83,29 @@ MainTaigaDirective = ($log, $compile) ->
""")
+ # 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) ->
- menuEntriesSelector = $el.find("ul.main-nav > li")
- menuEntries = _.map(menuEntriesSelector, (x) -> angular.element(x))
- menuEntriesByName = groupBy(menuEntries, (x) -> x.data("name"))
+ menuDom = $el.find("nav.menu")
+ menuDom.empty()
+ menuDom.append(dom)
- $scope.$watch "mainSection", (sectionName) ->
- $el.find("ul.main-nav a.active").removeClass("active")
- entry = menuEntriesByName[sectionName]
- entry.find("> a").addClass("active")
+ sectionName = targetScope.section
+ menuDom.find("a.active").removeClass("active")
+ menuDom.find("[data-name=#{sectionName}] > a").addClass("active")
link = ($scope, $el, $attrs, $ctrl) ->
- $log.debug "Taiga main directive initialized."
- linkMainNav($scope, $el, $attrs, $ctrl)
+ $scope.$on "$viewContentLoaded", (ctx) ->
+ renderMainMenu($el, ctx.targetScope.$$childHead)
- # 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.
- $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
- }
+ return {link:link}
-SectionMarkerDirective = ($log) ->
- 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])
+module.directive("tgMain", ["$log", "$compile", "$rootScope", MainTaigaDirective])
#############################################################################
diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee
index 3a22b2ed..5f3527a7 100644
--- a/app/coffee/modules/issues/list.coffee
+++ b/app/coffee/modules/issues/list.coffee
@@ -85,7 +85,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin)
module.controller("IssuesController", IssuesController)
#############################################################################
-## Issues Controller
+## Issues Directive
#############################################################################
paginatorTemplate = """
@@ -126,7 +126,6 @@ IssuesDirective = ($log, $location) ->
## Issues Pagination
#########################
- # Constants
template = _.template(paginatorTemplate)
linkPagination = ($scope, $el, $attrs, $ctrl) ->
@@ -197,13 +196,11 @@ IssuesDirective = ($log, $location) ->
$location.noreload($scope).search("page", $scope.page)
$ctrl.loadIssues()
-
#########################
## Issues Link
#########################
link = ($scope, $el, $attrs) ->
- console.log "IssuesDirective:link"
$ctrl = $el.controller()
linkPagination($scope, $el, $attrs, $ctrl)
diff --git a/app/partials/backlog.jade b/app/partials/backlog.jade
index 61273e38..584f6871 100644
--- a/app/partials/backlog.jade
+++ b/app/partials/backlog.jade
@@ -4,7 +4,8 @@ block head
title Taiga Project management web application with scrum in mind!
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
include views/modules/filters
section.main.backlog
diff --git a/app/partials/issues.jade b/app/partials/issues.jade
index 86230f5f..0285460b 100644
--- a/app/partials/issues.jade
+++ b/app/partials/issues.jade
@@ -4,7 +4,8 @@ block head
title Taiga Project management web application with scrum in mind!
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
header
h1 Filters