[backport] hide wiki links when the wiki doesn't have links

stable
Juanfran 2016-01-12 09:50:03 +01:00
parent d53675c9d4
commit ca0e5936ce
2 changed files with 12 additions and 6 deletions

View File

@ -57,6 +57,7 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
@scope.wikiSlug = @params.slug @scope.wikiSlug = @params.slug
@scope.wikiTitle = @scope.wikiSlug @scope.wikiTitle = @scope.wikiSlug
@scope.sectionName = "Wiki" @scope.sectionName = "Wiki"
@scope.linksVisible = false
promise = @.loadInitialData() promise = @.loadInitialData()
@ -72,10 +73,11 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
projectName: @scope.project.name projectName: @scope.project.name
}) })
description = @translate.instant("WIKI.PAGE_DESCRIPTION", { description = @translate.instant("WIKI.PAGE_DESCRIPTION", {
wikiPageContent: angular.element(@scope.wiki.html or "").text() wikiPageContent: angular.element(@scope.wiki?.html or "").text()
totalEditions: @scope.wiki.editions or 0 totalEditions: @scope.wiki?.editions or 0
lastModifiedDate: moment(@scope.wiki.modified_date).format(@translate.instant("WIKI.DATETIME")) lastModifiedDate: moment(@scope.wiki?.modified_date).format(@translate.instant("WIKI.DATETIME"))
}) })
@appMetaService.setAll(title, description) @appMetaService.setAll(title, description)
loadProject: -> loadProject: ->
@ -119,8 +121,12 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
promise = @.loadProject() promise = @.loadProject()
return promise.then (project) => return promise.then (project) =>
@.fillUsersAndRoles(project.members, project.roles) @.fillUsersAndRoles(project.members, project.roles)
@q.all([@.loadWikiLinks(), @.loadWiki()]).then () => @q.all([@.loadWikiLinks(), @.loadWiki()]).then @.checkLinksPerms.bind(this)
checkLinksPerms: ->
if @scope.project.my_permissions.indexOf("modify_wiki_link") != -1 ||
(@scope.project.my_permissions.indexOf("view_wiki_links") != -1 && @scope.wikiLinks.length)
@scope.linksVisible = true
delete: -> delete: ->
title = @translate.instant("WIKI.DELETE_LIGHTBOX_TITLE") title = @translate.instant("WIKI.DELETE_LIGHTBOX_TITLE")

View File

@ -3,7 +3,7 @@ doctype html
div.wrapper(ng-controller="WikiDetailController as ctrl", div.wrapper(ng-controller="WikiDetailController as ctrl",
ng-init="section='wiki'") ng-init="section='wiki'")
tg-project-menu tg-project-menu
sidebar.menu-secondary.extrabar(tg-check-permission="view_wiki_links") sidebar.menu-secondary.extrabar(ng-if="linksVisible")
section.wiki-nav(tg-wiki-nav, ng-model="wikiLinks") section.wiki-nav(tg-wiki-nav, ng-model="wikiLinks")
section.main.wiki section.main.wiki
header header