diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts index 82cde7a811..03b74b5769 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts @@ -68,6 +68,8 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges { @ViewChild('resultsTableBody', {}) resultsTableBody: ElementRef; + baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', ''); + constructor(private alfrescoSearchService: AlfrescoSearchService, private translate: AlfrescoTranslationService, private alfrescoThumbnailService: AlfrescoThumbnailService) { @@ -127,13 +129,12 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges { let icon = this.alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType); return this.resolveIconPath(icon); } else if (node.entry.isFolder) { - return 'ft_ic_folder.svg'; + return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`; } } resolveIconPath(icon: string): string { - let baseComponentPath = module.id.replace('/components/alfresco-search.component.js', ''); - return `${baseComponentPath}/../assets/images/${icon}`; + return `${this.baseComponentPath}/../assets/images/${icon}`; } /** diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts index e9c53a7931..222560af99 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts @@ -348,6 +348,22 @@ describe('AlfrescoSearchControlComponent', () => { }); }); - }); + it('should set un-active the search after file/folder is clicked', () => { + component.searchActive = true; + component.onFileClicked({ + value: 'node12345' + }); + expect(component.searchActive).toBe(false); + }); + + it('should reset the search term after file/folder is clicked', () => { + component.liveSearchTerm = 'test'; + component.onFileClicked({ + value: 'node12345' + }); + + expect(component.liveSearchTerm).toBe(''); + }); + }); }); diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts index 5ea4e3f9fc..3f0c1cc859 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts @@ -171,6 +171,8 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy { } onFileClicked(event): void { + this.liveSearchTerm = ''; + this.searchActive = false; this.fileSelect.emit(event); } diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts index 61ba0237f9..51e09eadae 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts @@ -63,6 +63,8 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit { queryParamName = 'q'; + baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', ''); + constructor(private alfrescoSearchService: AlfrescoSearchService, private translate: AlfrescoTranslationService, private _alfrescoThumbnailService: AlfrescoThumbnailService, @@ -100,13 +102,12 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit { let icon = this._alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType); return this.resolveIconPath(icon); } else if (node.entry.isFolder) { - return 'ft_ic_folder.svg'; + return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`; } } private resolveIconPath(icon: string): string { - let baseComponentPath = module.id.replace('/components/alfresco-search.component.js', ''); - return `${baseComponentPath}/../assets/images/${icon}`; + return `${this.baseComponentPath}/../assets/images/${icon}`; } /**