Fix default homepage for public projects as guest
parent
f019be3d3b
commit
0bd3b38a26
|
@ -24,6 +24,9 @@
|
|||
|
||||
module = angular.module("taigaCommon")
|
||||
|
||||
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'}
|
||||
|
@ -33,24 +36,26 @@ SECTIONS = {
|
|||
6: {id: 6, title: 'WIKI', path:'wiki', enabled: 'is_wiki_activated'}
|
||||
}
|
||||
|
||||
class SectionsService extends taiga.Service
|
||||
@.$inject = ["$translate", "tgCurrentUserService"]
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue