[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
This commit is contained in:
Suzana Dirla
2019-02-06 21:07:51 +02:00
committed by Eugenio Romano
parent a31803a6bb
commit 0d6c1bedfa
4 changed files with 19 additions and 28 deletions

View File

@@ -68,7 +68,6 @@
[where]="where"
(folderChange)="onFolderChange()"
(ready)="onFolderLoaded()"
(node-dblclick)="onNodeDoubleClick($event)"
data-automation-id="content-node-selector-document-list">
<adf-custom-empty-content-template>

View File

@@ -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);
});
}
}
}

View File

@@ -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();
});
});

View File

@@ -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 = <PaginationModel> {
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;
}