Calculating the correct section for redirecting the user from the project list

stable
Alejandro Alonso 2014-08-11 10:26:29 +02:00
parent 451125de35
commit c2b5bf01b7
2 changed files with 17 additions and 4 deletions

View File

@ -12,9 +12,9 @@ class ProjectNavController extends taiga.Controller
module.controller("ProjectNavController", ProjectNavController) module.controller("ProjectNavController", ProjectNavController)
class ProjectsController extends taiga.Controller class ProjectsController extends taiga.Controller
@.$inject = ["$scope", "$tgResources", "$rootScope"] @.$inject = ["$scope", "$tgResources", "$rootScope", "$tgNavUrls"]
constructor: (@scope, @rs, @rootscope) -> constructor: (@scope, @rs, @rootscope, @navurls) ->
@scope.hideMenu = true @scope.hideMenu = true
@.projects = [] @.projects = []
@.loadInitialData() @.loadInitialData()
@ -22,6 +22,19 @@ class ProjectsController extends taiga.Controller
loadInitialData: -> loadInitialData: ->
return @rs.projects.list().then (projects) => return @rs.projects.list().then (projects) =>
@.projects = {'recents': projects.slice(0, 8), 'all': projects.slice(8)} @.projects = {'recents': projects.slice(0, 8), 'all': projects.slice(8)}
for project in projects
if project.is_backlog_activated and project.my_permissions.indexOf("view_us")>-1
url = @navurls.resolve("project-backlog")
else if project.is_kanban_activated and project.my_permissions.indexOf("view_us")>-1
url = @navurls.resolve("project-kanban")
else if project.is_wiki_activated and project.my_permissions.indexOf("view_wiki_pages")>-1
url = @navurls.resolve("project-wiki")
else if project.is_issues_activated and project.my_permissions.indexOf("view_issues")>-1
url = @navurls.resolve("project-issues")
else
url = @navurls.resolve("project")
project.url = @navurls.formatUrl(url, {'project': project.slug})
newProject: -> newProject: ->
@rootscope.$broadcast("projects:create") @rootscope.$broadcast("projects:create")

View File

@ -12,7 +12,7 @@ block content
h2(tg-bo-bind="project.name") h2(tg-bo-bind="project.name")
p(tg-bo-bind="project.description") p(tg-bo-bind="project.description")
.project-link .project-link
a.button.button-gray(href="", tg-nav="project:project=project.slug") Go to project a.button.button-gray(ng-href="{{project.url}}") Go to project
div.all-projects div.all-projects
h1 Projects h1 Projects