[ADF-1040] Change document list style rows based on permissions model (#2085)

* Change document list style rows based on permissions model

* fix test
This commit is contained in:
Eugenio Romano
2017-07-17 17:22:08 +01:00
parent 6947e04208
commit a9142e2ca2
29 changed files with 382 additions and 167 deletions

View File

@@ -103,32 +103,21 @@ export class DocumentActionsService {
}
private deleteNode(obj: any, target?: any, permission?: string): Observable<any> {
let handlerObservale;
let handlerObservable;
if (this.canExecuteAction(obj)) {
if (this.hasPermission(obj.entry, permission)) {
handlerObservale = this.documentListService.deleteNode(obj.entry.id);
handlerObservale.subscribe(() => {
if (this.contentService.hasPermission(obj.entry, permission)) {
handlerObservable = this.documentListService.deleteNode(obj.entry.id);
handlerObservable.subscribe(() => {
if (target && typeof target.reload === 'function') {
target.reload();
}
});
return handlerObservale;
return handlerObservable;
} else {
this.permissionEvent.next(new PermissionModel({type: 'content', action: 'delete', permission: permission}));
return Observable.throw(new Error('No permission to delete'));
}
}
}
private hasPermission(node: any, permission: string): boolean {
if (this.hasPermissions(node)) {
return node.allowableOperations.find(permision => permision === permission) ? true : false;
}
return false;
}
private hasPermissions(node: any): boolean {
return node && node.allowableOperations ? true : false;
}
}