diff --git a/docs-web-common/src/main/java/com/sismics/rest/util/AclUtil.java b/docs-web-common/src/main/java/com/sismics/rest/util/AclUtil.java index 5e4f5865..e9de8794 100644 --- a/docs-web-common/src/main/java/com/sismics/rest/util/AclUtil.java +++ b/docs-web-common/src/main/java/com/sismics/rest/util/AclUtil.java @@ -3,7 +3,6 @@ package com.sismics.rest.util; import com.sismics.docs.core.constant.PermType; import com.sismics.docs.core.dao.jpa.AclDao; import com.sismics.docs.core.dao.jpa.dto.AclDto; -import com.sismics.security.IPrincipal; import javax.json.Json; import javax.json.JsonArrayBuilder; diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index ceb61274..555e4dc5 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -82,14 +82,15 @@ public class DocumentResource extends BaseResource { .add("language", documentDto.getLanguage()) .add("shared", documentDto.getShared()) .add("file_count", documentDto.getFileCount()); - + + List tagDtoList = null; if (principal.isAnonymous()) { // No tags in anonymous mode (sharing) document.add("tags", Json.createArrayBuilder()); } else { - // Add tags added by the current user on this document + // Add tags visible by the current user on this document TagDao tagDao = new TagDao(); - List tagDtoList = tagDao.findByCriteria( + tagDtoList = tagDao.findByCriteria( new TagCriteria() .setTargetIdList(getTargetIdList(shareId)) .setDocumentId(documentId), @@ -117,6 +118,25 @@ public class DocumentResource extends BaseResource { // Add ACL AclUtil.addAcls(document, documentId, getTargetIdList(shareId)); + + // Add computed ACL + if (tagDtoList != null) { + JsonArrayBuilder aclList = Json.createArrayBuilder(); + for (TagDto tagDto : tagDtoList) { + AclDao aclDao = new AclDao(); + List aclDtoList = aclDao.getBySourceId(tagDto.getId()); + for (AclDto aclDto : aclDtoList) { + aclList.add(Json.createObjectBuilder() + .add("perm", aclDto.getPerm().name()) + .add("source_id", tagDto.getId()) + .add("source_name", tagDto.getName()) + .add("id", aclDto.getTargetId()) + .add("name", JsonUtil.nullable(aclDto.getTargetName())) + .add("type", aclDto.getTargetType())); + } + } + document.add("inherited_acls", aclList); + } // Add contributors ContributorDao contributorDao = new ContributorDao(); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewPermissions.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewPermissions.js index bfbc5493..cb953fcf 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewPermissions.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewPermissions.js @@ -3,5 +3,11 @@ /** * Document view permissions controller. */ -angular.module('docs').controller('DocumentViewPermissions', function() { +angular.module('docs').controller('DocumentViewPermissions', function($scope) { + // Watch for ACLs change and group them for easy displaying + $scope.$watch('document.inherited_acls', function(acls) { + $scope.inheritedAcls = _.groupBy(acls, function(acl) { + return acl.id; + }); + }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/directive.acledit.html b/docs-web/src/main/webapp/src/partial/docs/directive.acledit.html index 7e436e50..9cf0c792 100644 --- a/docs-web/src/main/webapp/src/partial/docs/directive.acledit.html +++ b/docs-web/src/main/webapp/src/partial/docs/directive.acledit.html @@ -8,12 +8,12 @@ - - {{ a.perm }} - - + + {{ a.perm }} + + diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.activity.html b/docs-web/src/main/webapp/src/partial/docs/document.view.activity.html index 6726c5ed..ff100f5e 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.activity.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.activity.html @@ -1 +1,3 @@ +

Every actions on this document are logged here.

+ \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.permissions.html b/docs-web/src/main/webapp/src/partial/docs/document.view.permissions.html index 0c611570..7c4401f5 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.permissions.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.permissions.html @@ -1,4 +1,37 @@ - \ No newline at end of file +

Permissions can be applied directly to this document, or can come from tags.

+ +
+

Permissions inherited by tags

+ + + + + + + + + + + + + +
FromForPermission
+ +   + {{ acl[0].source_name }} + + + + {{ a.perm }} + +
+
+ +
+

Permissions on this document

+ + +
\ 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 90f56a22..98332e9a 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,3 +1,7 @@ +

{{ tag.name }}

+ +

Permissions on this tag will also be applied to documents tagged {{ tag.name }}

+