1 |
50169
|
argiro.kok
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
2 |
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
3 |
|
|
import {Router} from '@angular/router';
|
4 |
|
|
|
5 |
|
|
@Component({
|
6 |
58093
|
argiro.kok
|
selector: 'search-form',
|
7 |
|
|
template: `
|
8 |
50169
|
argiro.kok
|
|
9 |
58093
|
argiro.kok
|
<form [class]="((isDisabled)?'uk-disabled':'')+(setFormCentered?' uk-text-center':'')">
|
10 |
58377
|
argiro.kok
|
<div class="uk-inline">
|
11 |
|
|
<a *ngIf="keyword.length > 0" class="uk-form-icon uk-form-icon-flip"
|
12 |
|
|
(click)="keyword = ''; keywordChanged()"
|
13 |
|
|
uk-icon="icon: close"></a>
|
14 |
58547
|
k.triantaf
|
<input type="text" class="uk-input text-input-box uk-width-xlarge@l uk-width-large@m uk-width-medium"
|
15 |
58377
|
argiro.kok
|
[placeholder]="placeholderText" aria-describedby="sizing-addon2"
|
16 |
|
|
[(ngModel)]="keyword" name="keyword">
|
17 |
|
|
</div>
|
18 |
56276
|
k.triantaf
|
<button *ngIf="!link" (click)="keywordChanged()" type="submit" class=" uk-button portal-button uk-margin-small-left">
|
19 |
58377
|
argiro.kok
|
Search
|
20 |
56276
|
k.triantaf
|
</button>
|
21 |
|
|
<button *ngIf="link" (click)="goTo()" type="submit" class="uk-button portal-button uk-padding uk-padding-remove-vertical uk-margin-small-left">
|
22 |
58377
|
argiro.kok
|
Search
|
23 |
56276
|
k.triantaf
|
</button>
|
24 |
50169
|
argiro.kok
|
</form>
|
25 |
|
|
`
|
26 |
|
|
})
|
27 |
|
|
|
28 |
|
|
export class SearchFormComponent {
|
29 |
|
|
@Input() isDisabled: boolean = false;
|
30 |
|
|
@Input() keyword: string = '';
|
31 |
|
|
@Input() generalSearch: boolean = false;
|
32 |
|
|
@Input() placeholderText: string = "Type keywords";
|
33 |
55220
|
konstantin
|
@Input() link: string = "";
|
34 |
55270
|
argiro.kok
|
@Input() setFormCentered: boolean = true;
|
35 |
50169
|
argiro.kok
|
public routerHelper:RouterHelper = new RouterHelper();
|
36 |
|
|
|
37 |
|
|
@Output() keywordChange = new EventEmitter();
|
38 |
|
|
|
39 |
|
|
constructor (private _router:Router) {
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
ngOnInit() {
|
43 |
|
|
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
keywordChanged() {
|
47 |
54775
|
konstantin
|
//console.info("inside form: "+this.keyword);
|
48 |
50169
|
argiro.kok
|
this.keywordChange.emit({
|
49 |
|
|
value: this.keyword
|
50 |
|
|
});
|
51 |
|
|
}
|
52 |
|
|
goTo() {
|
53 |
55220
|
konstantin
|
//this._router.navigate(['/search/find'], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
54 |
|
|
this._router.navigate([this.link], { queryParams: this.routerHelper.createQueryParam('keyword',this.keyword) });
|
55 |
50169
|
argiro.kok
|
}
|
56 |
|
|
}
|