2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
|
|
import {Router} from '@angular/router';
|
|
|
|
|
|
|
|
@Component({
|
2020-02-13 15:44:51 +01:00
|
|
|
selector: 'search-form',
|
|
|
|
template: `
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
<form [class]="((isDisabled)?'uk-disabled':'')+(setFormCentered?' uk-text-center':'')">
|
2019-06-29 00:58:52 +02:00
|
|
|
<input type="text" class="uk-input uk-width-xlarge@l uk-width-medium@m uk-width-auto" [placeholder]="placeholderText" aria-describedby="sizing-addon2" [(ngModel)]="keyword" name="keyword" >
|
|
|
|
<button *ngIf="!link" (click)="keywordChanged()" type="submit" class=" uk-button portal-button uk-margin-small-left">
|
|
|
|
<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-vertical uk-margin-small-left">
|
|
|
|
<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>
|
2017-12-19 13:53:46 +01:00
|
|
|
</form>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchFormComponent {
|
|
|
|
@Input() isDisabled: boolean = false;
|
|
|
|
@Input() keyword: string = '';
|
|
|
|
@Input() generalSearch: boolean = false;
|
|
|
|
@Input() placeholderText: string = "Type keywords";
|
2019-04-08 14:11:54 +02:00
|
|
|
@Input() link: string = "";
|
2019-04-11 11:36:31 +02:00
|
|
|
@Input() setFormCentered: boolean = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
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() {
|
2019-04-08 14:11:54 +02:00
|
|
|
//this._router.navigate(['/search/find'], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
|
|
|
this._router.navigate([this.link], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|