diff --git a/src/frontend/app/folder/folder-tree.component.html b/src/frontend/app/folder/folder-tree.component.html index f3333c08bf63e25fcdc68ff4ffa60c28336b7938..7a72dfa31cf31fd17e3aa7a724c78fb6ca41da5e 100644 --- a/src/frontend/app/folder/folder-tree.component.html +++ b/src/frontend/app/folder/folder-tree.component.html @@ -21,7 +21,7 @@ </span> </button> <mat-menu #menu="matMenu"> - <button mat-menu-item [disabled]="createItemNode" (click)="addNewItem(node)">{{lang.addSubFolder}}</button> + <button mat-menu-item [disabled]="createItemNode || !node.canAdd" (click)="addNewItem(node)">{{lang.addSubFolder}}</button> <button mat-menu-item (click)="deleteNode(node)" [disabled]="!node.edition">{{lang.delete}}</button> <button mat-menu-item (click)="openFolderAdmin(node)" [disabled]="!node.edition">{{lang.update}}</button> </mat-menu> @@ -60,7 +60,7 @@ </span> </button> <mat-menu #menu="matMenu"> - <button mat-menu-item [disabled]="createItemNode" (click)="addNewItem(node)">{{lang.addSubFolder}}</button> + <button mat-menu-item [disabled]="createItemNode || !node.canAdd" (click)="addNewItem(node)">{{lang.addSubFolder}}</button> <button mat-menu-item (click)="deleteNode(node)" [disabled]="!node.edition">{{lang.delete}}</button> <button mat-menu-item (click)="openFolderAdmin(node)" [disabled]="!node.edition">{{lang.update}}</button> </mat-menu> @@ -74,7 +74,7 @@ </mat-list-item> </mat-nav-list> <mat-list *ngIf="createRootNode"> - <mat-list-item role="listitem"> + <mat-list-item role="listitem" class="rootFolder"> <form> <mat-form-field floatLabel="never" style="width: 100%;"> <input matInput id="itemValue" #itemValue placeholder="{{lang.addRootFolder}}"> diff --git a/src/frontend/app/folder/folder-tree.component.scss b/src/frontend/app/folder/folder-tree.component.scss index 378c4d4e45bc72ed3832f81d8fbdc7d32c9e58c3..61ee7cf2e65d47fe169d1671f80156bf7f96618f 100644 --- a/src/frontend/app/folder/folder-tree.component.scss +++ b/src/frontend/app/folder/folder-tree.component.scss @@ -81,12 +81,17 @@ form { .more { width: 100%; - + opacity: 0.6; ::ng-deep.mat-list-item-content { justify-content: center; } } +.rootFolder { + width: 100%; +} + + .private { margin-left: 5px; color: $secondary; diff --git a/src/frontend/app/folder/folder-tree.component.ts b/src/frontend/app/folder/folder-tree.component.ts index f8fa4b98aa87952b960c1edecf4ad49c01d0702e..7c21f89193f25032ce8ee21d0d4abc4fee9bebc4 100644 --- a/src/frontend/app/folder/folder-tree.component.ts +++ b/src/frontend/app/folder/folder-tree.component.ts @@ -243,7 +243,7 @@ export class FolderTreeComponent implements OnInit { if (currentNode.children === undefined) { currentNode['children'] = []; } - currentNode.children.push({ label: '', parent_id: currentNode.id } as ItemNode); + currentNode.children.push({ label: '', parent_id: currentNode.id, public : currentNode.public } as ItemNode); this.dataChange.next(this.data); this.treeControl.expand(node); @@ -425,6 +425,8 @@ export class FolderTreeComponent implements OnInit { exhaustMap(() => this.http.get("../../rest/folders/" + node.id)), tap((data: any) => { let canAdmin = false; + + let canAdd = true; const compare = data.folder.sharing.entities.filter((item: any) => userEntities.indexOf(item) > -1); @@ -435,7 +437,10 @@ export class FolderTreeComponent implements OnInit { canAdmin = true; } }); - + if (data.folder.user_id !== currentUserId && node.public) { + canAdd = false; + } + node.canAdd = canAdd; node.edition = (canAdmin || data.folder.user_id === currentUserId) ? true : false; }), ).subscribe();