Fix default homepage for public projects as guest
parent
f019be3d3b
commit
0bd3b38a26
|
@ -24,33 +24,38 @@
|
||||||
|
|
||||||
module = angular.module("taigaCommon")
|
module = angular.module("taigaCommon")
|
||||||
|
|
||||||
SECTIONS = {
|
|
||||||
1: {id: 1, title: 'TIMELINE', path:'timeline', enabled: ''}
|
|
||||||
2: {id: 2, title: 'EPICS', path:'epics', enabled: 'is_epics_activated'}
|
|
||||||
3: {id: 3, title: 'BACKLOG', path:'backlog', enabled: 'is_backlog_activated'}
|
|
||||||
4: {id: 4, title: 'KANBAN', path:'kanban', enabled: 'is_kanban_activated'}
|
|
||||||
5: {id: 5, title: 'ISSUES', path:'issues', enabled: 'is_issues_activated'}
|
|
||||||
6: {id: 6, title: 'WIKI', path:'wiki', enabled: 'is_wiki_activated'}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SectionsService extends taiga.Service
|
class SectionsService extends taiga.Service
|
||||||
@.$inject = ["$translate", "tgCurrentUserService"]
|
@.$inject = ["$translate", "tgCurrentUserService"]
|
||||||
|
|
||||||
|
SECTIONS = {
|
||||||
|
1: {id: 1, title: 'TIMELINE', path:'timeline', enabled: ''}
|
||||||
|
2: {id: 2, title: 'EPICS', path:'epics', enabled: 'is_epics_activated'}
|
||||||
|
3: {id: 3, title: 'BACKLOG', path:'backlog', enabled: 'is_backlog_activated'}
|
||||||
|
4: {id: 4, title: 'KANBAN', path:'kanban', enabled: 'is_kanban_activated'}
|
||||||
|
5: {id: 5, title: 'ISSUES', path:'issues', enabled: 'is_issues_activated'}
|
||||||
|
6: {id: 6, title: 'WIKI', path:'wiki', enabled: 'is_wiki_activated'}
|
||||||
|
}
|
||||||
|
|
||||||
constructor: (@translate, @currentUserService) ->
|
constructor: (@translate, @currentUserService) ->
|
||||||
super()
|
super()
|
||||||
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
|
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
|
||||||
list: () ->
|
list: () ->
|
||||||
return SECTIONS
|
return SECTIONS
|
||||||
getPath: (projectSlug, sectionId) ->
|
getPath: (projectSlug, sectionId) ->
|
||||||
projects = @currentUserService.projects.get("all")
|
defaultHomePage = "timeline"
|
||||||
|
|
||||||
|
projects = @currentUserService.projects?.get("all")
|
||||||
project = projects.find (p) -> return p.get('slug') == projectSlug
|
project = projects.find (p) -> return p.get('slug') == projectSlug
|
||||||
|
|
||||||
|
if not project
|
||||||
|
return defaultHomePage
|
||||||
|
|
||||||
if not sectionId
|
if not sectionId
|
||||||
sectionId = project.get('my_homepage')
|
sectionId = project.get('my_homepage')
|
||||||
section = _.find(SECTIONS, {"id": sectionId})
|
|
||||||
|
|
||||||
|
section = _.find(SECTIONS, {"id": sectionId})
|
||||||
if !section or project?.get(section.enabled) is not true
|
if !section or project?.get(section.enabled) is not true
|
||||||
return "timeline"
|
return defaultHomePage
|
||||||
|
|
||||||
return section.path
|
return section.path
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue