Skip to content

Commit 130f2f9

Browse files
committed
feat(controls): Added number control support
1 parent 4e8252a commit 130f2f9

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

frontend/src/app/controls/base/booleanControl/booleanControl.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { FormGroup, FormControl } from '@angular/forms';
1010
styles: [``],
1111
template: `
1212
<div [formGroup]="inputGroup">
13-
<label>{{label}}</label>
14-
<select formControlName="item" [(ngModel)]="value">
13+
<label for="BooleanSelect">{{label}}</label>
14+
<select id="BooleanSelect" formControlName="item" [(ngModel)]="value">
1515
<option [ngValue]="true">True</option>
1616
<option [ngValue]="false">False</option>
1717
</select>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Angular 2 decorators and services
3+
*/
4+
import { Component, Input } from '@angular/core';
5+
import { FormGroup } from '@angular/forms';
6+
7+
@Component({
8+
// The selector is what angular internally uses
9+
selector: 'cb-number-control',
10+
styles: [``],
11+
template: `
12+
<div [formGroup]="inputGroup">
13+
<label for="numberElement">{{label}}</label>
14+
<input id="numberElement" type="number" [(ngModel)]="value" formControlName="item" required/>
15+
</div>
16+
`,
17+
})
18+
export class NumberControlComponent {
19+
@Input() label: string;
20+
@Input() value: string;
21+
@Input() inputGroup: FormGroup;
22+
23+
constructor() { }
24+
25+
ngOnInit() {}
26+
}

frontend/src/app/controls/base/stringControl/stringControl.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { FormGroup } from '@angular/forms';
1010
styles: [``],
1111
template: `
1212
<div [formGroup]="inputGroup">
13-
<label>{{label}}</label>
14-
<input type="text" [(ngModel)]="value" formControlName="item" />
13+
<label for="stringElement">{{label}}</label>
14+
<input id="stringElement" type="text" [(ngModel)]="value" formControlName="item" />
1515
</div>
1616
`,
1717
})

frontend/src/app/controls/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { StringControlComponent } from './base/stringControl/stringControl.component.ts';
22
import { BooleanControlComponent } from './base/booleanControl/booleanControl.component.ts';
3+
import { NumberControlComponent } from './base/numberControl/numberControl.component.ts';
34

45
export const defaultControls = {
56
// Basic
@@ -11,6 +12,10 @@ export const defaultControls = {
1112
control: BooleanControlComponent,
1213
nested: false,
1314
},
15+
number: {
16+
control: NumberControlComponent,
17+
nested: false,
18+
},
1419
};
1520

1621
export { ControlsModule } from './controls.module.ts';

0 commit comments

Comments
 (0)