From 6870b9a057b1840c4c6b119978c6a00380019d30 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 27 Nov 2014 16:43:15 +0100 Subject: [PATCH] fix #1706 preserve navigation active in US and tasks --- app/coffee/modules/nav.coffee | 18 +++++++++++++++++- app/partials/task-detail.jade | 2 +- app/partials/us-detail.jade | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/coffee/modules/nav.coffee b/app/coffee/modules/nav.coffee index adc7e401..7da65d7e 100644 --- a/app/coffee/modules/nav.coffee +++ b/app/coffee/modules/nav.coffee @@ -311,6 +311,22 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $ """) + # If the last page was kanban or backlog and + # the new one is the task detail or the us details + # this method preserve the last section name. + getSectionName = ($el, sectionName, project) -> + oldSectionName = $el.find("a.active").parent().attr("id")?.replace("nav-", "") + + if sectionName == "backlog-kanban" + if oldSectionName in ["backlog", "kanban"] + sectionName = oldSectionName + else if project.is_backlog_activated && !project.is_kanban_activated + sectionName = "backlog" + else if !project.is_backlog_activated && project.is_kanban_activated + sectionName = "kanban" + + return sectionName + renderMainMenu = ($el) -> html = mainTemplate({}) $el.html(html) @@ -320,7 +336,7 @@ ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $ # content loaded signal is raised using inner scope. renderMenuEntries = ($el, targetScope, project={}) -> container = $el.find(".menu-container") - sectionName = targetScope.section + sectionName = getSectionName($el, targetScope.section, project) ctx = { user: $auth.getUser(), diff --git a/app/partials/task-detail.jade b/app/partials/task-detail.jade index c9d4e80e..25cf5c73 100644 --- a/app/partials/task-detail.jade +++ b/app/partials/task-detail.jade @@ -5,7 +5,7 @@ block head block content div.wrapper(ng-controller="TaskDetailController as ctrl", - ng-init="section='backlog'") + ng-init="section='backlog-kanban'") div.main.us-detail div.us-detail-header.header-with-actions include views/components/mainTitle diff --git a/app/partials/us-detail.jade b/app/partials/us-detail.jade index 2bb65166..6685ae9a 100644 --- a/app/partials/us-detail.jade +++ b/app/partials/us-detail.jade @@ -5,7 +5,7 @@ block head block content div.wrapper(ng-controller="UserStoryDetailController as ctrl", - ng-init="section='backlog'") + ng-init="section='backlog-kanban'") div.main.us-detail div.us-detail-header.header-with-actions include views/components/mainTitle