[Backport] Fix mentions in coments

stable
David Barragán Merino 2016-10-03 12:52:01 +02:00
parent 7166320d9b
commit be89c3745f
1 changed files with 9 additions and 5 deletions

View File

@ -58,10 +58,14 @@ module = angular.module("taigaCommon")
############################################################################# #############################################################################
## WYSIWYG markitup editor directive ## WYSIWYG markitup editor directive
############################################################################# #############################################################################
MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $translate) -> MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $translate, projectService) ->
previewTemplate = $template.get("common/wysiwyg/wysiwyg-markitup-preview.html", true) previewTemplate = $template.get("common/wysiwyg/wysiwyg-markitup-preview.html", true)
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
if not $scope.project
# for backward compatibility
$scope.project = projectService.project.toJS()
element = angular.element($el) element = angular.element($el)
previewDomNode = $("<div/>", {class: "preview"}) previewDomNode = $("<div/>", {class: "preview"})
@ -83,7 +87,7 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
markdownDomNode = element.parents(".markdown") markdownDomNode = element.parents(".markdown")
markItUpDomNode = element.parents(".markItUp") markItUpDomNode = element.parents(".markItUp")
$rs.mdrender.render($scope.projectId || $scope.vm.projectId, $model.$modelValue).then (data) -> $rs.mdrender.render($scope.project.id, $model.$modelValue).then (data) ->
html = previewTemplate({data: data.data}) html = previewTemplate({data: data.data})
html = $compile(html)($scope) html = $compile(html)($scope)
@ -384,7 +388,7 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
return false return false
cancelablePromise.abort() if cancelablePromise cancelablePromise.abort() if cancelablePromise
cancelablePromise = $rs.search.do($scope.projectId || $scope.vm.projectId, term) cancelablePromise = $rs.search.do($scope.project.id, term)
cancelablePromise.then (res) => cancelablePromise.then (res) =>
# ignore wikipages if they're the only results. can't exclude them in search # ignore wikipages if they're the only results. can't exclude them in search
@ -440,7 +444,7 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
search: (term, callback) -> search: (term, callback) ->
term = taiga.slugify(term) term = taiga.slugify(term)
$rs.search.do($scope.projectId || $scope.vm.projectId, term).then (res) => $rs.search.do($scope.project.id, term).then (res) =>
if res.count < 1 if res.count < 1
callback([]) callback([])
@ -482,4 +486,4 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
return {link:link, require:"ngModel"} return {link:link, require:"ngModel"}
module.directive("tgMarkitup", ["$rootScope", "$tgResources", "$selectedText", "$tgTemplate", "$compile", module.directive("tgMarkitup", ["$rootScope", "$tgResources", "$selectedText", "$tgTemplate", "$compile",
"$translate", MarkitupDirective]) "$translate", "tgProjectService", MarkitupDirective])