Fixing redirection when creating project
parent
266d89a567
commit
e21e23e5e4
|
@ -420,3 +420,27 @@ AppTitle = () ->
|
|||
return {set: set}
|
||||
|
||||
module.factory("$appTitle", AppTitle)
|
||||
|
||||
#############################################################################
|
||||
## Get the appropiate section url for a project
|
||||
## according to his enabled features and user permisions
|
||||
#############################################################################
|
||||
|
||||
ProjectUrl = ($navurls) ->
|
||||
get = (project) ->
|
||||
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")
|
||||
|
||||
return $navurls.formatUrl(url, {'project': project.slug})
|
||||
|
||||
return {get: get}
|
||||
|
||||
module.factory("$projectUrl", ["$tgNavUrls", ProjectUrl])
|
||||
|
|
|
@ -29,9 +29,9 @@ module = angular.module("taigaNavMenu", [])
|
|||
## Projects Navigation
|
||||
#############################################################################
|
||||
class ProjectsNavigationController extends taiga.Controller
|
||||
@.$inject = ["$scope", "$rootScope", "$tgResources", "$tgNavUrls"]
|
||||
@.$inject = ["$scope", "$rootScope", "$tgResources", "$tgNavUrls", "$projectUrl"]
|
||||
|
||||
constructor: (@scope, @rootscope, @rs, @navurls) ->
|
||||
constructor: (@scope, @rootscope, @rs, @navurls, @projectUrl) ->
|
||||
promise = @.loadInitialData()
|
||||
promise.then null, ->
|
||||
console.log "FAIL"
|
||||
|
@ -48,18 +48,7 @@ class ProjectsNavigationController extends taiga.Controller
|
|||
loadInitialData: ->
|
||||
return @rs.projects.list().then (projects) =>
|
||||
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})
|
||||
project.url = @projectUrl.get(project)
|
||||
|
||||
@scope.projects = projects
|
||||
@scope.filteredProjects = projects
|
||||
|
|
|
@ -3,7 +3,7 @@ bindOnce = @.taiga.bindOnce
|
|||
|
||||
module = angular.module("taigaProject")
|
||||
|
||||
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, lightboxService) ->
|
||||
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, lightboxService) ->
|
||||
link = ($scope, $el, attrs) ->
|
||||
$scope.data = {}
|
||||
$scope.templates = []
|
||||
|
@ -11,13 +11,8 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, lightbox
|
|||
|
||||
onSuccessSubmit = (response) ->
|
||||
lightboxService.close($el)
|
||||
|
||||
$confirm.notify("success", "Success") #TODO: i18n
|
||||
|
||||
url = $navurls.resolve('project')
|
||||
fullUrl = $navurls.formatUrl(url, {'project': response.slug})
|
||||
|
||||
$location.url(fullUrl)
|
||||
$location.url($projectUrl.get(response))
|
||||
$rootscope.$broadcast("projects:reload")
|
||||
|
||||
onErrorSubmit = (response) ->
|
||||
|
@ -54,6 +49,7 @@ module.directive("tgLbCreateProject", [
|
|||
"$location",
|
||||
"$tgNavUrls",
|
||||
"$tgResources",
|
||||
"$projectUrl",
|
||||
"lightboxService",
|
||||
CreateProject
|
||||
])
|
||||
|
|
|
@ -3,9 +3,9 @@ module = angular.module("taigaProject")
|
|||
|
||||
|
||||
class ProjectsController extends taiga.Controller
|
||||
@.$inject = ["$scope", "$tgResources", "$rootScope", "$tgNavUrls", "$tgAuth", "$location", "$appTitle"]
|
||||
@.$inject = ["$scope", "$tgResources", "$rootScope", "$tgNavUrls", "$tgAuth", "$location", "$appTitle", "$projectUrl"]
|
||||
|
||||
constructor: (@scope, @rs, @rootscope, @navurls, $auth, $location, appTitle) ->
|
||||
constructor: (@scope, @rs, @rootscope, @navurls, $auth, $location, appTitle, @projectUrl) ->
|
||||
appTitle.set("Projects")
|
||||
|
||||
if !$auth.isAuthenticated()
|
||||
|
@ -19,18 +19,7 @@ class ProjectsController extends taiga.Controller
|
|||
return @rs.projects.list().then (projects) =>
|
||||
@.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})
|
||||
project.url = @projectUrl.get(project)
|
||||
|
||||
newProject: ->
|
||||
@rootscope.$broadcast("projects:create")
|
||||
|
|
Loading…
Reference in New Issue