From ca0e5936ce0ddbd981a61d3cb76cb018ced2e6e9 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Tue, 12 Jan 2016 09:50:03 +0100 Subject: [PATCH] [backport] hide wiki links when the wiki doesn't have links --- app/coffee/modules/wiki/main.coffee | 14 ++++++++++---- app/partials/wiki/wiki.jade | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee index 434d9ea2..86d4901c 100644 --- a/app/coffee/modules/wiki/main.coffee +++ b/app/coffee/modules/wiki/main.coffee @@ -57,6 +57,7 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.wikiSlug = @params.slug @scope.wikiTitle = @scope.wikiSlug @scope.sectionName = "Wiki" + @scope.linksVisible = false promise = @.loadInitialData() @@ -72,10 +73,11 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin) projectName: @scope.project.name }) description = @translate.instant("WIKI.PAGE_DESCRIPTION", { - wikiPageContent: angular.element(@scope.wiki.html or "").text() - totalEditions: @scope.wiki.editions or 0 - lastModifiedDate: moment(@scope.wiki.modified_date).format(@translate.instant("WIKI.DATETIME")) + wikiPageContent: angular.element(@scope.wiki?.html or "").text() + totalEditions: @scope.wiki?.editions or 0 + lastModifiedDate: moment(@scope.wiki?.modified_date).format(@translate.instant("WIKI.DATETIME")) }) + @appMetaService.setAll(title, description) loadProject: -> @@ -119,8 +121,12 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin) promise = @.loadProject() return promise.then (project) => @.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: -> title = @translate.instant("WIKI.DELETE_LIGHTBOX_TITLE") diff --git a/app/partials/wiki/wiki.jade b/app/partials/wiki/wiki.jade index ec699d01..cadf21d9 100644 --- a/app/partials/wiki/wiki.jade +++ b/app/partials/wiki/wiki.jade @@ -3,14 +3,14 @@ doctype html div.wrapper(ng-controller="WikiDetailController as ctrl", ng-init="section='wiki'") 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.main.wiki header h1 span(tg-bo-bind="project.name") span.green(translate="PROJECT.SECTION.WIKI") - + div.summary.wiki-summary(tg-wiki-summary, ng-model="wiki", ng-if="wiki.id") h2.wiki-title(ng-bind='wikiTitle')