mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4056][ADF-4060][ADF-3930] Content Node Selector fix (#4293)
* remove target when search * content panel component infinite pagiantion and dropdown integration * fix insight karma
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
[contextMenuActions]="false"
|
||||
[contentActions]="false"
|
||||
[allowDropFiles]="false"
|
||||
[sorting]="'server'"
|
||||
[where]="where"
|
||||
(folderChange)="onFolderChange()"
|
||||
(ready)="onFolderLoaded()"
|
||||
@@ -89,7 +90,7 @@
|
||||
</adf-document-list>
|
||||
|
||||
<adf-infinite-pagination
|
||||
[target]="documentList"
|
||||
[target]="target"
|
||||
[loading]="loadingSearchResults"
|
||||
(loadMore)="getNextPageOfSearch($event)"
|
||||
data-automation-id="content-node-selector-search-pagination">
|
||||
|
@@ -84,6 +84,7 @@
|
||||
height: 200px;
|
||||
overflow: auto;
|
||||
border: 1px solid mat-color($foreground, base, 0.07);
|
||||
padding: 1px;
|
||||
|
||||
.adf-highlight {
|
||||
color: mat-color($primary);
|
||||
|
@@ -116,6 +116,10 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should the document list use the server ordering', () => {
|
||||
expect(component.documentList.sorting).toBe('server');
|
||||
});
|
||||
|
||||
it('should trigger the select event when selection has been made', (done) => {
|
||||
const expectedNode = <Node> {};
|
||||
component.select.subscribe((nodes) => {
|
||||
@@ -350,6 +354,13 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
const expectedDefaultFolderNode = <NodeEntry> { entry: { path: { elements: [] } } };
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(of({
|
||||
list: {
|
||||
pagination: {},
|
||||
entries: [],
|
||||
source: {}
|
||||
}
|
||||
}));
|
||||
|
||||
const sitesService = TestBed.get(SitesService);
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
@@ -364,6 +375,8 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
});
|
||||
|
||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||
component.documentList.ngOnInit();
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@@ -775,6 +788,44 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
||||
expect(paginationLoading).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('Should infinite pagination target be null when we use it for search ', fakeAsync(() => {
|
||||
component.showingSearchResults = true;
|
||||
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
expect(component.target).toBeNull();
|
||||
}));
|
||||
|
||||
it('Should infinite pagination target be present when search finish', fakeAsync(() => {
|
||||
component.showingSearchResults = true;
|
||||
|
||||
typeToSearchBox('shenron');
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
typeToSearchBox('');
|
||||
|
||||
tick(debounceSearch);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.target).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('Should infinite pagination target on init be the document list', fakeAsync(() => {
|
||||
component.showingSearchResults = true;
|
||||
|
||||
expect(component.target).toEqual(component.documentList);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -21,7 +21,7 @@ import {
|
||||
UserPreferencesService,
|
||||
PaginationModel,
|
||||
UserPreferenceValues,
|
||||
InfinitePaginationComponent
|
||||
InfinitePaginationComponent, PaginatedComponent
|
||||
} from '@alfresco/adf-core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { Node, NodePaging, Pagination, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
@@ -163,6 +163,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
debounceSearch: number = 200;
|
||||
searchInput: FormControl = new FormControl();
|
||||
|
||||
target: PaginatedComponent;
|
||||
|
||||
constructor(private contentNodeSelectorService: ContentNodeSelectorService,
|
||||
private customResourcesService: CustomResourcesService,
|
||||
private userPreferencesService: UserPreferencesService) {
|
||||
@@ -194,6 +196,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.target = this.documentList;
|
||||
this.folderIdToShow = this.currentFolderId;
|
||||
|
||||
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
|
||||
@@ -232,6 +235,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
siteChanged(chosenSite: SiteEntry): void {
|
||||
this.siteId = chosenSite.entry.guid;
|
||||
this.updateResults();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +278,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
this.searchTerm = '';
|
||||
this.nodePaging = null;
|
||||
this.pagination.maxItems = this.pageSize;
|
||||
this.infinitePaginationComponent.reset();
|
||||
this.chosenNode = null;
|
||||
this.showingSearchResults = false;
|
||||
}
|
||||
@@ -283,6 +286,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
* Update the result list depending on the criteria
|
||||
*/
|
||||
private updateResults(): void {
|
||||
this.target = this.searchTerm.length > 0 ? null : this.documentList;
|
||||
|
||||
if (this.searchTerm.length === 0) {
|
||||
this.clear();
|
||||
} else {
|
||||
@@ -296,7 +301,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
private startNewSearch(): void {
|
||||
this.nodePaging = null;
|
||||
this.pagination.maxItems = this.pageSize;
|
||||
this.infinitePaginationComponent.reset();
|
||||
if (this.target) {
|
||||
this.infinitePaginationComponent.reset();
|
||||
}
|
||||
this.chosenNode = null;
|
||||
this.folderIdToShow = null;
|
||||
this.querySearch();
|
||||
|
Reference in New Issue
Block a user