Minor fixes in wiki page directives
parent
f3dd62bf90
commit
06b1b7550d
|
@ -178,9 +178,7 @@ module.directive("tgWikiSummary", ["$log", "$tgTemplate", WikiSummaryDirective])
|
||||||
## Editable Wiki Content Directive
|
## Editable Wiki Content Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $location, $navUrls,
|
EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $analytics, $qqueue) ->
|
||||||
$analytics, $qqueue) ->
|
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
return $scope.project.my_permissions.indexOf("modify_wiki_page") != -1
|
return $scope.project.my_permissions.indexOf("modify_wiki_page") != -1
|
||||||
|
@ -199,14 +197,11 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
|
||||||
$el.find(".edit-wiki-content").remove()
|
$el.find(".edit-wiki-content").remove()
|
||||||
|
|
||||||
cancelEdition = ->
|
cancelEdition = ->
|
||||||
return if !$scope.wiki.html
|
return if not $model.$modelValue.id
|
||||||
|
|
||||||
if $scope.wiki.id
|
$scope.$apply () =>
|
||||||
$scope.$apply () => $scope.wiki.revert()
|
$model.$modelValue.revert()
|
||||||
switchToReadMode()
|
switchToReadMode()
|
||||||
else
|
|
||||||
ctx = {project: $scope.projectSlug}
|
|
||||||
$location.path($navUrls.resolve("project-wiki", ctx))
|
|
||||||
|
|
||||||
getSelectedText = ->
|
getSelectedText = ->
|
||||||
if $window.getSelection
|
if $window.getSelection
|
||||||
|
@ -220,11 +215,11 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
|
||||||
if not wiki.id?
|
if not wiki.id?
|
||||||
$analytics.trackEvent("wikipage", "create", "create wiki page", 1)
|
$analytics.trackEvent("wikipage", "create", "create wiki page", 1)
|
||||||
|
|
||||||
$scope.wiki = wikiPage
|
$model.$modelValue = wikiPage
|
||||||
$model.setModelValue = wiki
|
$scope.$broadcast("wiki:edit", wikiPage)
|
||||||
|
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
switchToReadMode()
|
switchToReadMode()
|
||||||
$scope.$broadcast("wiki:edit", wikiPage)
|
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
@ -272,7 +267,6 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (wikiPage) ->
|
$scope.$watch $attrs.ngModel, (wikiPage) ->
|
||||||
return if not wikiPage
|
return if not wikiPage
|
||||||
$scope.wiki = wikiPage
|
|
||||||
|
|
||||||
if isEditable()
|
if isEditable()
|
||||||
$el.addClass('editable')
|
$el.addClass('editable')
|
||||||
|
@ -292,5 +286,4 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgEditableWikiContent", ["$window", "$document", "$tgRepo", "$tgConfirm", "$tgLoading",
|
module.directive("tgEditableWikiContent", ["$window", "$document", "$tgRepo", "$tgConfirm", "$tgLoading",
|
||||||
"$tgLocation", "$tgNavUrls", "$tgAnalytics", "$tgQqueue",
|
"$tgAnalytics", "$tgQqueue", EditableWikiContentDirective])
|
||||||
EditableWikiContentDirective])
|
|
||||||
|
|
Loading…
Reference in New Issue