[ACA-1135] spike on deleting nodes from the viewer (#192)

* delete/restore from the viewer

* rename content management service events

* test fixes

* offload node delete/restore to content service

* improve tests
This commit is contained in:
Denys Vuika
2018-02-21 06:00:58 +00:00
committed by Cilibiu Bogdan
parent 0d727a5ffd
commit 5234a875e7
19 changed files with 147 additions and 44 deletions

View File

@@ -27,6 +27,7 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AlfrescoApiService, UserPreferencesService, ObjectUtils } from '@alfresco/adf-core';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { ContentManagementService } from '../../common/services/content-management.service';
@Component({
selector: 'app-preview',
@@ -53,7 +54,8 @@ export class PreviewComponent implements OnInit {
constructor(private router: Router,
private route: ActivatedRoute,
private apiService: AlfrescoApiService,
private preferences: UserPreferencesService) {
private preferences: UserPreferencesService,
private content: ContentManagementService) {
}
ngOnInit() {
@@ -90,7 +92,9 @@ export class PreviewComponent implements OnInit {
async displayNode(id: string) {
if (id) {
try {
this.node = await this.apiService.nodesApi.getNodeInfo(id);
this.node = await this.apiService.nodesApi.getNodeInfo(id, {
include: [ 'allowableOperations']
});
if (this.node && this.node.isFile) {
const nearest = await this.getNearestNodes(this.node.id, this.node.parentId);
@@ -315,4 +319,16 @@ export class PreviewComponent implements OnInit {
}
return path;
}
canDeleteFile(): boolean {
return this.content.canDeleteNode(this.node);
}
async deleteFile() {
try {
await this.content.deleteNode(this.node);
this.onVisibilityChanged(false);
} catch {
}
}
}