From fc5a1f2e7126a63f7db8b554e264728b631a6672 Mon Sep 17 00:00:00 2001 From: jendib Date: Wed, 31 Jul 2013 22:07:42 +0200 Subject: [PATCH] Confirmation on tag deletion --- docs-web/src/main/webapp/js/controller/Tag.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docs-web/src/main/webapp/js/controller/Tag.js b/docs-web/src/main/webapp/js/controller/Tag.js index 337a32a3..fd67a636 100644 --- a/docs-web/src/main/webapp/js/controller/Tag.js +++ b/docs-web/src/main/webapp/js/controller/Tag.js @@ -3,7 +3,7 @@ /** * Tag controller. */ -App.controller('Tag', function($scope, $state, Tag, Restangular) { +App.controller('Tag', function($scope, $dialog, $state, Tag, Restangular) { // Retrieve tags Tag.tags().then(function(data) { $scope.tags = data.tags; @@ -24,10 +24,20 @@ App.controller('Tag', function($scope, $state, Tag, Restangular) { * Delete a tag. */ $scope.deleteTag = function(tag) { - Restangular.one('tag', tag.id).remove().then(function() { - $scope.tags = _.reject($scope.tags, function(t) { - return tag.id == t.id; - }); + var title = 'Delete tag'; + var msg = 'Do you really want to delete this tag?'; + var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}]; + + $dialog.messageBox(title, msg, btns) + .open() + .then(function(result) { + if (result == 'ok') { + Restangular.one('tag', tag.id).remove().then(function() { + $scope.tags = _.reject($scope.tags, function(t) { + return tag.id == t.id; + }); + }); + } }); };