mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3930] Can't load more results in Copy/Move dialog (#4247)
* fix unrelated failing test improve type definition add set get filtering node selector fix directive highlight fix minor problem style breadcrumb small refactoring problem documentlist * fix lint style * fix html node * fix test
This commit is contained in:
@@ -232,7 +232,7 @@ export class ContentNodeDialogService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private rowFilter(currentNodeId, row: ShareDataRow): boolean {
|
||||
private rowFilter(currentNodeId: string, row: ShareDataRow): boolean {
|
||||
const node: Node = row.node.entry;
|
||||
|
||||
if (node.id === currentNodeId || node.isFile) {
|
||||
|
@@ -53,8 +53,8 @@
|
||||
data-automation-id="content-node-selector-content-list">
|
||||
<adf-document-list
|
||||
#documentList
|
||||
adf-highlight
|
||||
adf-highlight-selector="adf-name-location-cell .adf-name-location-cell-name"
|
||||
[adf-highlight]="searchTerm"
|
||||
adf-highlight-selector=".adf-name-location-cell-name"
|
||||
[showHeader]="false"
|
||||
[node]="nodes"
|
||||
[maxItems]="pageSize"
|
||||
@@ -66,7 +66,7 @@
|
||||
[contentActions]="false"
|
||||
[allowDropFiles]="false"
|
||||
(folderChange)="onFolderChange()"
|
||||
(ready)="onFolderLoaded($event)"
|
||||
(ready)="onFolderLoaded()"
|
||||
(node-dblclick)="onNodeDoubleClick($event)"
|
||||
data-automation-id="content-node-selector-document-list">
|
||||
|
||||
|
@@ -112,32 +112,28 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
component.excludeSiteContent = ['blog'];
|
||||
fixture.detectChanges();
|
||||
|
||||
const testSiteContent = new Node({id: 'blog-id', properties: { 'st:componentId': 'blog' }});
|
||||
expect(component.rowFilter(<any> {node: {entry: testSiteContent}}, null, null)).toBe(false);
|
||||
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
||||
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null)).toBe(false);
|
||||
});
|
||||
|
||||
it('should NOT filter out any site content by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const testSiteContent = new Node({id: 'blog-id', properties: { 'st:componentId': 'blog' }});
|
||||
expect(component.rowFilter(<any> {node: {entry: testSiteContent}}, null, null)).toBe(true);
|
||||
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
||||
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Breadcrumbs', () => {
|
||||
|
||||
let documentListService,
|
||||
sitesService,
|
||||
expectedDefaultFolderNode;
|
||||
let documentListService, sitesService;
|
||||
|
||||
beforeEach(() => {
|
||||
expectedDefaultFolderNode = <Node> { path: { elements: [] } };
|
||||
documentListService = TestBed.get(DocumentListService);
|
||||
sitesService = TestBed.get(SitesService);
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
spyOn(component.documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve());
|
||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@@ -149,7 +145,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(expectedDefaultFolderNode);
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -215,26 +211,27 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path);
|
||||
}));
|
||||
|
||||
it('should NOT show the breadcrumb for the selected node when not on search results list', (done) => {
|
||||
it('should NOT show the breadcrumb for the selected node when not on search results list', fakeAsync(() => {
|
||||
typeToSearchBox();
|
||||
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
component.onFolderChange();
|
||||
fixture.detectChanges();
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
|
||||
const chosenNode = <Node> { path: { elements: [] } };
|
||||
component.onNodeSelect({ detail: { node: { entry: chosenNode } } });
|
||||
fixture.detectChanges();
|
||||
component.onFolderChange();
|
||||
fixture.detectChanges();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(expectedDefaultFolderNode);
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
const chosenNode = <Node> { path: { elements: [] } };
|
||||
component.onNodeSelect({ detail: { node: { entry: chosenNode } } });
|
||||
fixture.detectChanges();
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
}));
|
||||
|
||||
it('should keep breadcrumb\'s folderNode unchanged if breadcrumbTransform is NOT defined', (done) => {
|
||||
fixture.detectChanges();
|
||||
@@ -244,7 +241,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(component.breadcrumbTransform).toBeNull();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(expectedDefaultFolderNode);
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -306,7 +303,6 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
const expectedDefaultFolderNode = <NodeEntry> { entry: { path: { elements: [] } } };
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode));
|
||||
spyOn(component.documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve());
|
||||
|
||||
const sitesService = TestBed.get(SitesService);
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
@@ -588,19 +584,20 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('should highlight the results when search was performed in the next timeframe', fakeAsync(() => {
|
||||
spyOn(component.highlighter, 'highlight');
|
||||
typeToSearchBox('shenron');
|
||||
it('should highlight the results when search was performed in the next timeframe', (done) => {
|
||||
typeToSearchBox('My');
|
||||
|
||||
tick(debounceSearch);
|
||||
setTimeout(() => {
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
|
||||
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-highlight').innerHTML).toBe('My');
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
expect(component.highlighter.highlight).toHaveBeenCalledWith('shenron');
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('should show the default text instead of result list if search was cleared', (done) => {
|
||||
typeToSearchBox();
|
||||
@@ -670,7 +667,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
component.searchTerm = '';
|
||||
fixture.detectChanges();
|
||||
|
||||
component.updatePagination({ skipCount });
|
||||
component.getNextPageOfSearch({ skipCount });
|
||||
fixture.detectChanges();
|
||||
expect(component.searchTerm).toBe('');
|
||||
|
||||
|
@@ -16,10 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
AlfrescoApiService, HighlightDirective, UserPreferencesService,
|
||||
PaginatedComponent, PaginationModel
|
||||
} from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, HighlightDirective, UserPreferencesService, PaginationModel } from '@alfresco/adf-core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { Node, NodePaging, Pagination, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { DocumentListComponent, PaginationStrategy } from '../document-list/components/document-list.component';
|
||||
@@ -30,6 +27,7 @@ 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;
|
||||
|
||||
@@ -42,7 +40,7 @@ const defaultValidation = () => true;
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { 'class': 'adf-content-node-selector-panel' }
|
||||
})
|
||||
export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedComponent {
|
||||
export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
|
||||
/** Node ID of the folder currently listed. */
|
||||
@Input()
|
||||
@@ -270,20 +268,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedCompo
|
||||
this.querySearch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the next batch of search results
|
||||
*
|
||||
* @param event Pagination object
|
||||
*/
|
||||
updatePagination(pagination: Pagination): void {
|
||||
this.infiniteScroll = true;
|
||||
this.skipCount = pagination.skipCount;
|
||||
|
||||
if (this.searchTerm.length > 0) {
|
||||
this.querySearch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the call to searchService with the proper parameters
|
||||
*/
|
||||
@@ -322,16 +306,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedCompo
|
||||
}
|
||||
|
||||
this.pagination.next(nodePaging.list.pagination);
|
||||
this.highlight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight the actual search term in the next frame
|
||||
*/
|
||||
highlight(): void {
|
||||
setTimeout(() => {
|
||||
this.highlighter.highlight(this.searchTerm);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +320,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedCompo
|
||||
/**
|
||||
* Attempts to set the currently loaded node
|
||||
*/
|
||||
onFolderLoaded(nodePaging: NodePaging): void {
|
||||
onFolderLoaded(): void {
|
||||
if (!this.showingSearchResults) {
|
||||
this.attemptNodeSelection(this.documentList.folderNode);
|
||||
}
|
||||
@@ -413,8 +387,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedCompo
|
||||
};
|
||||
|
||||
this.apiService.nodesApi.getNode(node.guid, options)
|
||||
.then((documentLibrary) => {
|
||||
this.documentList.performCustomSourceNavigation(documentLibrary);
|
||||
.then((nodeEntry: NodeEntry) => {
|
||||
this.documentList.navigateTo(nodeEntry.entry);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user