diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java index 9448f8cf..9e8f5871 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java @@ -97,6 +97,14 @@ public class TagResource extends BaseResource { .add("name", tagDto.getName()) .add("color", tagDto.getColor()); + // Add the parent if its visible + if (tagDto.getParentId() != null) { + AclDao aclDao = new AclDao(); + if (aclDao.checkPermission(tagDto.getParentId(), PermType.READ, getTargetIdList(null))) { + tag.add("parent", tagDto.getParentId()); + } + } + // Add ACL AclUtil.addAcls(tag, id, getTargetIdList(null)); 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 acf3b5b5..c92f0e1b 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,20 @@ /** * Tag controller. */ -angular.module('docs').controller('Tag', function($scope, $dialog, Restangular) { +angular.module('docs').controller('Tag', function($scope, $dialog, Restangular, $state) { $scope.tag = { name: '', color: '#3a87ad' }; // Retrieve tags Restangular.one('tag/list').get().then(function(data) { $scope.tags = data.tags; }); + + /** + * Display a tag. + */ + $scope.viewTag = function(id) { + $state.go('tag.edit', { id: id }); + }; /** * Add a tag. @@ -42,12 +49,4 @@ angular.module('docs').controller('Tag', function($scope, $dialog, Restangular) } }); }; - - /** - * Update a tag. - */ - $scope.updateTag = function(tag) { - // Update the server - return Restangular.one('tag', tag.id).post('', tag); - }; }); \ 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 1910309d..591de7b6 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 @@ -4,7 +4,23 @@ * Tag edit controller. */ angular.module('docs').controller('TagEdit', function($scope, $stateParams, Restangular) { + // Retrieve the tag Restangular.one('tag', $stateParams.id).get().then(function(data) { $scope.tag = data; - }) + + // Replace the tag from the list with this reference + _.each($scope.tags, function(tag, i) { + if (tag.id == $scope.tag.id) { + $scope.tags[i] = $scope.tag; + } + }); + }); + + /** + * Update a tag. + */ + $scope.edit = function() { + // Update the server + Restangular.one('tag', $scope.tag.id).post('', $scope.tag); + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/directive/InlineEdit.js b/docs-web/src/main/webapp/src/app/docs/directive/InlineEdit.js deleted file mode 100644 index 02ea72c8..00000000 --- a/docs-web/src/main/webapp/src/app/docs/directive/InlineEdit.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -/** - * Inline edition directive. - * Thanks to http://jsfiddle.net/joshdmiller/NDFHg/ - */ -angular.module('docs').directive('inlineEdit', function() { - return { - restrict: 'E', - scope: { - value: '=', - editCallback: '&onEdit' - }, - template: '', - link: function (scope, element, attrs) { - // Let's get a reference to the input element, as we'll want to reference it. - var inputElement = angular.element(element.children()[1]); - var el = inputElement[0]; - - // This directive should have a set class so we can style it. - element.addClass('inline-edit'); - - // Initially, we're not editing. - scope.editing = false; - - // ng-click handler to activate edit-in-place - scope.edit = function () { - scope.editing = true; - scope.oldValue = el.value; - - // We control display through a class on the directive itself. See the CSS. - element.addClass('active'); - - // And we must focus the element. - // `angular.element()` provides a chainable array, like jQuery so to access a native DOM function, - // we have to reference the first element in the array. - el.focus(); - el.selectionStart = 0; - el.selectionEnd = el.value.length; - }; - - // When we leave the input, we're done editing. - inputElement.on('blur', function() { - scope.editing = false; - element.removeClass('active'); - - // Invoke parent scope callback - if (scope.editCallback && scope.oldValue != el.value) { - scope.$apply(function() { - if (scope.value) { - scope.editCallback().then(null, function() { - scope.value = scope.oldValue; - }); - } else { - scope.value = scope.oldValue; - } - }); - } - }); - } - }; -}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index c7760315..a5a6d8ce 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -81,7 +81,6 @@ - diff --git a/docs-web/src/main/webapp/src/partial/docs/tag.default.html b/docs-web/src/main/webapp/src/partial/docs/tag.default.html index dee44dec..f9af3e0f 100644 --- a/docs-web/src/main/webapp/src/partial/docs/tag.default.html +++ b/docs-web/src/main/webapp/src/partial/docs/tag.default.html @@ -1,6 +1,6 @@
Tags are labels associated to documents.
A document can be tagged by multiple tags, and a tag can be applied to multiple documents.
-Using the button, you can edit permissions on a tag.
+Using the button, you can edit permissions on a tag.
If a tag can be read by another user or group, associated documents can also be read by those people.
For example, tag your company documents with a tag MyCompany and add the permission Read to a group employees
\ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/tag.edit.html b/docs-web/src/main/webapp/src/partial/docs/tag.edit.html index 10e48dbe..843a80a1 100644 --- a/docs-web/src/main/webapp/src/partial/docs/tag.edit.html +++ b/docs-web/src/main/webapp/src/partial/docs/tag.edit.html @@ -1,8 +1,54 @@ -Permissions on this tag will also be applied to documents tagged {{ tag.name }}
+Permissions on this tag will also be applied to documents tagged {{ tag.name }}
+ +- + | |||||
+ + {{ tag.name }} + | ++ + + + | ++ | -- | - |