Project

General

Profile

1
import {Component, Input, Output, EventEmitter} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {RouterHelper} from '../../utils/routerHelper.class';
4

    
5
@Component({
6
    selector: 'search-form',
7
    template: `
8

    
9
        <form [class]="(isDisabled)?'uk-margin uk-text-center uk-margin-top uk-disabled':'uk-margin uk-text-center uk-margin-top'">
10
                 <input type="text" class="uk-input  uk-width-1-2" [placeholder]="placeholderText" aria-describedby="sizing-addon2"  [(ngModel)]="keyword"  name="keyword" >
11
                    <button *ngIf="!link" (click)="keywordChanged()"  type="submit" class=" uk-button uk-button-default">
12
                    <span class="uk-icon">
13
                    <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1"><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>
14
                    </span>Search
15
                  </button>
16
                  <a *ngIf="link"  class=" uk-button uk-button-default" [queryParams]="routerHelper.createQueryParam('keyword',keyword)" routerLinkActive="router-link-active" routerLink="/search/find">
17
                    <span class="uk-icon">
18
                    <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1"><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>
19
                    </span>Search
20
                  </a>
21

    
22

    
23
        </form>
24

    
25

    
26
    `
27
})
28

    
29
export class SearchFormComponent {
30
    @Input() isDisabled: boolean = false;
31
    @Input() keyword: string = '';
32
    @Input() generalSearch: boolean = false;
33
    @Input() placeholderText: string = "Type keywords";
34
    @Input() link: boolean = false;
35
    public routerHelper:RouterHelper = new RouterHelper();
36

    
37
    @Output() keywordChange  = new EventEmitter();
38

    
39
    constructor () {
40
     }
41

    
42
    ngOnInit() {
43

    
44
    }
45

    
46
    keywordChanged() {
47
        console.info("inside form: "+this.keyword);
48
        this.keywordChange.emit({
49
            value: this.keyword
50
        });
51
    }
52
}
(15-15/28)