mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Merge pull request #289 from Alfresco/dev-wabson-283
Load viewer on search results click
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr *ngFor="let result of results; let idx = index">
|
||||
<tr *ngFor="let result of results; let idx = index" (click)="onItemClick(result, $event)">
|
||||
<td><img src="{{getMimeTypeIcon(result)}}" /></td>
|
||||
<td attr.data-automation-id=file_{{result.entry.name}} >{{result.entry.name}}</td>
|
||||
<td attr.data-automation-id=file_{{result.entry.name}}_{{result.entry.modifiedByUser.displayName}}>
|
||||
|
@@ -109,4 +109,35 @@ describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('search result actions', () => {
|
||||
|
||||
it('should emit preview when file item clicked',
|
||||
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.overrideProviders(AlfrescoSearchComponent, [
|
||||
{ provide: AlfrescoSearchService, useClass: SearchServiceMock }
|
||||
])
|
||||
.createAsync(AlfrescoSearchComponent)
|
||||
.then((fixture) => {
|
||||
let componentInstance = fixture.componentInstance;
|
||||
componentInstance.results = [{
|
||||
entry: {
|
||||
id: '123',
|
||||
name: 'MyDoc',
|
||||
content: {
|
||||
mimetype: 'text/plain'
|
||||
},
|
||||
isFile: true
|
||||
}
|
||||
}];
|
||||
fixture.detectChanges(componentInstance.results[0]);
|
||||
componentInstance.preview.subscribe(e => {
|
||||
expect(e.value).toBe(componentInstance.results[0]);
|
||||
});
|
||||
componentInstance.onItemClick();
|
||||
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, Optional, OnChanges, OnInit } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, Output, Optional, OnChanges, OnInit } from '@angular/core';
|
||||
import { RouteParams } from '@angular/router-deprecated';
|
||||
import { AlfrescoSearchService } from './../services/alfresco-search.service';
|
||||
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
|
||||
@@ -38,6 +38,9 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
@Input()
|
||||
searchTerm: string = '';
|
||||
|
||||
@Output()
|
||||
preview: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
results: any;
|
||||
|
||||
errorMessage;
|
||||
@@ -100,4 +103,17 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
onItemClick(node, event?: Event): void {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (node && node.entry) {
|
||||
if (node.entry.isFile) {
|
||||
this.preview.emit({
|
||||
value: node
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -59,7 +59,6 @@ export class AlfrescoSearchService {
|
||||
public getLiveSearchResults(term: string): Observable<any> {
|
||||
return Observable.fromPromise(this.getSearchNodesPromise(term))
|
||||
.map(res => <any> res)
|
||||
.do(data => console.log('Search data', data)) // eyeball results in the console
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user