mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-2202] Not able to search for files (#5569)
* [AAE-2202] Not able to search for files * * fixd test * * fixed panel test * * fixed files search options * * added docs
This commit is contained in:
@@ -54,12 +54,13 @@ export class ContentNodeDialogService {
|
||||
|
||||
/**
|
||||
* Opens a file browser at a chosen folder location.
|
||||
* shows files and folders in the dialog search result.
|
||||
* @param folderNodeId ID of the folder to use
|
||||
* @returns Information about the selected file(s)
|
||||
*/
|
||||
openFileBrowseDialogByFolderId(folderNodeId: string): Observable<Node[]> {
|
||||
return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((nodeEntry: NodeEntry) => {
|
||||
return this.openUploadFileDialog('Choose', nodeEntry.entry);
|
||||
return this.openUploadFileDialog('Choose', nodeEntry.entry, true);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ export class ContentNodeDialogService {
|
||||
|
||||
/**
|
||||
* Opens a file browser at a chosen site location.
|
||||
* shows files and folders in the dialog search result.
|
||||
* @returns Information about the selected file(s)
|
||||
*/
|
||||
openFileBrowseDialogBySite(): Observable<Node[]> {
|
||||
@@ -196,9 +198,10 @@ export class ContentNodeDialogService {
|
||||
* Opens a dialog to choose a file to upload.
|
||||
* @param action Name of the action to show in the title
|
||||
* @param contentEntry Item to upload
|
||||
* @param showFilesInResult Show files in dialog search result
|
||||
* @returns Information about the chosen file(s)
|
||||
*/
|
||||
openUploadFileDialog(action: string, contentEntry: Node): Observable<Node[]> {
|
||||
openUploadFileDialog(action: string, contentEntry: Node, showFilesInResult = false): Observable<Node[]> {
|
||||
const select = new Subject<Node[]>();
|
||||
select.subscribe({
|
||||
complete: this.close.bind(this)
|
||||
@@ -210,7 +213,8 @@ export class ContentNodeDialogService {
|
||||
currentFolderId: contentEntry.id,
|
||||
imageResolver: this.imageResolver.bind(this),
|
||||
isSelectionValid: this.isNodeFile.bind(this),
|
||||
select: select
|
||||
select: select,
|
||||
showFilesInResult
|
||||
};
|
||||
|
||||
this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '630px');
|
||||
|
||||
+16
-6
@@ -353,7 +353,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
describe('Search functionality', () => {
|
||||
let getCorrespondingNodeIdsSpy;
|
||||
|
||||
const defaultSearchOptions = (searchTerm, rootNodeId = undefined, skipCount = 0) => {
|
||||
const defaultSearchOptions = (searchTerm, rootNodeId = undefined, skipCount = 0, showFiles = false) => {
|
||||
|
||||
const parentFiltering = rootNodeId ? [{ query: `ANCESTOR:'workspace://SpacesStore/${rootNodeId}'` }] : [];
|
||||
|
||||
@@ -367,7 +367,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
skipCount: skipCount
|
||||
},
|
||||
filterQueries: [
|
||||
{ query: "TYPE:'cm:folder'" },
|
||||
{ query: `TYPE:'cm:folder'${ showFiles ? " OR TYPE:'cm:content'" : '' }` },
|
||||
{ query: 'NOT cm:creator:System' },
|
||||
...parentFiltering
|
||||
],
|
||||
@@ -419,6 +419,16 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
expect(searchSpy).toHaveBeenCalledWith(defaultSearchOptions('kakarot'));
|
||||
}));
|
||||
|
||||
it('should show files in results by calling the search api on search change', fakeAsync(() => {
|
||||
component.showFilesInResult = true;
|
||||
typeToSearchBox('kakarot');
|
||||
|
||||
tick(debounceSearch);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(searchSpy).toHaveBeenCalledWith(defaultSearchOptions('kakarot', undefined, 0, true));
|
||||
}));
|
||||
|
||||
it('should reset the currently chosen node in case of starting a new search', fakeAsync(() => {
|
||||
component.chosenNode = <Node> {};
|
||||
typeToSearchBox('kakarot');
|
||||
@@ -452,8 +462,8 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
expect(cnSearchSpy).toHaveBeenCalled();
|
||||
expect(cnSearchSpy.calls.count()).toBe(2);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', undefined, 0, 25);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25, ['123456testId', '09876543testId']);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', undefined, 0, 25, [], false);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25, ['123456testId', '09876543testId'], false);
|
||||
}));
|
||||
|
||||
it('should call the content node selector\'s search with the right parameters on changing the site selectBox value from a custom dropdown menu', fakeAsync(() => {
|
||||
@@ -470,8 +480,8 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
expect(cnSearchSpy).toHaveBeenCalled();
|
||||
expect(cnSearchSpy.calls.count()).toBe(2);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', undefined, 0, 25);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25, ['123456testId', '09876543testId']);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', undefined, 0, 25, [], false);
|
||||
expect(cnSearchSpy).toHaveBeenCalledWith('vegeta', '-sites-', 0, 25, ['123456testId', '09876543testId'], false);
|
||||
}));
|
||||
|
||||
it('should get the corresponding node ids on search when a known alias is selected from dropdown', fakeAsync(() => {
|
||||
|
||||
+11
-2
@@ -56,6 +56,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
|
||||
private showSiteList = true;
|
||||
private showSearchField = true;
|
||||
private showFiles = false;
|
||||
|
||||
/** Node ID of the folder currently listed. */
|
||||
@Input()
|
||||
@@ -163,6 +164,14 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
return this.showSiteList;
|
||||
}
|
||||
|
||||
/** Shows the files and folders in the search result */
|
||||
@Input()
|
||||
set showFilesInResult(value: boolean) {
|
||||
if (value !== undefined && value !== null) {
|
||||
this.showFiles = value;
|
||||
}
|
||||
}
|
||||
|
||||
/** Emitted when the user has chosen an item. */
|
||||
@Output()
|
||||
select: EventEmitter<Node[]> = new EventEmitter<Node[]>();
|
||||
@@ -355,14 +364,14 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
if (this.customResourcesService.hasCorrespondingNodeIds(this.siteId)) {
|
||||
this.customResourcesService.getCorrespondingNodeIds(this.siteId)
|
||||
.subscribe((nodeIds) => {
|
||||
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, nodeIds)
|
||||
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, nodeIds, this.showFiles)
|
||||
.subscribe(this.showSearchResults.bind(this));
|
||||
},
|
||||
() => {
|
||||
this.showSearchResults({ list: { entries: [] } });
|
||||
});
|
||||
} else {
|
||||
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems)
|
||||
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.pagination.skipCount, this.pagination.maxItems, [], this.showFiles)
|
||||
.subscribe(this.showSearchResults.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -32,5 +32,6 @@ export interface ContentNodeSelectorComponentData {
|
||||
excludeSiteContent?: string[];
|
||||
select: Subject<Node[]>;
|
||||
showSearch?: boolean;
|
||||
showFilesInResult?: boolean;
|
||||
showDropdownSiteList?: boolean;
|
||||
}
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
[where]="data?.where"
|
||||
[showSearch]="data?.showSearch"
|
||||
[showDropdownSiteList]="data?.showDropdownSiteList"
|
||||
[showFilesInResult]="data?.showFilesInResult"
|
||||
(select)="onSelect($event)">
|
||||
</adf-content-node-selector-panel>
|
||||
</mat-dialog-content>
|
||||
|
||||
+7
-1
@@ -80,12 +80,18 @@ describe('ContentNodeSelectorService', () => {
|
||||
expect(search.query.paging.skipCount).toEqual(0);
|
||||
});
|
||||
|
||||
it('should filter the search only for folders', () => {
|
||||
it('should filter the search for folders', () => {
|
||||
service.search('nuka cola quantum');
|
||||
|
||||
expect(search.query.filterQueries).toContain({ query: "TYPE:'cm:folder'" });
|
||||
});
|
||||
|
||||
it('should filter the search for files', () => {
|
||||
service.search('nuka cola quantum', null, 0, 25, [], true);
|
||||
|
||||
expect(search.query.filterQueries).toContain({ query: "TYPE:'cm:folder' OR TYPE:'cm:content'" });
|
||||
});
|
||||
|
||||
it('should filter out the "system-base" entries', () => {
|
||||
service.search('nuka cola quantum');
|
||||
|
||||
|
||||
@@ -41,8 +41,9 @@ export class ContentNodeSelectorService {
|
||||
* @param [extraNodeIds] List of extra node ids to search from. This last parameter is necessary when
|
||||
* the rootNodeId is one of the supported aliases (e.g. '-my-', '-root-', '-mysites-', etc.)
|
||||
* and search is not supported for that alias, but can be performed on its corresponding nodes.
|
||||
* @param [showFiles] shows the files in the dialog search result
|
||||
*/
|
||||
public search(searchTerm: string, rootNodeId: string = null, skipCount: number = 0, maxItems: number = 25, extraNodeIds?: string[]): Observable<ResultSetPaging> {
|
||||
public search(searchTerm: string, rootNodeId: string = null, skipCount: number = 0, maxItems: number = 25, extraNodeIds?: string[], showFiles?: boolean): Observable<ResultSetPaging> {
|
||||
|
||||
let extraParentFiltering = '';
|
||||
|
||||
@@ -66,7 +67,7 @@ export class ContentNodeSelectorService {
|
||||
skipCount: skipCount
|
||||
},
|
||||
filterQueries: [
|
||||
{ query: "TYPE:'cm:folder'" },
|
||||
{ query: `TYPE:'cm:folder'${ showFiles ? " OR TYPE:'cm:content'" : '' }` },
|
||||
{ query: 'NOT cm:creator:System' },
|
||||
...parentFiltering
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user