2017-12-19 13:53:46 +01:00
|
|
|
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'">
|
2018-10-01 17:02:14 +02:00
|
|
|
<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>
|
2017-12-19 13:53:46 +01:00
|
|
|
</button>
|
2018-10-01 17:02:14 +02:00
|
|
|
<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>
|
2017-12-19 13:53:46 +01:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchFormComponent {
|
|
|
|
@Input() isDisabled: boolean = false;
|
|
|
|
@Input() keyword: string = '';
|
|
|
|
@Input() generalSearch: boolean = false;
|
|
|
|
@Input() placeholderText: string = "Type keywords";
|
|
|
|
@Input() link: boolean = false;
|
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
|
|
|
|
@Output() keywordChange = new EventEmitter();
|
|
|
|
|
|
|
|
constructor (private _router:Router) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
keywordChanged() {
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("inside form: "+this.keyword);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.keywordChange.emit({
|
|
|
|
value: this.keyword
|
|
|
|
});
|
|
|
|
}
|
|
|
|
goTo() {
|
|
|
|
this._router.navigate(['/search/find'], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
|
|
|
}
|
|
|
|
}
|