50 lines
2.4 KiB
TypeScript
50 lines
2.4 KiB
TypeScript
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
import {Router} from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'search-form',
|
|
template: `
|
|
|
|
<form [class]="(isDisabled)?'uk-margin uk-text-center uk-margin-top uk-disabled':'uk-margin uk-text-center uk-margin-top'">
|
|
<input type="text" class="uk-input uk-width-xlarge" [placeholder]="placeholderText" aria-describedby="sizing-addon2" [(ngModel)]="keyword" name="keyword" >
|
|
<button *ngIf="!link" (click)="keywordChanged()" type="submit" class=" uk-button portal-button">
|
|
<span class="uk-icon" ><svg width="30" height="30" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1.5"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg></span>
|
|
</button>
|
|
<button *ngIf="link" (click)="goTo()" type="submit" class=" uk-button portal-button uk-padding uk-padding-remove-top uk-padding-remove-bottom ">
|
|
<span class="uk-icon" ><svg width="30" height="30" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1.5"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg></span>
|
|
</button>
|
|
</form>
|
|
`
|
|
})
|
|
|
|
export class SearchFormComponent {
|
|
@Input() isDisabled: boolean = false;
|
|
@Input() keyword: string = '';
|
|
@Input() generalSearch: boolean = false;
|
|
@Input() placeholderText: string = "Type keywords";
|
|
@Input() link: string = "";
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
@Output() keywordChange = new EventEmitter();
|
|
|
|
constructor (private _router:Router) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
keywordChanged() {
|
|
//console.info("inside form: "+this.keyword);
|
|
this.keywordChange.emit({
|
|
value: this.keyword
|
|
});
|
|
}
|
|
goTo() {
|
|
//this._router.navigate(['/search/find'], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
|
this._router.navigate([this.link], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
|
}
|
|
}
|