Add navegation directive and main controller.
parent
53cd77513f
commit
d59dcfed38
|
@ -63,13 +63,12 @@ angular.module("taigaCommon", [])
|
|||
|
||||
modules = [
|
||||
# Main Global Modules
|
||||
"taigaConfig",
|
||||
"taigaBase",
|
||||
"taigaCommon",
|
||||
"taigaConfig",
|
||||
"taigaResources",
|
||||
"taigaLocales",
|
||||
"taigaAuth",
|
||||
"taigaCommon",
|
||||
"taigaNavigation",
|
||||
|
||||
# Specific Modules
|
||||
"taigaBacklog",
|
||||
|
|
|
@ -19,4 +19,76 @@
|
|||
# File: modules/base.coffee
|
||||
###
|
||||
|
||||
taiga = @.taiga
|
||||
groupBy = @.taiga.groupBy
|
||||
|
||||
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])
|
||||
|
|
|
@ -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])
|
|
@ -8,7 +8,7 @@ html(lang="en", ng-app="taiga")
|
|||
meta(name="keywords", content="Agile, Taiga, Management, Github")
|
||||
meta(name="viewport", content="width=device-width, user-scalable=no")
|
||||
link(rel="stylesheet", href="/styles/main.css")
|
||||
body
|
||||
body(tg-main)
|
||||
include partials/views/modules/nav
|
||||
div.master(ng-view="")
|
||||
div.hidden.lightbox.lightbox_confirm-delete
|
||||
|
|
|
@ -4,7 +4,8 @@ block head
|
|||
title Taiga Project management web application with scrum in mind!
|
||||
|
||||
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
|
||||
h1
|
||||
span(tg-bo-html="project.name")
|
||||
|
|
|
@ -3,27 +3,27 @@ nav.menu
|
|||
a(href="", title="Home")
|
||||
img(src="/images/logo.png", alt="Taiga")
|
||||
ul.main-nav
|
||||
li
|
||||
li(data-name="search")
|
||||
a(href="", title="Search")
|
||||
span.icon.icon-search
|
||||
span.item Search
|
||||
li
|
||||
li(data-name="backlog")
|
||||
a.active(href="", title="Backlog")
|
||||
span.icon.icon-backlog
|
||||
span.item Backlog
|
||||
li
|
||||
li(data-name="kanban")
|
||||
a(href="", title="Kanban")
|
||||
span.icon.icon-kanban
|
||||
span.item Kanban
|
||||
li
|
||||
li(data-name="issues")
|
||||
a(href="", title="Issues")
|
||||
span.icon.icon-issues
|
||||
span.item Issues
|
||||
li
|
||||
li(data-name="wiki")
|
||||
a(href="", title="Wiki")
|
||||
span.icon.icon-wiki
|
||||
span.item Wiki
|
||||
li
|
||||
li(data-name"video")
|
||||
a(href="", title="Video")
|
||||
span.icon.icon-video
|
||||
span.item Video
|
||||
|
|
Loading…
Reference in New Issue