Adding delete confirmation on wiki and wiki links

stable
Jesús Espino 2014-07-30 09:22:04 +02:00
parent 2f3278652b
commit 0369a35228
2 changed files with 19 additions and 4 deletions

View File

@ -24,6 +24,7 @@ taiga = @.taiga
mixOf = @.taiga.mixOf mixOf = @.taiga.mixOf
groupBy = @.taiga.groupBy groupBy = @.taiga.groupBy
bindOnce = @.taiga.bindOnce bindOnce = @.taiga.bindOnce
unslugify = @.taiga.unslugify
module = angular.module("taigaWiki") module = angular.module("taigaWiki")
@ -99,7 +100,14 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
@location.path("/project/#{@scope.projectSlug}/wiki") @location.path("/project/#{@scope.projectSlug}/wiki")
onError = => onError = =>
@confirm.notify("error") @confirm.notify("error")
@repo.remove(@scope.wiki).then onSuccess, onError
# TODO: i18n
title = "Delete Wiki Page"
subtitle = unslugify(@scope.wiki.slug)
@confirm.ask(title, subtitle).then =>
@repo.remove(@scope.wiki).then onSuccess, onError
module.controller("WikiDetailController", WikiDetailController) module.controller("WikiDetailController", WikiDetailController)

View File

@ -25,6 +25,7 @@ mixOf = @.taiga.mixOf
groupBy = @.taiga.groupBy groupBy = @.taiga.groupBy
bindOnce = @.taiga.bindOnce bindOnce = @.taiga.bindOnce
slugify = @.taiga.slugify slugify = @.taiga.slugify
unslugify = @.taiga.slugify
module = angular.module("taigaWiki") module = angular.module("taigaWiki")
@ -86,9 +87,15 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm) ->
event.stopPropagation() event.stopPropagation()
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
linkId = target.parents('.wiki-link').data('id') linkId = target.parents('.wiki-link').data('id')
$tgrepo.remove($scope.wikiLinks[linkId]).then ->
$ctrl.loadWikiLinks().then -> # TODO: i18n
render($scope.wikiLinks) title = "Delete Wiki Link"
subtitle = $scope.wikiLinks[linkId].title
$confirm.ask(title, subtitle).then =>
$tgrepo.remove($scope.wikiLinks[linkId]).then ->
$ctrl.loadWikiLinks().then ->
render($scope.wikiLinks)
$el.on "keyup", ".new input", (event) -> $el.on "keyup", ".new input", (event) ->
event.preventDefault() event.preventDefault()