Fix default homepage for public projects as guest

stable
Daniel García 2018-11-26 18:41:20 +01:00 committed by Alex Hermida
parent f019be3d3b
commit 0bd3b38a26
1 changed files with 17 additions and 12 deletions

View File

@ -24,33 +24,38 @@
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
@.$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) ->
super()
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
list: () ->
return SECTIONS
getPath: (projectSlug, sectionId) ->
projects = @currentUserService.projects.get("all")
defaultHomePage = "timeline"
projects = @currentUserService.projects?.get("all")
project = projects.find (p) -> return p.get('slug') == projectSlug
if not project
return defaultHomePage
if not sectionId
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
return "timeline"
return defaultHomePage
return section.path