From 0d5976f7c02fddc7dfd0cb3176edb064afa4e7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Tue, 12 Apr 2016 19:47:44 +0200 Subject: [PATCH] Fix issue #4070: Can't open wiki links in new window --- app/coffee/modules/wiki/main.coffee | 7 +++++++ app/coffee/modules/wiki/nav.coffee | 19 ++++--------------- app/partials/wiki/wiki-nav.jade | 7 ++++++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee index 88dd33e1..a34db70e 100644 --- a/app/coffee/modules/wiki/main.coffee +++ b/app/coffee/modules/wiki/main.coffee @@ -117,6 +117,13 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin) loadWikiLinks: -> return @rs.wiki.listLinks(@scope.projectId).then (wikiLinks) => @scope.wikiLinks = wikiLinks + + for link in @scope.wikiLinks + link.url = @navUrls.resolve("project-wiki-page", { + project: @scope.projectSlug + slug: link.href + }) + selectedWikiLink = _.find(wikiLinks, {href: @scope.wikiSlug}) @scope.wikiTitle = selectedWikiLink.title if selectedWikiLink? diff --git a/app/coffee/modules/wiki/nav.coffee b/app/coffee/modules/wiki/nav.coffee index 6bf17e14..31ecf4ab 100644 --- a/app/coffee/modules/wiki/nav.coffee +++ b/app/coffee/modules/wiki/nav.coffee @@ -35,7 +35,8 @@ module = angular.module("taigaWiki") ## Wiki Main Directive ############################################################################# -WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $loading, $template, $compile, $translate) -> +WikiNavDirective = ($tgrepo, $log, $location, $confirm, $analytics, $loading, $template, + $compile, $translate) -> template = $template.get("wiki/wiki-nav.html", true) link = ($scope, $el, $attrs) -> $ctrl = $el.controller() @@ -59,18 +60,6 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $l $el.off() $el.html(html) - $el.on "click", ".wiki-link .link-title", (event) -> - event.preventDefault() - target = angular.element(event.currentTarget) - linkId = target.parents('.wiki-link').data('id') - linkSlug = $scope.wikiLinks[linkId].href - $scope.$apply -> - ctx = { - project: $scope.projectSlug - slug: linkSlug - } - $location.path($navUrls.resolve("project-wiki-page", ctx)) - $el.on "click", ".add-button", (event) -> event.preventDefault() $el.find(".new").removeClass("hidden") @@ -146,5 +135,5 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $l return {link:link} -module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", - "$tgAnalytics", "$tgLoading", "$tgTemplate", "$compile", "$translate", WikiNavDirective]) +module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgAnalytics", + "$tgLoading", "$tgTemplate", "$compile", "$translate", WikiNavDirective]) diff --git a/app/partials/wiki/wiki-nav.jade b/app/partials/wiki/wiki-nav.jade index 6d5c6f34..1971a536 100644 --- a/app/partials/wiki/wiki-nav.jade +++ b/app/partials/wiki/wiki-nav.jade @@ -5,22 +5,27 @@ nav ul <% _.each(wikiLinks, function(link, index) { %> li.wiki-link(data-id!="<%- index %>") - a.link-title(title!="<%- link.title %>") <%- link.title %> + a.link-title(title!="<%- link.title %>", href!="<%- link.url %>") + <%- link.title %> + <% if (deleteWikiLinkPermission) { %> a.js-delete-link.remove-wiki-page(title!="{{'WIKI.DELETE_LINK_TITLE' | translate}}") tg-svg(svg-icon="icon-trash") <% } %> + input.hidden( type="text" placeholder="{{'COMMON.FIELDS.NAME' | translate}}" value!="<%- link.title %>" ) <% }) %> + li.new.hidden input( type="text" placeholder="{{'COMMON.FIELDS.NAME' | translate}}" ) + <% if (addWikiLinkPermission) { %> a( href=""