Restore navigation to search page in demo-shell

- Remove deprecated router component
- searchChanges and new searchSubmit component outputs work as you would expect
- Update tests

Refs #737
This commit is contained in:
Will Abson
2016-09-23 18:07:40 +01:00
parent 79fc3085c0
commit 147af98bda
6 changed files with 85 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
<alfresco-search-control *ngIf="isLoggedIn()" [searchTerm]="searchTerm" [autocomplete]="false"
(searchChange)="searchTermChange($event);" (expand)="onExpandToggle($event);" (preview)="onFileClicked($event)"></alfresco-search-control>
(searchSubmit)="onSearchSubmit($event);" (searchChange)="onSearchTermChange($event);" (expand)="onExpandToggle($event);" (preview)="onFileClicked($event)"></alfresco-search-control>
<alfresco-viewer [(showViewer)]="fileShowed"
[fileNodeId]="fileNodeId"

View File

@@ -16,6 +16,7 @@
*/
import { Component, EventEmitter, Output } from '@angular/core';
import { Router } from '@angular/router';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
declare let __moduleName: string;
@@ -34,13 +35,25 @@ export class SearchBarComponent {
@Output()
expand = new EventEmitter();
constructor(public auth: AlfrescoAuthenticationService) {
constructor(public router: Router,
public auth: AlfrescoAuthenticationService) {
}
isLoggedIn(): boolean {
return this.auth.isLoggedIn();
}
/**
* Called when the user submits the search, e.g. hits enter or clicks submit
*
* @param event Parameters relating to the search
*/
onSearchSubmit(event) {
this.router.navigate(['/search', {
q: event.value
}]);
}
onFileClicked(event) {
if (event.value.entry.isFile) {
this.fileNodeId = event.value.entry.id;
@@ -48,8 +61,7 @@ export class SearchBarComponent {
}
}
searchTermChange(event) {
console.log('Search term changed', event);
onSearchTermChange(event) {
this.searchTerm = event.value;
}