From 79141edf7044eaddf33d1251543b263aebd67d9b Mon Sep 17 00:00:00 2001 From: jendib Date: Mon, 9 May 2016 22:09:29 +0200 Subject: [PATCH] Closes #97: Handle write permission in #/tag and #/tag/id --- .../webapp/src/app/docs/controller/tag/Tag.js | 33 ++++--------------- .../src/app/docs/controller/tag/TagEdit.js | 23 ++++++++++++- .../src/partial/docs/document.view.html | 2 +- .../webapp/src/partial/docs/tag.edit.html | 10 ++++-- .../src/main/webapp/src/partial/docs/tag.html | 5 --- 5 files changed, 38 insertions(+), 35 deletions(-) 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 @@
-
+
-
+ + +
diff --git a/docs-web/src/main/webapp/src/partial/docs/tag.html b/docs-web/src/main/webapp/src/partial/docs/tag.html index 280daed3..8a915b26 100644 --- a/docs-web/src/main/webapp/src/partial/docs/tag.html +++ b/docs-web/src/main/webapp/src/partial/docs/tag.html @@ -29,11 +29,6 @@ - - -