Add navegation directive and main controller.

stable
Andrey Antukh 2014-06-25 12:12:28 +02:00
parent 53cd77513f
commit d59dcfed38
6 changed files with 83 additions and 49 deletions

View File

@ -63,13 +63,12 @@ angular.module("taigaCommon", [])
modules = [ modules = [
# Main Global Modules # Main Global Modules
"taigaConfig",
"taigaBase", "taigaBase",
"taigaCommon",
"taigaConfig",
"taigaResources", "taigaResources",
"taigaLocales", "taigaLocales",
"taigaAuth", "taigaAuth",
"taigaCommon",
"taigaNavigation",
# Specific Modules # Specific Modules
"taigaBacklog", "taigaBacklog",

View File

@ -19,4 +19,76 @@
# File: modules/base.coffee # File: modules/base.coffee
### ###
taiga = @.taiga
groupBy = @.taiga.groupBy
module = angular.module("taigaBase", ["taigaLocales"]) 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) ->
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"))
$scope.$watch "mainSection", (sectionName) ->
$el.find("ul.main-nav a.active").removeClass("active")
entry = menuEntriesByName[sectionName]
entry.find("> a").addClass("active")
link = ($scope, $el, $attrs, $ctrl) ->
$log.debug "Taiga main directive initialized."
linkMainNav($scope, $el, $attrs, $ctrl)
return {
controller: MainTaigaController
link: link
}
SectionMarkerDirective = ($log) ->
link = ($scope, $el, $attrs, $ctrl) ->
$ctrl.setSectionName($attrs.tgSectionMarker)
return {
require: "^tgMain"
link: link
}
module.directive("tgMain", ["$log", MainTaigaDirective])
module.directive("tgSectionMarker", ["$log", SectionMarkerDirective])
#############################################################################
## Navigation
#############################################################################
urls = {
"home": "/",
"profile": "/:user",
"project": "/project/:project",
"project-backlog": "/project/:project/backlog",
"project-taskboard": "/project/:project/taskboard/:sprint",
}
init = ($log, $navurls) ->
$log.debug "Initialize navigation urls"
$navurls.update(urls)
module.run(["$log", "$tgNavUrls", init])

View File

@ -1,38 +0,0 @@
###
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# File: modules/navigation.coffee
###
# Simple module that uses navurls service and register
# navigation urls for taiga.
urls = {
"home": "/",
"profile": "/:user",
"project": "/project/:project",
"project-backlog": "/project/:project/backlog",
"project-taskboard": "/project/:project/taskboard/:sprint",
}
init = ($log, $navurls) ->
$log.debug "Initialize navigation urls"
$navurls.update(urls)
module = angular.module("taigaNavigation", ["taigaBase"])
module.run(["$log", "$tgNavUrls", init])

View File

@ -8,7 +8,7 @@ html(lang="en", ng-app="taiga")
meta(name="keywords", content="Agile, Taiga, Management, Github") meta(name="keywords", content="Agile, Taiga, Management, Github")
meta(name="viewport", content="width=device-width, user-scalable=no") meta(name="viewport", content="width=device-width, user-scalable=no")
link(rel="stylesheet", href="/styles/main.css") link(rel="stylesheet", href="/styles/main.css")
body body(tg-main)
include partials/views/modules/nav include partials/views/modules/nav
div.master(ng-view="") div.master(ng-view="")
div.hidden.lightbox.lightbox_confirm-delete div.hidden.lightbox.lightbox_confirm-delete

View File

@ -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-taskboard, ng-controller="TaskboardController as ctrl") div.wrapper(tg-taskboard, ng-controller="TaskboardController as ctrl",
tg-section-marker="backlog")
section.main.taskboard section.main.taskboard
h1 h1
span(tg-bo-html="project.name") span(tg-bo-html="project.name")

View File

@ -3,27 +3,27 @@ nav.menu
a(href="", title="Home") a(href="", title="Home")
img(src="/images/logo.png", alt="Taiga") img(src="/images/logo.png", alt="Taiga")
ul.main-nav ul.main-nav
li li(data-name="search")
a(href="", title="Search") a(href="", title="Search")
span.icon.icon-search span.icon.icon-search
span.item Search span.item Search
li li(data-name="backlog")
a.active(href="", title="Backlog") a.active(href="", title="Backlog")
span.icon.icon-backlog span.icon.icon-backlog
span.item Backlog span.item Backlog
li li(data-name="kanban")
a(href="", title="Kanban") a(href="", title="Kanban")
span.icon.icon-kanban span.icon.icon-kanban
span.item Kanban span.item Kanban
li li(data-name="issues")
a(href="", title="Issues") a(href="", title="Issues")
span.icon.icon-issues span.icon.icon-issues
span.item Issues span.item Issues
li li(data-name="wiki")
a(href="", title="Wiki") a(href="", title="Wiki")
span.icon.icon-wiki span.icon.icon-wiki
span.item Wiki span.item Wiki
li li(data-name"video")
a(href="", title="Video") a(href="", title="Video")
span.icon.icon-video span.icon.icon-video
span.item Video span.item Video