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

Commit 65cdff0

Browse files
authored
Merge pull request #72 from LabShare/bigfixes
fix: fixed checkbox input control
2 parents fceed4e + 15696dc commit 65cdff0

13 files changed

+16
-26
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.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"@angular/platform-browser-dynamic": "^6.0.4",
2727
"bootstrap": "^4.0.0",
2828
"core-js": "^2.4.1",
29-
"lodash": "4.17.10",
3029
"ngx-chips": "^1.9.1",
3130
"ngx-quill": "^3.1.0",
3231
"quill": "^1.3.4",
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<div class="row" [formGroup]="group">
2-
<label class="col-md-2 font-weight-bold col-form-label">{{ field.label }}
2+
<label class="col-md-2 font-weight-bold col-form-label">{{field.label}}
33
<span class="required-icon" [hidden]="!field.required">*</span>
44
</label>
55
<div class="col-md-10">
6-
<div class="row" *ngFor="let item of field.options">
7-
<label class="col-md-6"><input type="checkbox" [formControlName]="field.name">{{ item }}</label>
8-
</div>
6+
<input type="text" class="form-control" [attr.placeholder]="field.placeholder" [formControlName]="field.name">
97
</div>
10-
</div>
8+
</div>

src/app/components/form-checkbox/form-checkbox.component.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { FormCheckboxComponent as Type } from './form-checkbox.component';
2+
import { FormCheckboxComponent as Type} from './form-checkbox.component';
33
import { ReactiveFormsModule, FormsModule, FormGroup, FormControl } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
55
import { By } from '@angular/platform-browser';
@@ -8,7 +8,7 @@ describe('FormCheckboxComponent', () => {
88
let component: Type;
99
let fixture: ComponentFixture<Type>;
1010
let directiveEl;
11-
let value = "bbb";
11+
let value = true;
1212

1313
beforeEach(async(() => {
1414
TestBed.configureTestingModule({
@@ -25,15 +25,14 @@ describe('FormCheckboxComponent', () => {
2525
fixture = TestBed.createComponent(Type);
2626
component = fixture.componentInstance;
2727

28-
component.field = { type: "checkbox", name: "test", required: true, options: ['aaa', 'bbb', 'ccc'] };
28+
component.field = { type: "text", name: "test", required: true };
2929
component.group = new FormGroup({
3030
test: new FormControl('')
3131
});
3232
component.group.patchValue({
3333
test: value
3434
});
3535

36-
3736
fixture.detectChanges();
3837
});
3938
}));
@@ -43,8 +42,8 @@ describe('FormCheckboxComponent', () => {
4342
});
4443

4544
it('ensures component is rendered', () => {
46-
directiveEl = fixture.debugElement.queryAll(By.css('input'));
47-
expect(directiveEl.length).toEqual(component.field.options.length);
45+
directiveEl = fixture.debugElement.query(By.css('input'));
46+
expect(directiveEl.nativeElement.value.toString()).toEqual(value.toString());
4847
});
4948

5049
it('ensures required asterix appears', () => {

src/app/components/form-checkbox/form-checkbox.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Component } from '@angular/core';
2-
import { Field } from '../../models/field.interface';
32
import { FormGroup } from '@angular/forms';
3+
import { Field } from '../../models/field.interface';
44
import { IFieldConfig } from '../../models/field-config.interface';
55

66
@Component({
77
selector: 'form-checkbox',
88
template: require('./form-checkbox.component.html')
99
})
10-
11-
export class FormCheckboxComponent implements Field {
10+
export class FormCheckboxComponent implements Field {
1211
field: IFieldConfig;
1312
group: FormGroup;
1413
model: object;

src/app/components/form-hidden/form-hidden.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormInputHiddenComponent } from './form-hidden.component';
33
import { ReactiveFormsModule, FormsModule, FormBuilder, FormGroup, FormControl } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
5-
import * as _ from 'lodash';
65
import { By } from '@angular/platform-browser';
76

87
describe('FormInputHiddenComponent', () => {

src/app/components/form-input/form-input.component.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormInputComponent as Type} from './form-input.component';
3-
import { ReactiveFormsModule, FormsModule, FormBuilder, FormGroup, FormControl } from '@angular/forms';
3+
import { ReactiveFormsModule, FormsModule, FormGroup, FormControl } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
5-
import * as _ from 'lodash';
65
import { By } from '@angular/platform-browser';
76

87
describe('FormInputComponent', () => {
98
let component: Type;
109
let fixture: ComponentFixture<Type>;
11-
const formBuilder: FormBuilder = new FormBuilder();
1210
let directiveEl;
1311
let value = "Some Test Value";
1412

@@ -35,7 +33,6 @@ describe('FormInputComponent', () => {
3533
test: value
3634
});
3735

38-
3936
fixture.detectChanges();
4037
});
4138
}));

src/app/components/form-label/form-label.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormLabelComponent as Type } from './form-label.component';
33
import { ReactiveFormsModule, FormsModule, FormBuilder, FormGroup, FormControl } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
5-
import * as _ from 'lodash';
65
import { By } from '@angular/platform-browser';
76

87
describe('FormInputHiddenComponent', () => {

src/app/components/form-radio/form-radio.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormRadioComponent } from './form-radio.component';
33
import { ReactiveFormsModule, FormsModule, FormBuilder } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
5-
import * as _ from 'lodash';
65

76
describe('FormRadioComponent', () => {
87
let component: FormRadioComponent;

src/app/components/form-radio/form-radio.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Component } from '@angular/core';
22
import {Field} from '../../models/field.interface';
33
import { FormGroup } from '@angular/forms';
44
import { IFieldConfig } from '../../models/field-config.interface';
5-
import * as _ from 'lodash';
65

76
@Component({
87
selector: 'form-radio',

src/app/components/form-text-editor/form-text-editor.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { FormTextEditorComponent } from './form-text-editor.component';
33
import { ReactiveFormsModule, FormsModule, FormBuilder } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
55
import { QuillModule } from "ngx-quill";
6-
import * as _ from 'lodash';
76

87
describe('FormTextEditorComponent', () => {
98
let component: FormTextEditorComponent;

src/app/components/form-textarea/form-textarea.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormTextareaComponent } from "./form-textarea.component";
33
import { ReactiveFormsModule, FormsModule, FormBuilder } from '@angular/forms';
44
import { APP_BASE_HREF } from '@angular/common';
5-
import * as _ from 'lodash';
65

76
describe('FormTextareaComponent', () => {
87
let component: FormTextareaComponent;

src/nav/form-nav.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export class FormNavService {
2121
}
2222

2323
reset() {
24+
this.groups.forEach((group) => {
25+
group.hidden = false;
26+
});
2427
this.groups = [];
28+
this.selected = 0;
2529
}
2630

2731
addWatcher(ref: { groups: any[]; }): any {

0 commit comments

Comments
 (0)