From 44a9ade552638b1b48193e368748bea8b9fd7327 Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Sat, 3 Nov 2018 19:46:58 +0200 Subject: [PATCH] [ACA-1806] Viewer - navigate on node delete event (#775) * navigate onode delete event * remove console --- .../components/preview/preview.component.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/components/preview/preview.component.ts b/src/app/components/preview/preview.component.ts index d773d5766..4919eea2e 100644 --- a/src/app/components/preview/preview.component.ts +++ b/src/app/components/preview/preview.component.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core'; import { ActivatedRoute, Router, @@ -49,7 +49,8 @@ import { ContentActionRef, ViewerExtensionRef } from '@alfresco/adf-extensions'; encapsulation: ViewEncapsulation.None, host: { class: 'app-preview' } }) -export class PreviewComponent extends PageComponent implements OnInit { +export class PreviewComponent extends PageComponent + implements OnInit, OnDestroy { previewLocation: string = null; routesSkipNavigation = ['shared', 'recent-files', 'favorites']; navigateSource: string = null; @@ -108,10 +109,20 @@ export class PreviewComponent extends PageComponent implements OnInit { } }); + this.subscriptions = this.subscriptions.concat([ + this.content.nodesDeleted.subscribe(() => + this.navigateToFileLocation(true) + ) + ]); + this.openWith = this.extensions.openWithActions; this.contentExtensions = this.extensions.viewerContentExtensions; } + ngOnDestroy() { + super.ngOnDestroy(); + } + /** * Loads the particular node into the Viewer * @param id Unique identifier for the Node to display @@ -147,11 +158,16 @@ export class PreviewComponent extends PageComponent implements OnInit { * @param isVisible Indicator whether Viewer is visible or hidden. */ onVisibilityChanged(isVisible: boolean): void { + const shouldNavigate = !isVisible; + this.navigateToFileLocation(shouldNavigate); + } + + navigateToFileLocation(shouldNavigate: boolean) { const shouldSkipNavigation = this.routesSkipNavigation.includes( this.previewLocation ); - if (!isVisible) { + if (shouldNavigate) { const route = this.getNavigationCommands(this.previewLocation); if (!shouldSkipNavigation && this.folderId) {