diff --git a/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js b/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js index c92f0e1b..33572c9f 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js @@ -3,13 +3,16 @@ /** * Tag controller. */ -angular.module('docs').controller('Tag', function($scope, $dialog, Restangular, $state) { +angular.module('docs').controller('Tag', function($scope, Restangular, $state) { $scope.tag = { name: '', color: '#3a87ad' }; // Retrieve tags - Restangular.one('tag/list').get().then(function(data) { - $scope.tags = data.tags; - }); + $scope.loadTags = function() { + Restangular.one('tag/list').get().then(function(data) { + $scope.tags = data.tags; + }); + }; + $scope.loadTags(); /** * Display a tag. @@ -27,26 +30,4 @@ angular.module('docs').controller('Tag', function($scope, $dialog, Restangular, $scope.tag = { name: '', color: '#3a87ad' }; }); }; - - /** - * Delete a tag. - */ - $scope.deleteTag = function(tag) { - 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, 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; - }); - }); - } - }); - }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js index 591de7b6..e77599da 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js @@ -3,7 +3,7 @@ /** * Tag edit controller. */ -angular.module('docs').controller('TagEdit', function($scope, $stateParams, Restangular) { +angular.module('docs').controller('TagEdit', function($scope, $stateParams, Restangular, $dialog, $state) { // Retrieve the tag Restangular.one('tag', $stateParams.id).get().then(function(data) { $scope.tag = data; @@ -23,4 +23,25 @@ angular.module('docs').controller('TagEdit', function($scope, $stateParams, Rest // Update the server Restangular.one('tag', $scope.tag.id).post('', $scope.tag); }; + + /** + * Delete a tag. + */ + $scope.deleteTag = function(tag) { + 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, function(result) { + if (result == 'ok') { + Restangular.one('tag', tag.id).remove().then(function() { + $scope.loadTags(); + $state.go('tag.default'); + }); + } + }); + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.html b/docs-web/src/main/webapp/src/partial/docs/document.view.html index 664eabd2..a6a7fb94 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.html @@ -12,7 +12,7 @@