Skip to content
This repository was archived by the owner on Aug 25, 2020. It is now read-only.

Commit a1b2b95

Browse files
authored
Merge pull request #99 from LabShare/adev
formGroup renamed to group
2 parents fbd34c0 + 615d475 commit a1b2b95

File tree

9 files changed

+24
-23
lines changed

9 files changed

+24
-23
lines changed

dist/ngx-forms.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dynamic-form/dynamic-form.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ describe('DynamicFormDirective', () => {
8282

8383

8484
it('should call changes()', () => {
85-
expect(dir.changes).toEqual(dir.formGroup.valueChanges);
85+
expect(dir.changes).toEqual(dir.group.valueChanges);
8686
});
8787

8888
it('should call valid()', () => {
89-
expect(dir.valid).toEqual(dir.formGroup.valid);
89+
expect(dir.valid).toEqual(dir.group.valid);
9090
});
9191

9292
it('should call value()', () => {
93-
expect(dir.value).toEqual(dir.formGroup.value);
93+
expect(dir.value).toEqual(dir.group.value);
9494
});
9595

9696
it('should call value()', () => {
97-
expect(dir.rawValue).toEqual(dir.formGroup.getRawValue());
97+
expect(dir.rawValue).toEqual(dir.group.getRawValue());
9898
});
9999

100100
});

src/app/dynamic-form/dynamic-form.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ export class DynamicFormDirective implements OnInit {
1111
@Input() model: any;
1212
@Input() lookups: object;
1313

14-
public formGroup: FormGroup;
15-
get changes() { return this.formGroup.valueChanges; }
16-
get valid() { return this.formGroup.valid; }
17-
get value() { return this.formGroup.value; }
18-
get rawValue() { return this.formGroup.getRawValue(); }
14+
public group: FormGroup;
15+
get changes() { return this.group.valueChanges; }
16+
get valid() { return this.group.valid; }
17+
get value() { return this.group.value; }
18+
get rawValue() { return this.group.getRawValue(); }
1919

2020
constructor(
2121
private componentFactoryResolver: ComponentFactoryResolver,
2222
private container: ViewContainerRef,
2323
@Inject(LAYOUTS_TOKEN) private layouts: LayoutDictionary) {
24-
this.formGroup = new FormGroup({});
24+
this.group = new FormGroup({});
2525
}
2626

2727
public ngOnInit(): void {
@@ -31,7 +31,7 @@ export class DynamicFormDirective implements OnInit {
3131
const componentReference = this.layouts[this.formConfig.layout];
3232
const componentFactory = this.componentFactoryResolver.resolveComponentFactory<Layout>(componentReference);
3333
const component = this.container.createComponent(componentFactory);
34-
component.instance.formGroup = this.formGroup;
34+
component.instance.group = this.group;
3535
component.instance.formConfig = this.formConfig;
3636
component.instance.model = this.model;
3737
}

src/app/layouts/base-layout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export class BaseLayout implements Layout {
66
@Input() formConfig: FormConfig;
77
@Input() model: any;
88
@Input() lookups: object;
9-
@Input() formGroup: FormGroup;
9+
@Input() group: FormGroup;
1010
}

src/app/layouts/basic/basic-layout.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2>{{formConfig.title}}</h2>
1010
</label>
1111

1212
<div class="col-md-10">
13-
<div dynamicField [field]="field" [group]="formGroup" [model]="model"></div>
13+
<div dynamicField [field]="field" [group]="group" [model]="model"></div>
1414
</div>
1515

1616
</div>

src/app/layouts/basic/basic-layout.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('BasicLayoutComponent Core', () => {
5353
beforeEach(() => {
5454
fixture = TestBed.createComponent(BasicLayoutComponent);
5555
component = fixture.componentInstance;
56-
component.formGroup = new FormGroup({})
56+
component.group = new FormGroup({})
5757
component.formConfig = {
5858
form: [
5959
{ label: 'fields and panels', panels: [{ label: 'fields', fields: [{ type: 'text', name: 'title', required: true }] }] },
@@ -69,7 +69,7 @@ describe('BasicLayoutComponent Core', () => {
6969
describe('ngOnInit()', () => {
7070

7171
it('should create group', () => {
72-
expect(component.formGroup).toBeDefined();
72+
expect(component.group).toBeDefined();
7373
});
7474

7575
});

src/app/layouts/groups/group/group.component.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<div class="row">
22
<div class="col-md-2">
3-
<form-nav [form]="formGroup"></form-nav>
3+
<form-nav [form]="group"></form-nav>
44
</div>
5-
<div class="col-md-10" [formGroup]="formGroup">
5+
<div class="col-md-10" [formGroup]="group">
66
<div *ngFor="let panel of formConfig.form" [navTab]="panel">
77

88
<ng-container *ngIf="panel.fields">
9-
<layout-group-panel [panelConfig]="panel" [group]="formGroup" [model]="model" [hidden]="panel.hidden"></layout-group-panel>
9+
<layout-group-panel [panelConfig]="panel" [group]="group" [model]="model" [hidden]="panel.hidden">
10+
</layout-group-panel>
1011
</ng-container>
1112

1213
<ng-container *ngIf="panel.panels">
13-
<layout-group-panel *ngFor="let panelConfig of panel.panels" [panelConfig]="panelConfig" [group]="formGroup"
14+
<layout-group-panel *ngFor="let panelConfig of panel.panels" [panelConfig]="panelConfig" [group]="group"
1415
[model]="model" [hidden]="panel.hidden"></layout-group-panel>
1516
</ng-container>
1617
</div>

src/app/layouts/groups/group/group.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('GroupComponent Core', () => {
111111
beforeEach(() => {
112112
fixture = TestBed.createComponent(GroupComponent);
113113
component = fixture.componentInstance;
114-
component.formGroup = new FormGroup({})
114+
component.group = new FormGroup({})
115115
component.formConfig = {
116116
form: [
117117
{ label: 'fields and panels', panels: [{ label: 'fields', fields: [{ type: 'text', name: 'title', required: true }] }] },
@@ -127,7 +127,7 @@ describe('GroupComponent Core', () => {
127127
describe('ngOnInit()', () => {
128128

129129
it('should create group', () => {
130-
expect(component.formGroup).toBeDefined();
130+
expect(component.group).toBeDefined();
131131
});
132132

133133
describe('Lookup Expansion', () => {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const FIELD_DICT_TOKEN = new InjectionToken<FieldDictionary>('fields');
4545
export const LAYOUTS_TOKEN = new InjectionToken<Layout>('layouts');
4646

4747
export interface Layout {
48-
formGroup: FormGroup;
48+
group: FormGroup;
4949
formConfig: any;
5050
model: any;
5151
}

0 commit comments

Comments
 (0)