From a6b8e16391f54f7c5efb26a208247b7653d6de8d Mon Sep 17 00:00:00 2001 From: Vito Date: Mon, 16 Apr 2018 21:03:03 +0100 Subject: [PATCH] [ADF-2723] preventing document list to restart always from -my- folder (#3200) * [ADF-2723] preventing document list to restart always from -my- folder * [ADF-2723] fixed condition * [ADF-2723] removed commented line --- .../app/components/files/files.component.html | 1 + .../app/components/files/files.component.ts | 19 ++++++++++++++++--- .../components/document-list.component.ts | 5 ++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html index c55424740f..a98e66a05e 100644 --- a/demo-shell/src/app/components/files/files.component.html +++ b/demo-shell/src/app/components/files/files.component.html @@ -192,6 +192,7 @@ (success)="resetError()" (ready)="emitReadyEvent($event)" (preview)="showFile($event)" + (folderChange)="onFolderChange($event)" (permissionError)="handlePermissionError($event)"> diff --git a/demo-shell/src/app/components/files/files.component.ts b/demo-shell/src/app/components/files/files.component.ts index 6fc2e6c1fe..2561daf4b3 100644 --- a/demo-shell/src/app/components/files/files.component.ts +++ b/demo-shell/src/app/components/files/files.component.ts @@ -16,11 +16,11 @@ */ import { - Component, Input, OnInit, OnChanges, OnDestroy, + Component, Input, OnInit, OnChanges, OnDestroy, Optional, EventEmitter, ViewChild, SimpleChanges, Output } from '@angular/core'; import { MatDialog } from '@angular/material'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Params, Router } from '@angular/router'; import { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry } from 'alfresco-js-api'; import { AuthenticationService, AppConfigService, ContentService, TranslationService, @@ -146,6 +146,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { permissionsStyle: PermissionStyleModel[] = []; infiniteScrolling: boolean; supportedPages: number[]; + currentSiteid = ''; private onCreateFolder: Subscription; private onEditFolder: Subscription; @@ -159,6 +160,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { private logService: LogService, private preference: UserPreferencesService, private appConfig: AppConfigService, + @Optional() private route: ActivatedRoute, public authenticationService: AuthenticationService) { this.preference.select(UserPreferenceValues.SupportedPageSizes) .subscribe((pages) => { @@ -187,6 +189,14 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { }; } + if (this.route) { + this.route.params.forEach((params: Params) => { + if (params['id'] && this.currentFolderId !== params['id']) { + this.currentFolderId = params['id']; + } + }); + } + // this.disableDragArea = false; this.uploadService.fileUploadComplete.asObservable().debounceTime(300).subscribe(value => this.onFileUploadEvent(value)); this.uploadService.fileUploadDeleted.subscribe((value) => this.onFileUploadEvent(value)); @@ -262,6 +272,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { } } + onFolderChange($event) { + this.router.navigate(['/files', $event.value.id]); + } + handlePermissionError(event: any) { this.translateService.get('PERMISSON.LACKOF', { permission: event.permission, @@ -281,7 +295,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { emitReadyEvent(event: NodePaging) { this.documentListReady.emit(event); - this.router.navigate(['/files', event.list.source.id]); } pageIsEmpty(node: NodePaging) { diff --git a/lib/content-services/document-list/components/document-list.component.ts b/lib/content-services/document-list/components/document-list.component.ts index 3f427567d0..1eb0c316d8 100644 --- a/lib/content-services/document-list/components/document-list.component.ts +++ b/lib/content-services/document-list/components/document-list.component.ts @@ -373,7 +373,9 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte this.currentFolderId = changes.folderNode.currentValue.id; this.resetNewFolderPagination(); this.loadFolder(); - } else if (changes.currentFolderId && changes.currentFolderId.currentValue) { + } else if (changes.currentFolderId && + changes.currentFolderId.currentValue && + changes.currentFolderId.currentValue !== changes.currentFolderId.previousValue) { this.resetNewFolderPagination(); this.loadFolder(); } else if (this.data) { @@ -740,6 +742,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte this.currentFolderId = nodeId; this.resetNewFolderPagination(); this.loadFolder(); + this.folderChange.emit(new NodeEntryEvent({id: nodeId})); } private resetNewFolderPagination() {