From 0d6c1bedfa1a9107789e6e2cfae3b3d9395328cb Mon Sep 17 00:00:00 2001 From: Suzana Dirla Date: Wed, 6 Feb 2019 21:07:51 +0200 Subject: [PATCH] [ADF-4027] fix navigation to custom sources (#4273) * [ADF-4027] fix navigation to custom sources * [ADF-4027] code cleanup * [ADF-4027] allow to perform navigation for custom sources * [ADF-4027] disable old test * [ADF-4027] perform site navigation on document-list * [ADF-4027] update test --- ...content-node-selector-panel.component.html | 1 - .../content-node-selector-panel.component.ts | 21 +------------------ .../document-list.component.spec.ts | 4 ++-- .../components/document-list.component.ts | 21 ++++++++++++++----- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.html b/lib/content-services/content-node-selector/content-node-selector-panel.component.html index 9a59658c19..2d618aa486 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.html +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.html @@ -68,7 +68,6 @@ [where]="where" (folderChange)="onFolderChange()" (ready)="onFolderLoaded()" - (node-dblclick)="onNodeDoubleClick($event)" data-automation-id="content-node-selector-document-list"> diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.ts index 99b5f51430..8540dba586 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.ts @@ -16,7 +16,7 @@ */ import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core'; -import { AlfrescoApiService, HighlightDirective, UserPreferencesService, PaginationModel } from '@alfresco/adf-core'; +import { HighlightDirective, UserPreferencesService, PaginationModel } from '@alfresco/adf-core'; import { FormControl } from '@angular/forms'; import { Node, NodePaging, Pagination, SiteEntry, SitePaging } from '@alfresco/js-api'; import { DocumentListComponent } from '../document-list/components/document-list.component'; @@ -27,7 +27,6 @@ import { debounceTime } from 'rxjs/operators'; import { BehaviorSubject } from 'rxjs'; import { CustomResourcesService } from '../document-list/services/custom-resources.service'; import { ShareDataRow } from '../document-list'; -import { NodeEntry } from '@alfresco/js-api/src/api/content-rest-api/model/nodeEntry'; export type ValidationFunction = (entry: Node) => boolean; @@ -148,7 +147,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit { searchInput: FormControl = new FormControl(); constructor(private contentNodeSelectorService: ContentNodeSelectorService, - private apiService: AlfrescoApiService, private customResourcesService: CustomResourcesService, private preferences: UserPreferencesService) { this.searchInput.valueChanges @@ -389,21 +387,4 @@ export class ContentNodeSelectorPanelComponent implements OnInit { onNodeSelect(event: any): void { this.attemptNodeSelection(event.detail.node.entry); } - - onNodeDoubleClick(customEvent: CustomEvent) { - const node: any = customEvent.detail.node.entry; - - if (node && node.guid) { - const options = { - maxItems: this.pageSize, - skipCount: this.skipCount, - include: ['path', 'properties', 'allowableOperations'] - }; - - this.apiService.nodesApi.getNode(node.guid, options) - .then((nodeEntry: NodeEntry) => { - this.documentList.navigateTo(nodeEntry.entry); - }); - } - } } diff --git a/lib/content-services/document-list/components/document-list.component.spec.ts b/lib/content-services/document-list/components/document-list.component.spec.ts index a92209f8b0..a6b27b76e9 100644 --- a/lib/content-services/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/document-list/components/document-list.component.spec.ts @@ -1023,7 +1023,7 @@ describe('DocumentList', () => { expect(documentList.noPermission).toBeTruthy(); }); - it('should not perform navigation for virtual sources', () => { + it('should allow to perform navigation for virtual sources', () => { const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-']; const node = new FolderNode('folder'); @@ -1032,7 +1032,7 @@ describe('DocumentList', () => { sources.forEach((source) => { documentList.currentFolderId = source; - expect(documentList.canNavigateFolder(node.entry)).toBeFalsy(); + expect(documentList.canNavigateFolder(node.entry)).toBeTruthy(); }); }); 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 6ac4104974..ea43b3af33 100644 --- a/lib/content-services/document-list/components/document-list.component.ts +++ b/lib/content-services/document-list/components/document-list.component.ts @@ -40,7 +40,8 @@ import { CustomLoadingContentTemplateDirective, CustomNoPermissionTemplateDirective, CustomEmptyContentTemplateDirective, - RequestPaginationModel + RequestPaginationModel, + AlfrescoApiService } from '@alfresco/adf-core'; import { Node, NodeEntry, NodePaging } from '@alfresco/js-api'; @@ -283,7 +284,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte private preferences: UserPreferencesService, private customResourcesService: CustomResourcesService, private contentService: ContentService, - private thumbnailService: ThumbnailService) { + private thumbnailService: ThumbnailService, + private alfrescoApiService: AlfrescoApiService) { this._pagination = { maxItems: this.maxItems || this.preferences.paginationSize, @@ -716,6 +718,17 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte if (nodeEntry.entry.isFolder) { this.navigateTo(nodeEntry.entry); } + + if (nodeEntry.entry['guid']) { + const options = { + include: this.includeFields + }; + + this.alfrescoApiService.nodesApi.getNode(nodeEntry.entry['guid'], options) + .then((node: NodeEntry) => { + this.navigateTo(node.entry); + }); + } } } @@ -781,9 +794,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte canNavigateFolder(node: Node): boolean { let canNavigateFolder: boolean = false; - if (this.customResourcesService.isCustomSource(this.currentFolderId)) { - canNavigateFolder = false; - } else if (node && node.isFolder) { + if (node && node.isFolder) { canNavigateFolder = true; }