Revision 57708
Added by Konstantinos Triantafyllou over 4 years ago
input.component.ts | ||
---|---|---|
1 | 1 |
import {Component, Input, OnDestroy, OnInit} from "@angular/core"; |
2 | 2 |
import {Option} from "../../../utils/indicator-utils"; |
3 |
import {AbstractControl, FormControl} from "@angular/forms"; |
|
4 | 3 |
|
5 | 4 |
@Component({ |
6 | 5 |
selector: '[dashboard-input]', |
... | ... | |
9 | 8 |
<input *ngIf="type === 'text'" matInput [placeholder]="label" |
10 | 9 |
[formControl]="formControl" [required]="required"> |
11 | 10 |
<textarea *ngIf="type === 'textarea'" [rows]="rows" matInput [placeholder]="label" [formControl]="formControl"></textarea> |
12 |
<mat-select *ngIf="type === 'select'" [placeholder]="label" [formControl]="formControl" [disableOptionCentering]="true"> |
|
11 |
<mat-select *ngIf="type === 'select'" [placeholder]="label" (openedChange)="stopPropagation()" |
|
12 |
[formControl]="formControl" [disableOptionCentering]="true"> |
|
13 | 13 |
<mat-option *ngFor="let option of options" [value]="option.value"> |
14 | 14 |
{{option.label}} |
15 | 15 |
</mat-option> |
... | ... | |
18 | 18 |
` |
19 | 19 |
}) |
20 | 20 |
export class InputComponent implements OnInit, OnDestroy { |
21 |
@Input('formInput') formControl: FormControl;
|
|
21 |
@Input('formInput') formControl: any;
|
|
22 | 22 |
@Input('type') type: string = 'text'; |
23 | 23 |
@Input('label') label: string; |
24 | 24 |
@Input('rows') rows: number = 3; |
... | ... | |
38 | 38 |
&& this.formControl.validator(this.formControl) |
39 | 39 |
&& this.formControl.validator(this.formControl).required; |
40 | 40 |
} |
41 |
|
|
42 |
stopPropagation() { |
|
43 |
if(event) { |
|
44 |
event.stopPropagation(); |
|
45 |
} |
|
46 |
} |
|
41 | 47 |
} |
Also available in: Unified diff
[Monitor-Dashboard]: Rename home -> stakeholder. Add custom classes to chart Icons