diff --git a/ng6-seed/package-lock.json b/ng6-seed/package-lock.json index 2e4cd6022..e076f93e2 100755 --- a/ng6-seed/package-lock.json +++ b/ng6-seed/package-lock.json @@ -2002,7 +2002,7 @@ }, "sax": { "version": "1.2.1", - "resolved": "http://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=", "dev": true }, @@ -2483,7 +2483,7 @@ }, "buffer": { "version": "4.9.1", - "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "requires": { "base64-js": "^1.0.2", @@ -2618,7 +2618,7 @@ }, "calendar-utils": { "version": "0.1.2", - "resolved": "http://registry.npmjs.org/calendar-utils/-/calendar-utils-0.1.2.tgz", + "resolved": "https://registry.npmjs.org/calendar-utils/-/calendar-utils-0.1.2.tgz", "integrity": "sha512-9j4Zd1itopNYTSWzFU4MqD2IDHMqznfxsGr8UWGh7hWv+lKzjRJz0LS29iAg5rHtP6+6x3ikQnhoMGqFUzoD2Q==" }, "caller-callsite": { @@ -7686,7 +7686,7 @@ }, "lodash": { "version": "3.10.1", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", "dev": true }, @@ -7874,7 +7874,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "requires": { "graceful-fs": "^4.1.2", @@ -7967,7 +7967,7 @@ }, "log4js": { "version": "0.6.38", - "resolved": "http://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=", "dev": true, "requires": { @@ -8261,7 +8261,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "requires": { "camelcase-keys": "^2.0.0", @@ -8390,7 +8390,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { @@ -8479,7 +8479,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -8487,7 +8487,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } @@ -8949,7 +8949,7 @@ "dependencies": { "semver": { "version": "5.3.0", - "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" } } @@ -9391,7 +9391,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, @@ -9450,7 +9450,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "requires": { "lcid": "^1.0.0" @@ -11964,7 +11964,7 @@ }, "sax": { "version": "0.5.8", - "resolved": "http://registry.npmjs.org/sax/-/sax-0.5.8.tgz", + "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz", "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=", "dev": true }, @@ -12878,7 +12878,7 @@ }, "sax": { "version": "0.6.1", - "resolved": "http://registry.npmjs.org/sax/-/sax-0.6.1.tgz", + "resolved": "https://registry.npmjs.org/sax/-/sax-0.6.1.tgz", "integrity": "sha1-VjsZx8HeiS4Jv8Ty/DDjwn8JUrk=", "dev": true }, @@ -13415,7 +13415,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { "string-width": "^1.0.1", diff --git a/ng6-seed/src/app/layouts/admin/admin-layout.component.html b/ng6-seed/src/app/layouts/admin/admin-layout.component.html index 6c35804ad..4dec3576a 100755 --- a/ng6-seed/src/app/layouts/admin/admin-layout.component.html +++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.html @@ -8,7 +8,8 @@

{{userDep}}

--> -

{{userDep}} +

+

diff --git a/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts b/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts index 0e4be33ea..014a94812 100755 --- a/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts +++ b/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts @@ -18,7 +18,9 @@ export class HttpLoaderComponent implements OnInit { ngOnInit() { this.subscription = this.loaderService.loaderState .subscribe((state: LoaderState) => { + setTimeout(()=>{ this.show = state.show; + }) }); } ngOnDestroy() { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html index 411a7839b..9fce4cc0c 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html @@ -160,10 +160,10 @@ matTooltip="View" matTooltipPosition="above"> visibility - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html index 31e9bb1ca..9f3613c18 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html @@ -134,10 +134,10 @@ - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html index c8743dfcc..db445fae7 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html @@ -127,10 +127,10 @@ sms --> - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html index bc1559c49..041328727 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html @@ -132,10 +132,10 @@ --> - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html index 87413452a..5452d3954 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html @@ -132,10 +132,10 @@ --> - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html index 18003f29e..d80399894 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html @@ -92,6 +92,10 @@ Pincode Required + + Pincode should be 6 digit @@ -258,7 +262,7 @@ + *ngIf="addressForm.controls['locality'].value == 1 && addressForm.controls['locality_others']"> diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts index b3e357167..f53270bf4 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts @@ -420,6 +420,7 @@ export class AddressComponent implements OnInit { e == 1 ? this.addressForm.addControl('address_type_others', new FormControl('', Validators.required)) : this.addressForm.removeControl('address_type_others'); break; case 4: + console.log("value",e ); e == 1 ? this.addressForm.addControl('locality_others', new FormControl('', Validators.required)) : this.addressForm.removeControl('locality_others'); break; case 5: @@ -534,12 +535,24 @@ export class AddressComponent implements OnInit { }); } + public findInvalidControls() { + const invalid = []; + const controls = this.addressForm.controls; + for (const name in controls) { + if (controls[name].invalid) { + invalid.push(name); + } + } + return invalid; + } onSubmit() { if (!this.addressForm.valid) { this.validateAllFormFields(this.addressForm); this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); this.disableAfterSubmit = false; + let inavalidCtrls = this.findInvalidControls(); + console.log(inavalidCtrls) return; } // else if (this.addressForm.value.address_form_remark == '') { @@ -881,9 +894,85 @@ export class AddressComponent implements OnInit { this._pd.getVendorDatas('address',this.pdid).subscribe(result=>{ if(result) { + let initiated_address_check =result.records.hasOwnProperty('is_pd_done_on_initiated_address') ? result.records.is_pd_done_on_initiated_address : true ; + if (initiated_address_check == false) { + + this.addressForm.addControl('alternative_addresses', this.fb.array([])); + const alternative_address_control = this.addressForm.controls['alternative_addresses']; + if (result.records.alternative_addresses.length > 0) { + + result.records.alternative_addresses.forEach((datas, index) => { + + if (datas.citySearch == "" || datas.citySearch == null){ + delete datas.citySearch; + } + if (datas.pinSearch == "" || datas.pinSearch == null){ + delete datas.pinSearch; + } + if (datas.stateSearch == "" || datas.stateSearch == null){ + delete datas.stateSearch; + } + + let obj = { + 'alternative_address': this.transformName(datas.alternative_address), + 'alternative_state': datas.alternative_state, + 'alternative_city': datas.alternative_city, + 'alternative_pincode': datas.alternative_pincode, + // 'alternative_pincode_others': datas.alternative_pincode == 1 ? datas.alternative_pincode_others : '', + 'reason_for_alternative_address': datas.reason_for_alternative_address, + } + this.getCityAndPincodeDetails(datas.alternative_state, index, 2); + if(alternative_address_control.length == 1) { + alternative_address_control.removeAt(0); + } + alternative_address_control.push(this.createAlternativeAddresses(obj)); + this.setOthers(+datas.alternative_pincode, index, 2); + if(datas.alternative_pincode == 1) { + let AltCtrl: any = alternative_address_control.controls[index]; + AltCtrl.controls['alternative_pincode_others'].setValue(datas.alternative_pincode_others); + AltCtrl.controls['alternative_pincode_others'].updateValueAndValidity(); + } + + this.addressForm.controls.pd_location.setValue(result.records.pd_location); + this.addressForm.controls.address_type.setValue(result.records.address_type); + + let selectedAddressType = this.addressData.filter(element => element.address_type_id == result.records.address_type)[0]; + if(selectedAddressType != undefined && selectedAddressType.hasOwnProperty('address_type')){ + this.selectedAddressType(selectedAddressType.address_type); + } + + this.setOthers(result.records.address_type, '', 3); + + if (result.records.address_type == 1) { + this.addressForm.controls.address_type_others.setValue(result.records.address_type_others); + this.selectedAddressType(result.records.address_type_others); + } + + this.addressForm.controls.comment_locality.setValue(result.records.comment_locality); + + this.addressForm.controls.locality.setValue(result.records.locality); + this.setOthers(result.records.locality, '', 4); + + if (result.records.locality == 1) { + this.addressForm.controls.locality_others.setValue(result.records.locality_others); + } + + if(this.lender_short_name != 'CLIX' && this.prod_catagory != 'BL'){ + this.addressForm.controls.estimated_area.setValue(result.records.estimated_area); + this.addressForm.controls.uom.setValue(result.records.uom); + this.setOthers(result.records.uom, '', 5); + if (result.records.uom == 1) { + this.addressForm.controls.uom_others.setValue(result.records.uom_others); + } + } + }); + } + } + setTimeout(() =>{ this.addressForm.patchValue(result.records); + },1000) // console.log(this.addressForm.value,this.commentData,this.locationdata); - // console.log(this.a.value) + console.log(this.addressForm.value) } }) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.html new file mode 100644 index 000000000..c0f51dc66 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.html @@ -0,0 +1,69 @@ +
+ +
+ + + + + + + +
+ +
+
+ +
+ + + + + + + {{parent_ques.group_title}} {{g_i+1}} + + + +
+ +
+
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.spec.ts new file mode 100644 index 000000000..ad74d0cb1 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { DynamicFormComponent } from './dynamic-form.component'; + +describe('DynamicFormComponent', () => { + let component: DynamicFormComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DynamicFormComponent ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(DynamicFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts new file mode 100644 index 000000000..51d62390b --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts @@ -0,0 +1,68 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { FormGroup, FormBuilder, FormArray } from '@angular/forms'; +import { QuesFormService } from '../ques-form/ques-form.service'; + + +@Component({ + selector: 'app-dynamic-form', + templateUrl: './dynamic-form.component.html', + styleUrls: ['./dynamic-form.component.scss'], +}) +export class DynamicFormComponent implements OnInit { + // form_group_name: FormGroup; + @Input() form_group_name:FormGroup; + @Input() questions_JSON:any; + @Input() json_answers:any; + step: number=0; + constructor(private _fb:FormBuilder,private questionService:QuesFormService) { } + + ngOnInit() { + // this.form_group_name=new FormGroup({questions:this._fb.array([])}) + console.log(this.questions_JSON,this.json_answers,this.questionService); + this.form_group_name=this.questionService.assignFormControl_array(this.form_group_name,this.questions_JSON.questions) + // debugger + } + ngOnChanges() { + console.log(this.questions_JSON,this.json_answers,this.questionService); + // this.form_group_name=new FormGroup({questions:this._fb.array([])}) + + console.log(this.form_group_name); + // this.form_group_name.valueChanges.subscribe(()=>{ + // this.form_group_name.updateValueAndValidity(); + // }) + // debugger; + // this.form_group_name.patchValue(this.json_answers) + } + addData(index,json_obj) { + let control_names:any= {} + let control = this.form_group_name.get(json_obj.group_key) as FormArray + json_obj.question.map(val=>{ + control_names[val.question_key] = '' + }) + console.log(control,json_obj.group_key,control_names); + json_obj.group_questions.push(json_obj.question); + control.push(this._fb.group(control_names)) + + json_obj.question.forEach((group_indi,arr_index)=>{ + // console.log("sd",childControl) + this.questionService.addAdditionalControl(group_indi, control.controls[control.length-1], arr_index) + }) + json_obj.question = JSON.parse(JSON.stringify(json_obj.question)) + control.updateValueAndValidity(); + control.controls[control.length-1].updateValueAndValidity(); + this.form_group_name.updateValueAndValidity(); + this.step = control.length-1 + console.log(this.form_group_name.value); + } + + removeData(index,json_obj) { + console.log(json_obj) + // debugger; + let control = this.form_group_name.get(json_obj.group_key) as FormArray + control.removeAt(index) + json_obj.group_questions.splice(index,1) + this.step = control.length-1 + console.log(json_obj) + } + +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html new file mode 100644 index 000000000..176fd02f3 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html @@ -0,0 +1,184 @@ +
+ + + + {{parent_ques.question}} + + + {{"₹"}} {{formGroupN.value[parent_ques.question_key] | numberToWords}} + + + + + {{validation.message}} + + + + + {{parent_ques.question}} + + + + {{val.answer}} + + + {{"₹"}} {{formGroupN.value[parent_ques.question_key] | numberToWords}} + + + + + {{validation.message}} + + + + +
+ {{parent_ques.question}}
+ + {{val.answer}}
+
+ + + {{validation.message}} + +
+ + + {{parent_ques.question}} + + {{val.answer}} + + + + {{validation.message}} + + + + + + + {{parent_ques.question}} + + {{val.answer}} + + + + + {{validation.message}} + + + + + + + {{parent_ques.question}} + + + + + {{validation.message}} + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.scss new file mode 100644 index 000000000..eec25d91c --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.scss @@ -0,0 +1,34 @@ +mat-radio-button,mat-checkbox{ + margin-top: 13px; +} +mat-form-field { + width: 100%; +} +.radio-gap{ + margin-top: 10px; + margin-bottom: 10px; +} +.radio-btn-gap{ + margin:10px; +} + +::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle{ + border-color:rgb(212, 15, 15); + } + + ::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle{ + color:rgb(212, 15, 15); + background-color:rgb(212, 15, 15); + } + + ::ng-deep .mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { + background-color:rgba(224, 22, 22, 0.308); + } + input{ + // width: 100px; + // border-radius: 4px; + // border-color: gray; + // font-size: 12px; + height: 28px; + + } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.spec.ts new file mode 100644 index 000000000..2fbd70c50 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { DynamicQuestionTemplateComponent } from './dynamic-question-template.component'; + +describe('DynamicQuestionTemplateComponent', () => { + let component: DynamicQuestionTemplateComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DynamicQuestionTemplateComponent ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(DynamicQuestionTemplateComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts new file mode 100644 index 000000000..099848b76 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts @@ -0,0 +1,417 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { FormGroup, FormArray, FormControl } from '@angular/forms'; +import { QuesFormService } from '../ques-form/ques-form.service'; +import { startWith, map } from 'rxjs/operators'; +import { Observable } from 'rxjs'; + +@Component({ + selector: 'app-dynamic-question-template', + templateUrl: './dynamic-question-template.component.html', + styleUrls: ['./dynamic-question-template.component.scss'], +}) +export class DynamicQuestionTemplateComponent implements OnInit { + @Input() formGroupN : FormGroup; + @Input() currFormArrayObj; + parent_ques: any; + fileredSearchValue: any=[]; + @Input() whole_json:any; + @Input() json_index:any; + @Input() whole_form:FormGroup; + @Input() json_answers:any; + local_city: any; + local_pincode: any; + autoCompleteAns:Observable + constructor(private quesService:QuesFormService) { } + + ngOnInit() { + if(this.parent_ques.type == '9' && this.parent_ques.answers && this.parent_ques.answers.length > 0) { + this.autoCompleteAns =this.formGroupN.get(this.parent_ques.question_key).valueChanges.pipe( + startWith(''), + map(value => this.autoCompleteFilter(value)) + ) + } + } + + ngOnChanges() { + this.parent_ques = this.currFormArrayObj + console.log(this.parent_ques,this.formGroupN); + if(this.json_answers!=null && this.json_answers != undefined && this.json_answers) { + console.log("ddddddddddddddd",this.json_answers[this.parent_ques.question_key],this.parent_ques) + setTimeout(()=>{ + this.formGroupN.get(this.parent_ques.question_key).patchValue((this.json_answers[this.parent_ques.question_key] || '')) + this.onChangeProperty({value:this.json_answers[this.parent_ques.question_key]},this.parent_ques,'') + }) + // this.formGroupN.get(this.parent_ques.question_key).patchValue(this.json_answers[this.parent_ques.question_key]) + // this.onChangeProperty({value:this.json_answers[this.parent_ques.question_key]},this.parent_ques,'') + setTimeout(()=>{ + this.json_answers = null + },700) + } + } + autoCompleteFilter(value:string): string[] { + if(value) { + const filterValue = value.toLowerCase(); + + return this.parent_ques.answers.filter(option => option.answer.toLowerCase().indexOf(filterValue) === 0); + } + else { + return this.parent_ques.answers + } + } + onChange_checkbox(event,sec_control){ + console.log(event,sec_control) + const control=this.formGroupN.get(sec_control.question_key) as FormArray + + if(event.checked) { + control.push(new FormControl(event.source.value)) + } else { + const i = control.controls.findIndex(x => x.value === event.source.value); + control.removeAt(i); + } + } + onChangeProperty(event,sec_control,question_key,options?,sec_index?){ + this.fileredSearchValue=[] + + if( sec_control.answers!= null && sec_control.answers.length > 0){ + // this.creatSubField(sec_control,event.value) + } + //FOR API CALLS + // console.log(sec_control.value); + if(sec_control.onchange_properties != null && sec_control.onchange_properties.length >0){ + + let onChangeProperties_value=sec_control.onchange_properties + +// let new_name=`{ +// "purpose":"FORM_CTRL", +// "form_controls":[ +// { +// "insert_index":"total_work_exp", +// "expression":"(total_work_exp > vintage_in_current_biz)", +// "value_keys":[ +// "total_work_exp", +// "vintage_in_current_biz"], +// "questions":[ +// { +// "question_key":"previous_experience_details2", +// "question":"Previous Experience2", +// "type":"1", +// "api_properties":null, +// "answers":null, +// "onchange_properties":null, +// "is_repeatable":null, +// "field_type":"string", +// "validations":[{ +// "isactive": "1", +// "message": "Name Required", +// "name": "required", +// "validator": "Validators.required", +// "value": null +// }] + +// }] + +// }, +// { +// "insert_index":"vintage_in_current_biz", +// "expression":"(total_work_exp > vintage_in_current_biz)", +// "value_keys":[ +// "total_work_exp", +// "vintage_in_current_biz"], +// "questions":[{ +// "question_key":"vintage1", +// "question":"Vintage check", +// "type":"1", +// "api_properties":null, +// "answers":null, +// "onchange_properties":null, +// "is_repeatable":null, +// "field_type":"string", +// "validations":[] + +// }] + +// } +// ] + +// }` +// onChangeProperties_value.push(JSON.parse(new_name)) + + onChangeProperties_value.forEach(onChangeProperty=>{ + console.log("api",onChangeProperty) + if(onChangeProperty.purpose == 'api'){ + if(onChangeProperty.api == 'getListOfStatesAndCities'){ + // console.log(event.value,onChangeProperty.params) + // onChangeProperty.params = JSON.stringify(onChangeProperty.params); + let updatedParams =JSON.stringify(onChangeProperty.params); + updatedParams = updatedParams.replace('value_of_answer',event.value); + // console.log(JSON.parse(updatedParams),updatedParams,JSON.parse(JSON.stringify(updatedParams))) + // debugger; + console.log("after",onChangeProperty) + this.quesService.apiCall(onChangeProperty.api,JSON.parse(updatedParams),onChangeProperty.api_method).subscribe(res=>{ + if(res['dataStatus']){ + this.local_city=res['records'].cities + this.local_pincode=res['records'].pincode + + this.whole_json.forEach((val,index)=>{ + + if(val.api_properties == 'local_city'){ + + this.local_city=this.quesService.convertArrayNames(['city_id','city_name'],this.local_city) + val.answers = (this.local_city) + } + else if(val.api_properties == 'local_pincode'){ + this.local_pincode=this.quesService.convertArrayNames(['pincode_id','pincode'],this.local_pincode) + val.answers = (this.local_pincode) + } + + }) + + } + }) + } + else{ + this.quesService.apiCall(onChangeProperty.api,onChangeProperty.params,onChangeProperty.api_method).subscribe(result=>{ + if(result['dataStatus']){ + if(result.hasOwnProperty('records')){ + result=result['records'] + } + // let ques_control= this.quesAnsForm.controls.questions['controls'] + // if(options == 2){ + // ques_control=group_ques.controls.questions['controls'] + // } + + this.whole_json.forEach((val,index)=>{ + + if(val.api_properties == onChangeProperty.local_variable){ + let values1=this.quesService.convertArrayNames(onChangeProperty.fields,result) + val.answers = (values1) + } + + }) + } + }) + } + } + if(onChangeProperty.purpose == 'validations'){ + + // if(options == 2){ + this.setValidations_onChange(onChangeProperty,this.formGroupN,sec_control,sec_index) + // } + // else{ + // this.setValidations_onChange(onChangeProperty,this.quesAnsForm,sec_control,sec_index) + // } + } + if(onChangeProperty.purpose == 'FORM_CTRL'){ + + // if(options == 2){ + console.log(sec_control) + // debugger; + this.creteNewField(onChangeProperty,this.formGroupN,sec_control,sec_index) + // } + // else{ + // this.creteNewField(onChangeProperty,this.quesAnsForm,sec_control,sec_index) + // } + } + }) + } + } + creteNewField(form_control_obj_raw,group_ques,sec_control,sec_index,purpose?){ + console.log(group_ques,form_control_obj_raw,sec_index); + if(form_control_obj_raw.form_controls.length > 0){ + form_control_obj_raw.form_controls.forEach(form_control_obj=>{ + if(form_control_obj.value_keys != null && form_control_obj.value_keys.length > 0 ){ + let expression_value=form_control_obj.expression + form_control_obj.value_keys.forEach(res=>{ + let control_value_obj + if(purpose != 'edit'){ + control_value_obj =group_ques.value[res] + } + else{ + control_value_obj = sec_index.questions.filter(val=>val.question_key == res)[0] + } + if(control_value_obj){ + // if(control_value_obj.answer_value == ''){ + // control_value_obj.answer_value =0 + // } + expression_value=expression_value.replace(res,control_value_obj) + } + }) + console.log("Expression",expression_value) + let calc_exp=eval(expression_value) + console.log("Expression result",calc_exp) + if(calc_exp != false){ + if(form_control_obj.questions.length > 0){ + let question_index_after + this.whole_json.forEach((val,index,arr)=>{ + + if(val.question_key == form_control_obj.insert_index){ + question_index_after= arr.indexOf(val) + } + }) + console.log("after result",question_index_after,sec_index); + this.createControl(form_control_obj,group_ques,question_index_after,1) //FOR ADD CONTOL + } + } + else{ + this.createControl(form_control_obj,group_ques,'',2) //FOR REMOVE CONTROL + } + } + }) + } + } + createControl(form_control_obj,group_ques,question_index_after,options){ + console.log(form_control_obj,group_ques,question_index_after) + let ques_control=this.whole_json + let inserted_control_obj=form_control_obj + inserted_control_obj.questions.sort() + inserted_control_obj.questions.reverse() + inserted_control_obj.questions.forEach(val=>{ + if(options == 1){ + let check_dup=ques_control.filter(control_key=>control_key.question_key == val.question_key) + console.log(check_dup,this.formGroupN); + + // let check_dup = [] + if(check_dup.length == 0){ + val.raw_validations=val.validations + // ques_control.insert(question_index_after+1,this.questionService.createValue(val)) + this.whole_json.splice(question_index_after+1,0,val); + this.formGroupN.addControl(val.question_key,new FormControl('')) + console.log("After adding control",this.whole_json,this.formGroupN,this.whole_form); + this.quesService.addAdditionalControl(val, this.formGroupN, question_index_after+1,"") + } + } + else{ + ques_control.forEach((control_key,index)=>{ + if(control_key.question_key == val.question_key){ + this.whole_json.splice(index,1) + this.formGroupN.controls[val.question_key].reset() + this.formGroupN.removeControl(val.question_key); + } + }) + } + }) + } + setValidations_onChange(validation_obj_raw,group_ques,sec_control,sec_index){ + + + if(validation_obj_raw.validations.length > 0){ + validation_obj_raw.validations.forEach(validation_obj=>{ + console.log("sing",validation_obj) + //FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION + if(validation_obj.hasOwnProperty('value_keys')){ + + if( validation_obj.value_keys != null){ + + + let expression_value=validation_obj.value + validation_obj.value_keys.forEach(res=>{ + let validator_value_obj=this.formGroupN.value[res] + if(validator_value_obj){ + expression_value=expression_value.replace(res,validator_value_obj) + } + }) + + // validation_obj.value=expression_value + validation_obj.validator=eval(expression_value) + + if(validation_obj.validator == false){ + validation_obj.isactive='0' + // // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS + this.proceedValidationSet(validation_obj,group_ques,sec_control,'') + } + else{ + validation_obj.isactive='1' + let validator_single=this.quesService.setValueForValidator(validation_obj) + console.log(validator_single) + // // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS + this.proceedValidationSet(validation_obj,group_ques,sec_control,validator_single) + } + //END OF EXPRESSION CHECK + } + else{ + // STARTING VALUE VALIDATION + let validator_value_obj + + + + validator_value_obj=this.formGroupN.value[ validation_obj.value] + console.log(validator_value_obj) + + validation_obj.validator=validator_value_obj + + // let validator_single=this.questionService.setValueForValidator(validation_obj) + // console.log(validator_single) + // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS + this.proceedValidationSet(validation_obj,group_ques,sec_control,'') + + // END OF VALUE VALIDATION + } + + // + + // } + // else{ + + // } + + } + }) + } + } + + proceedValidationSet(validation_obj,group_ques,sec_control,validator_single?){ + let ques_control; + if(validation_obj.validation_to == null){ + console.log("entered",group_ques,sec_control); + ques_control=this.whole_json[this.json_index] + + + // if(validation_obj.isactive == '1'){ + // ques_control.controls.answer_value.setValidators(validator_single) + // ques_control.controls.answer_value.updateValueAndValidity() + // } + // else{ + // ques_control.controls.answer_value.clearValidators() + // ques_control.controls.answer_value.updateValueAndValidity() + // } + // validation_obj.validator=validator_single + let new_validation_obj=this.updateValidationMsg(ques_control,validation_obj) + + this.quesService.settingArrayofValidators({validations:new_validation_obj,question_key:sec_control.question_key},this.formGroupN,'') + } + else{ + ques_control=this.whole_json + let other_control=ques_control.filter(val=>{ + if(val.question_key == validation_obj.validation_to){ + return val + } + })[0] + // let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name) + // updateMsg.push(validation_obj) + console.log("OTHER CONTROL",other_control) + // other_control.controls.answer_value.setValidators(validator_single) + // if(validation_obj.isactive == '1'){ + // other_control.controls.answer_value.setValidators(validator_single) + // other_control.controls.answer_value.updateValueAndValidity() + // } + // else{ + // other_control.controls.answer_value.clearValidators() + // other_control.controls.answer_value.updateValueAndValidity() + // } + + // other_control.controls.validations.setValue(updateMsg); + // validation_obj.validator=validator_single + let new_validations_obj=this.updateValidationMsg(other_control,validation_obj) + console.log("new validations obj",new_validations_obj,other_control) + this.quesService.settingArrayofValidators({validations:new_validations_obj,question_key:validation_obj.validation_to},this.formGroupN,'') + } + } + updateValidationMsg(ques_control,validation_obj){ + console.log("updae msg",ques_control,validation_obj); + let updateMsg=ques_control.validations.filter(val=>val.name != validation_obj.name) + updateMsg.push(validation_obj) + // ques_control.controls.validations.setValue(updateMsg); + ques_control.validations = updateMsg + return updateMsg; + } +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.spec.ts new file mode 100644 index 000000000..56b5b153f --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { QuesFormService } from './ques-form.service'; + +describe('QuesFormService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: QuesFormService = TestBed.get(QuesFormService); + expect(service).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts new file mode 100644 index 000000000..7ebfc7c03 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts @@ -0,0 +1,379 @@ +import { Injectable } from '@angular/core'; +import { FormGroup, FormArray, FormBuilder, FormControl, Validators } from '@angular/forms'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'environments/environment'; + +const apiUrl = environment.apiEndpoint + +@Injectable({ + providedIn: 'root' +}) +export class QuesFormService { + + constructor(private _fb:FormBuilder,private http:HttpClient) { + // this.apiUrl = constantProvider.environment().url + } + // FOR CREATING A FORM CONTROL DYNAMICALLY + assignFormControl_array(formgroup: FormGroup, ques_data: any) { + console.log(formgroup, ques_data) + const control: any = formgroup + + ques_data.forEach((val, index) => { + console.log("quees", val) + if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { + // control.push(this._fb.group({ + // "is_repeatable": [val.is_repeatable || null], + // "group_title": [val.group_title || null], "group_type": [val.group_type || null] + // ,"question_key":[val.question[0].question_key] + // })) + + control.addControl(val.group_key, this._fb.array([])) + + let childControl: any = control.get(val.group_key) as FormArray + + // childControl.push(this._fb.group({ 'questions': this._fb.array([]) })) + console.log("cc", childControl, control, index) + // let sub_childControl: any = childControl.controls[0].get('questions') as FormArray + let control_names:any={} + ques_data[index].group_questions = [] + ques_data[index].group_questions.push(val.question) + val.group_questions[0].forEach((group_indi, arr_index) => { + // if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){ + console.log("api pro", val.api_properties) + // let param + // val.api_properties.forEach(val=>param=val) + // console.log(param) + group_indi.raw_validations = group_indi.validations + // sub_childControl.push(this.createValue(group_indi)) + // childControl.addControl(group_indi.question_key,new FormControl('')) + control_names[group_indi.question_key] = '' + // childControl.push(this._fb.group({ + // [group_indi.question_key] :[''] + // })) + // setTimeout(()=>{ + // this.addAdditionalControl(group_indi, childControl.at(arr_index), arr_index) + // },2000) + // if(group_indi.type == '5'){ + // sub_childControl.controls[arr_index].removeControl('answer_value'); + // console.log("loop",arr_index,sub_childControl); + // sub_childControl.controls[arr_index].addControl('answer_value',this._fb.array([])) + // } + // if(group_indi.type == '1'){ + // sub_childControl.controls[arr_index].addControl('field_type',new FormControl(group_indi.field_type)) + // } + // if(val.type == '8'){ + // sub_childControl.controls[index].addControl('select_search',new FormControl(val.field_type)) + // } + + if (group_indi.api_properties != null) { + this.apiPropertiesCall(group_indi).then(res => { + if (res != false) { + group_indi.answers = [] + // group_indi.answers=this.convertArrayNames(val.api_properties.fields,res) + group_indi.answers = (this.convertArrayNames(group_indi.api_properties.fields, res)) + val.question[arr_index].answers = group_indi.answers + + } + }) + } + + const question_temp:any = JSON.parse(JSON.stringify(val.question)); + ques_data[index].question = question_temp + // else{ + // setTimeout(()=>{ + // sub_childControl.push(this.createValue(group_indi)) + // },200) + // } + // sub_childControl.push(this.createValue(group_indi)) + }) + console.log(control_names); + // val.questions[0]=val.question; + + childControl.push(this._fb.group(control_names)) + console.log(formgroup.value); + // debugger; + val.group_questions[0].forEach((group_indi,arr_index)=>{ + console.log("sd",childControl) + this.addAdditionalControl(group_indi, childControl.controls[0], arr_index) + }) + + // } + // else{ + // sub_childControl.push(this.createValue(group_indi)) + // } + // setTimeout(()=>{ + + // },500) + + console.log("dd112", formgroup, childControl) + // let key_list=Object.keys(val) + // console.log(Object.keys(val)) + // key_list.forEach(key=>{ + // childControl.controls + // }) + } + else { + // console.log("con",control) + // let key_list=Object.keys(val) + // console.log(Object.keys(val)) + // let curr_object + // console.log("apikd",typeof(val.api_properties)) + // if(val.api_properties != null && typeof(val.api_properties) == 'object'){ + val.raw_validations = val.validations + // control.push(this.createValue(val)) + formgroup.addControl(val.question_key,new FormControl('')) + // for checkbox remove the form control and add the formarray for multiple values + this.addAdditionalControl(val, formgroup, index) + // if(val.type == '5'){ + // control.controls[index].removeControl('answer_value'); + // console.log("loop",index,control); + // control.controls[index].addControl('answer_value',this._fb.array([])) + // } + // if(val.type == '1'){ + // control.controls[index].addControl('field_type',new FormControl(val.field_type)) + // } + // if(val.type == '8'){ + // control.controls[index].addControl('select_search',new FormControl(val.field_type)) + // } + if (val.api_properties != null) { + this.apiPropertiesCall(val).then(res => { + console.log("chekc", res) + if (res != false) { + // val.answers=[] + // val.answers=this.convertArrayNames(val.api_properties.fields,res) + val.answers = this.convertArrayNames(val.api_properties.fields, res) + + } + }, err => console.log(err)) + } + // else{ + // setTimeout(()=>{ + // control.push(this.createValue(val)) + // },200) + // } + + // } + // else{ + // control.push(this.createValue(val)) + // } + console.log(formgroup) + + } + }, err => console.log(err)) + return formgroup + } + // END OF FORM CREATION + + + // FOR CREATING THE FORM CONTROL FOR SPECIFIC FORM ARRAY + createValue(data){ + let is_amt_in_words=false + let answer_value_loc=''; + let answers_from_client=[] + // if(data.hasOwnProperty('answer_value') && data.answer_value != '' || null){ + // let values_for_cli:any = this.getAnswerValue(data) + // if(values_for_cli.flag == 1){ + // answer_value_loc=values_for_cli.values + // } + // else{ + // answers_from_client=values_for_cli.values + // } + // } + // if(data.hasOwnProperty('field_type')){ + // if(data.field_type == 'num'){ + // is_amt_in_words=true + // } + // } + return this._fb.group({ + "answer_value":[{value:answer_value_loc,disabled:answer_value_loc != '' ? true : false}], // OLD VALIDATION >>>> data.type != '6' ? Validators.compose([Validators.required]) : '' + "question":[data.question], + "question_key":[data.question_key], + "type":[data.type], + "raw_validations":[data.raw_validations], + "validations":[data.raw_validations], + "api_properties":[data.api_properties], + "onchange_properties":[data.onchange_properties], + "answers":[answers_from_client.length != 0 ? answers_from_client: data.answers], + "is_repeatable":[data.is_repeatable || null], + "group_title":[data.group_title || null] + }) + } + // END OF CREATEVALUE FUN + + // FOR REQUESTING THE API AUTOMATICALLY FROM JSON + apiPropertiesCall(val){ + return new Promise((resolve,reject)=>{ + if(val.api_properties != null && typeof(val.api_properties) == 'object'){ + this.apiCall(val.api_properties.api,val.api_properties.params,val.api_properties.api_method).subscribe(res=>{ + if(res['dataStatus']){ + if(res.hasOwnProperty('records')){ + res=res['records'] + } + resolve(res) + console.log(res) + // val.answers=res + } + else{ + resolve(false) + } + }) + } + else{ + resolve(false) + } + }) + } + apiCall(api_name:string,params,api_method?){ + if(api_method.toUpperCase() == 'POST'){ + return this.http.post(apiUrl+api_name,params) + } + else{ + return this.http.get(apiUrl+api_name) + } + + } + // END OF API PROPERTIES CALL + + // ---FOR CONVERTING THE ANSWER KEYS UNIQUE + convertArrayNames(fieldName,data_from_api){ + let val1=[] + let modified_json = data_from_api.map( + obj => { + return { + "answer_id" : obj[fieldName[0]], + "answer":obj[fieldName[1]], + + } + }); + return modified_json + } + // END OF CONVERTARRAYNAMES FUN-- + + addAdditionalControl(data,curr_control,curr_index,purpose?){ + console.log(curr_control); + //FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY + if(data.type == '5'){ + // curr_control.controls[curr_index].removeControl('answer_value'); + // curr_control.controls[curr_index].addControl('answer_value',this._fb.array([])) + curr_control.removeControl(data.question_key) + curr_control.addControl(data.question_key,this._fb.array([])) + } + + //FOR numeric of string field + if(data.type == '1'){ + // curr_control.controls[curr_index].addControl('field_type',new FormControl(data.field_type)) + // curr_control.controls[curr_index].addControl('place_holder',new FormControl(data.place_holder)) + } + + //FOR SEARCHABLE FIELD VALUE KEY () + if(data.type == '8'){ + // curr_control.controls[curr_index].addControl('select_search',new FormControl(data.field_type)) + curr_control.addControl(data.question_key+'_searchControl',new FormControl(data.field_type)) + } + if(purpose == 'additional_field'){ + curr_control.controls[curr_index].addControl('additional_field',new FormControl(1)) + } + + // FOR IMAGE STATUS + if(data.type == '6'){ + curr_control.controls[curr_index].addControl('is_loader',new FormControl('')) + curr_control.controls[curr_index].addControl('is_saved',new FormControl('')) + curr_control.controls[curr_index].addControl('is_image_status',new FormControl(false)) + } + + //FOR SETTING THE VALIDATORS + this.settingArrayofValidators(data,curr_control,curr_index) + } + + // FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp, + settingArrayofValidators(data,curr_control,curr_index){ + console.log("entered",data); + if(data.hasOwnProperty('validations') && data.validations.length > 0 ){ + const validList :any= []; + let validator_value + data.validations=data.validations.filter(val=>val.isactive != '0') + data.validations.forEach(valid => { + if(valid.value != null && !valid.hasOwnProperty('validation_to')){ + validator_value= this.getvalidatorValue(valid) + } + else{ + validator_value=this.setValueForValidator(valid) + console.log("cc",validator_value) + + } + validList.push(validator_value); + }); + // console.log("valid",validList,curr_control) + // let val="Validators.required" + // console.log(typeof(Validators)) + // console.log(typeof(`${val}`)) + + // let val1=`${val}` + // console.log(typeof(eval(val))) + // console.log(eval(val)) + console.log(validList) + // curr_control.controls[curr_index].controls.answer_value.setValidators(validList) + curr_control.controls[data.question_key].setValidators(validList) + console.log("ddvdeeqq",validList) + curr_control.controls[data.question_key].updateValueAndValidity() + console.log("after setting validators",curr_control.controls[data.question_key]) + // debugger; + } + } + // END OF SETTINGARRAYOFVALIDATORS FUN + + // FOR GETTING THE VALIDATION VALUE + getvalidatorValue(value_obj){ + if(value_obj != null && value_obj.hasOwnProperty('value')){ + let value_of_validator + switch(value_obj.value){ + case 'CURRENT_YEAR': + value_of_validator=new Date().getFullYear() + break; + default: + value_of_validator='' + break; + } + value_obj.validator=String(value_of_validator) + return this.setValueForValidator(value_obj) + } + } + // END OF GETVALIDATORVALUE FUN + + // FOR CREATING THE CORRECT VALIDATION + setValueForValidator(value_obj){ + console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator)) + let return_value + if(value_obj != null && value_obj.hasOwnProperty('validator')){ + switch(value_obj.name) + { + case 'required': + return_value=Validators.required + break; + case 'minLength': + return_value=Validators.minLength(value_obj.validator) + break; + case 'maxLength': + return_value=Validators.maxLength(value_obj.validator) + break; + case 'min': + return_value=Validators.min(value_obj.validator) + break; + case 'max': + return_value=Validators.max(value_obj.validator) + break; + case 'pattern': + return_value=Validators.pattern(value_obj.validator) + break; + default: + return_value='' + break; + } + return return_value + } + else{ + return false + } + } + // END OF SETVALUEFORVALIDATOR FUN +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts index 010e9d10b..c9aacb7f7 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts @@ -234,6 +234,9 @@ export class FinalRemarksComponent implements OnInit { recommendationPositiveCtrl.push(this.CreateRecommendationPositive(objs)); }); } + else { + this.addRecommendationPositive() + } if (data.records.recommendation_refer_to_credit.length > 0) { let recommendationReferToCredit: any = this._finalRemarkForm.get('recommendation_refer_to_credit') as FormArray; data.records.recommendation_refer_to_credit.forEach((val, index) => { @@ -241,6 +244,9 @@ export class FinalRemarksComponent implements OnInit { recommendationReferToCredit.push(this.CreateRecommendationReferToCredit(objs)); }); } + else { + this.addRecommendationReferToCredit() + } if (data.records.recommendation_negative.length > 0) { let recommendationNegativeCtrl: any = this._finalRemarkForm.get('recommendation_negative') as FormArray; data.records.recommendation_negative.forEach((val, index) => { @@ -248,6 +254,9 @@ export class FinalRemarksComponent implements OnInit { recommendationNegativeCtrl.push(this.CreateRecommendationNegative(objs)); }); } + else { + this.addRecommendationNegative() + } this._finalRemarkForm.controls.is_service_provided.setValue(data.records.is_service_provided); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.html index c9d401bf3..16dfdb20c 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.html @@ -70,7 +70,6 @@
-
@@ -87,6 +86,7 @@ +
@@ -106,6 +106,16 @@
+ + + +
{{questions_JSON.section_name}}
+
+
+ + + +
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.ts index 9cadc91c2..9c6f8e05b 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/queries-docs/queries-docs.component.ts @@ -33,6 +33,25 @@ export class QueriesDocsComponent implements OnInit { fk_pd_type: any; image_doc_params: { pdid: string; form_id: number; company_id: string; }; + covid19QuesForm:FormGroup; + // temlateQues:any + // `{ + // "form_name":"Personal Discussion Sheet - Working Capital Term Loan (For Sales Team)", + // "sections":[ + // ` + questions_JSON: any = {questions:[]}; + covidAnswers :any = null; + // = { + // "business_impacted_by_covid19": "No", + // "avail_loan_moratorium_facility": "Yes", + // "avail_any_loan": "Yes", + // "sales_or_revenue_amt": "233", + // "mentioned_turover_validated": "Yes", + // "business_impacted_by_covid19_No": "Business falls under essential services like chemist", + // "avail_any_loan_Yes": "df", + // "mentioned_turover_validated_Yes": "records shown" + // } + constructor(notifier: NotifierService, private _ngZone: NgZone, private fb: FormBuilder, @@ -71,6 +90,7 @@ export class QueriesDocsComponent implements OnInit { addtional_requirements:this.fb.array([this.createview()]) }) this.getFullPD(); + this.getCovidQuesTemplate() } createview(){ @@ -78,7 +98,25 @@ export class QueriesDocsComponent implements OnInit { name:[''] }) } - + getCovidQuesTemplate() { + // this.qustCat.covid19Ques().subscribe(res=>{ + let covidQuesTemplate: any = localStorage.getItem('dynamicQuesTemplate') + if (covidQuesTemplate && covidQuesTemplate != null && covidQuesTemplate != undefined + ) { + covidQuesTemplate = JSON.parse(covidQuesTemplate) + if (covidQuesTemplate.hasOwnProperty('template') && covidQuesTemplate.template) { + covidQuesTemplate =JSON.parse(covidQuesTemplate.template); + this.covid19QuesForm = new FormGroup({}) + this.questions_JSON = covidQuesTemplate; + console.log(this.questions_JSON); + setTimeout(() => { + this.covidAnswers = null + console.log("cleared") + }, 2000) + } + } + // }) + } getFullPD(){ // let records = {'parent_pdid': this.pdDetails.parent_pd_id,'pdid':this.pdDetails.pd_id,'random_string':this.pdDetails.random_string}; @@ -152,14 +190,58 @@ export class QueriesDocsComponent implements OnInit { // this.docs_change_fun(index,data) }) } + if(retrieved_data.hasOwnProperty('covid_section') && retrieved_data.covid_section) { + this.covidAnswers = retrieved_data.covid_section + + } // console.log("form123",this.docsCollectedForm.value); this.docsCollectedForm.patchValue(retrieved_data) } + if(this.pd_all_details.pdmaster_details.fk_pd_type == '2' && this.pd_all_details.pdmaster_details.hasOwnProperty('vendor_status') && this.pd_all_details.pdmaster_details.vendor_status == 'COMPLETED') { + console.log(this.pd_all_details.pdmaster_details.vendor_status); + setTimeout(()=>{ + this.getDataFromVendor() + },1000) + } },err=>{ }) } + + /************************* START OF VENDOR FORM DATAS *********************************/ + + getDataFromVendor() { + + this.pdTriggerService.getVendorDatas('queries_form',this.pdid).subscribe(result=>{ + if(result && result['dataStatus']) { + if(result.records.hasOwnProperty('docs_to_be_sighted') && result.records.docs_to_be_sighted.length > 0) { + result.records.docs_to_be_sighted.forEach((doc_value,index)=>{ + console.log(doc_value) + if(doc_value.hasOwnProperty('img') && doc_value.img && doc_value.img != '') { + this.docs_change_fun(index,'yes') + } + else if(doc_value.hasOwnProperty('reason') && doc_value.reason && doc_value.reason != '') { + this.docs_change_fun(index,'no'); + } + // let data=doc_value.control_name + // data=parseInt(data) + // console.log("data",data); + // data=doc_value.data + // this.docs_change_fun(index,data) + }) + this.docsCollectedForm.patchValue(result.records); + } + // let curr_control: any = ParCtrls.controls[0]; + // result.records.business_address_availability ='yes' + + // console.log(this._generalForm.value) + } + }) + + } + /************************* END OF VENDOR FORM DATAS *********************************/ + initControls(){ if(this.queries_docs.length != 0){ this.queries_docs.forEach(res=>{ @@ -207,6 +289,40 @@ export class QueriesDocsComponent implements OnInit { // console.log("Error",err) // }) // } + /** + * Marks all controls in a form group as touched + * @param formGroup - The form group to touch + */ + private markFormGroupTouched(formGroup: FormGroup) { + (Object).values(formGroup.controls).forEach(control => { + control.markAsTouched(); + + if (control.controls) { + this.markFormGroupTouched(control); + } + }); + } + public findInvalidControls() { + const controls = this.covid19QuesForm.controls; + console.log(controls) + for (const name in controls) { + if (controls[name].invalid) { + let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); + let firstInvalidField; + for(let val in invalidFields){ + if( invalidFields[val].nodeName == 'MAT-FORM-FIELD'){ //INPUT FOR INPUT FIELD + firstInvalidField=invalidFields[val] + break; + } + } + if(firstInvalidField != undefined){ + firstInvalidField.scrollIntoView(true) + } + break; + } + } + // return invalid; + } saveForm(){ // console.log(this.docsCollectedForm.value); // this.docsCollectedForm.value.docs_to_be_sighted.forEach(value=>{ @@ -218,11 +334,34 @@ export class QueriesDocsComponent implements OnInit { // } // }) if(this.docsCollectedForm.invalid){ + if(this.docsCollectedForm.invalid && (this.queries_docs.length > 0 || this.docs_array_value.length > 0)){ this.notifier.notify("warning","Please Fill all the Fields and capture the image if required"); return + } } + if(this.questions_JSON.questions.length > 0) { + console.log(this.covid19QuesForm.getRawValue(),this.covid19QuesForm.valid,JSON.stringify(this.covid19QuesForm.getRawValue()),this.questions_JSON.questions); + if(this.covid19QuesForm.invalid) { + this.covid19QuesForm.markAsDirty() + this.markFormGroupTouched(this.covid19QuesForm) + this.findInvalidControls() + this.notifier.notify("warning","Please Fill all the required Fields"); + // console.log(geneatedQues) + // let group_ques = this.questions_JSON.question.filter(val=>val.is_repeatable == '1') + // if(group_ques.length >0 && group_ques.hasOwnProperty('question') && group_ques.question) { + // group_ques=group_ques.question.map(vv=>{ + // return {question_key:vv.question_key,question:vv.question,is_repeatable:'0'} + // }) + // } + + return; + } + } + let formParams:any; this.disableAfterSubmit=true - this.docsCollectedForm.value.addtional_requirements[0].hasOwnProperty('name') ? delete this.docsCollectedForm.value.addtional_requirements[0].name : '' + if((this.queries_docs.length > 0 || this.docs_array_value.length > 0)) { + formParams = this.docsCollectedForm.value + formParams.addtional_requirements[0].hasOwnProperty('name') ? delete formParams.addtional_requirements[0].name : '' // console.log(JSON.stringify(this.docsCollectedForm.value)); // this.constantProvider.getGeoTag().then(geoCoords=>{ // if(this.docsCollectedForm.value.link == ""){ @@ -237,8 +376,19 @@ export class QueriesDocsComponent implements OnInit { }, error => { this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); }); + } - this.pdTriggerService.saveForm(this.docsCollectedForm.value).subscribe(res=>{ + if(this.questions_JSON.questions.length > 0) { + let geneatedQues = this.questions_JSON.questions.filter(val=>val.is_repeatable != '1').map(vv=>{ + return {question_key:vv.question_key,question:vv.question,is_repeatable:'0',type:vv.type} + }) + let covidFormAnswers = this.covid19QuesForm.getRawValue() + covidFormAnswers.question_info = geneatedQues + formParams.covid_section = covidFormAnswers + } + console.log(formParams); + + this.pdTriggerService.saveForm(formParams).subscribe(res=>{ if(res['dataStatus']){ this.notifier.notify("success","Record Saved Successfully..") setTimeout(()=>{ @@ -265,7 +415,7 @@ export class QueriesDocsComponent implements OnInit { if(value == 'yes'){ // this.camera_btn[index]=true control.controls[index].removeControl('reason') - // control.controls[index].addControl('img',new FormControl('',Validators.required)) + control.controls[index].addControl('img',new FormControl('',Validators.required)) // control.controls[index].addControl('is_new',new FormControl('',Validators.required)) } else if(value == 'no'){ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts index 4cde14ecb..ff3935b67 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts @@ -89,7 +89,21 @@ export class StartPdComponent implements OnInit, OnDestroy { // Ps.initialize(elemContent, { wheelSpeed: 2, suppressScrollX: true }); } this.loadTemplates(this.startPD,1,this.randomString); + this.getCreditPDTemplate(); } + getCreditPDTemplate() { + // let params = { "fk_entity_id":this.pddetails.fk_lender_id,"fk_product_id":this.pddetails.fk_product_id,"pd_form_id":this.pddetails.pd_id } + let params = { "fk_entity_id":"","fk_product_id":"","pd_form_id":"24" } + this._pd.loadCreditPDTemplate(params).subscribe(result=> { + let creditTemplate:any = null; + if(result['dataStatus']) { + if(result.hasOwnProperty('records') && result['records']) { + creditTemplate = result['records']; + } + } + localStorage.setItem("dynamicQuesTemplate",JSON.stringify(creditTemplate)); + }) + } isMac(): boolean { let bool = false; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html index 7db1940b3..22190e036 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html @@ -179,7 +179,7 @@ {{master.pd_status==pdStatusCheck.QC_COMPLETED ? 'QC Completed' : master.pd_status==pdStatusCheck.ADD_ON_PENDING ? 'Addon Pending' : master.pd_status | titlecase}} - + @@ -211,7 +211,7 @@ - +
@@ -348,7 +348,7 @@
Applicants
-
+
@@ -398,7 +398,7 @@
Credit Manager’s Specific Queries
-
+
@@ -421,7 +421,7 @@
Documents to be collected
-
+
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts index 615ef3f81..5b08b9532 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts @@ -90,6 +90,7 @@ export class ViewPdComponent implements OnInit, OnDestroy { "COMPLETED": 'COMPLETED', "ADD_ON_PENDING": 'ADD_ON_PENDING', "QC_COMPLETED": 'QC_COMPLETED', + "ALLOCATED_TO_PARTNER":'ALLOCATED_TO_PARTNER' }; mandatoryFieldsValidations: any = []; @@ -163,7 +164,7 @@ export class ViewPdComponent implements OnInit, OnDestroy { if (data.status == 200) { let masterData: any = data.records.pd_master_details; this.pdMasterData.push(masterData[0]); - if(this.pdMasterData[0].pd_status == 'COMPLETED') { + if((this.pdMasterData[0].fk_pd_type == '3' || this.pdMasterData[0].fk_pd_type == '2') && (this.pdMasterData[0].pd_status == 'COMPLETED' || this.pdMasterData[0].pd_status == 'QC_COMPLETED')) { this.getVideoUrl(this.viewID,this.masterRandomString) this.videoplayback.enableBtn = true; } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts index e82d22d87..32fda8e70 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts @@ -133,6 +133,9 @@ import { ImageDocsComponent } from './list-pd/start-pd/forms/image-docs/image-do import { environment } from 'environments/environment' import { CustomTitleCaseDirective } from '../pd-directive/custom-title-case.directive'; import { SpeedDialFabComponent } from './list-pd/view-pd/speed-dial-fab/speed-dial-fab.component'; +import { DynamicFormComponent } from './list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component'; +import { DynamicQuestionTemplateComponent } from './list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component'; +import { QuesFormService } from './list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service'; /** * Custom angular notifier options @@ -179,7 +182,8 @@ const pdCustomNotifierOptions: NotifierOptions = { }; @NgModule({ - declarations: [TelePdAllocationComponent, FinancialInfoComponent, BusinessInfoComponent, EmploymentInfoComponent, StockComponent, BankingDetailsComponent, ListPdComponent, FamilyDetailsComponent, AddressComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent,VendorPdAllocationComponent, DuplicatePdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, CurrentLoanComponent, AssetsInfoComponent, LoanDetailsComponent, OtherIncomeComponent, SupplierInfoComponent, PersonalInfoComponent, LenderRepresentativeComponent, PdReportComponent, AssessedIncomeComponent, AllocationViewMoreComponent, PdRequirementComponent,PdCollectedDocsComponent, GeneralInfoComponent, ModelEditPdReportComponent, OtherApplicantDetailsComponent, NeighbourHoodComponent, DialogChangeCurrentVenrsion, FinalRemarksComponent, BusinessOtherFamilyMemberComponent, QcReviewComponent, BusinessInfoGroupComponent, SearchRelationPipe, RupeeCurrencyFormatPipe, NumberToWordsPipe, DeleteRecordsCountPipe, BusinessAssetsInfoComponent, BusinessBankingDetailsComponent, SalesDetailsComponent, DailySalesDetailsComponent, SalesCalculationComponent, ManageSalesComponent, PurchaseDetailsComponent, BusinessExpenseDetailsComponent, HouseHoldDetailsComponent, OtherBusinessIncomeDetailsComponent, ManagePurchaseComponent, ManageBusinesExpenseComponent, ManageHouseHoldComponent, ManageOtherBusinessIncomeComponent, GrossProfitCalculationComponent, ManageDailySalesComponent, PdStatusChangeDialogueComponent, PdLocatedMapViewDirective, ViewLocationComponent, GetAnswerableFormsPipe, ConfirmAiDetailsComponent, RentalVerificationComponent, InitiateAdditionalPdComponent ,ManageDailyPurchaseComponent, DailyPurchaseDetailsComponent, ManageRentalVerificationComponent, FuturePlansAndBusinessEnvironmentComponent, ImageCropComponent,PurchaseCalculationComponent,QueriesDocsComponent, ImageDocsComponent,CustomTitleCaseDirective, SpeedDialFabComponent], + declarations: [TelePdAllocationComponent, FinancialInfoComponent, BusinessInfoComponent, EmploymentInfoComponent, StockComponent, BankingDetailsComponent, ListPdComponent, FamilyDetailsComponent, AddressComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent,VendorPdAllocationComponent, DuplicatePdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, CurrentLoanComponent, AssetsInfoComponent, LoanDetailsComponent, OtherIncomeComponent, SupplierInfoComponent, PersonalInfoComponent, LenderRepresentativeComponent, PdReportComponent, AssessedIncomeComponent, AllocationViewMoreComponent, PdRequirementComponent,PdCollectedDocsComponent, GeneralInfoComponent, ModelEditPdReportComponent, OtherApplicantDetailsComponent, NeighbourHoodComponent, DialogChangeCurrentVenrsion, FinalRemarksComponent, BusinessOtherFamilyMemberComponent, QcReviewComponent, BusinessInfoGroupComponent, SearchRelationPipe, RupeeCurrencyFormatPipe, NumberToWordsPipe, DeleteRecordsCountPipe, BusinessAssetsInfoComponent, BusinessBankingDetailsComponent, SalesDetailsComponent, DailySalesDetailsComponent, SalesCalculationComponent, ManageSalesComponent, PurchaseDetailsComponent, BusinessExpenseDetailsComponent, HouseHoldDetailsComponent, OtherBusinessIncomeDetailsComponent, ManagePurchaseComponent, ManageBusinesExpenseComponent, ManageHouseHoldComponent, ManageOtherBusinessIncomeComponent, GrossProfitCalculationComponent, ManageDailySalesComponent, PdStatusChangeDialogueComponent, PdLocatedMapViewDirective, ViewLocationComponent, GetAnswerableFormsPipe, ConfirmAiDetailsComponent, RentalVerificationComponent, InitiateAdditionalPdComponent ,ManageDailyPurchaseComponent, DailyPurchaseDetailsComponent, ManageRentalVerificationComponent, FuturePlansAndBusinessEnvironmentComponent, ImageCropComponent,PurchaseCalculationComponent,QueriesDocsComponent, ImageDocsComponent,CustomTitleCaseDirective, SpeedDialFabComponent, + DynamicFormComponent,DynamicQuestionTemplateComponent], imports: [ CommonModule, ManagePdRoutingModule, @@ -218,10 +222,11 @@ const pdCustomNotifierOptions: NotifierOptions = { exports: [DuplicatePdComponent,VendorPdAllocationComponent,PdLocatedMapViewDirective, PdAllocationComponent, SmartPdAllocationComponent, TelePdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, SupplierInfoComponent, PersonalInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent, AssessedIncomeComponent, AllocationViewMoreComponent, GeneralInfoComponent, PdRequirementComponent,PdCollectedDocsComponent, OtherApplicantDetailsComponent, NeighbourHoodComponent, BusinessOtherFamilyMemberComponent, BusinessInfoGroupComponent,DailySalesDetailsComponent, SalesCalculationComponent, PurchaseDetailsComponent, BusinessExpenseDetailsComponent, HouseHoldDetailsComponent, OtherBusinessIncomeDetailsComponent, ManageSalesComponent, ManagePurchaseComponent, ManageBusinesExpenseComponent, ManageHouseHoldComponent, ManageOtherBusinessIncomeComponent, GrossProfitCalculationComponent, ManageDailySalesComponent, PdStatusChangeDialogueComponent, ViewLocationComponent, ConfirmAiDetailsComponent, RentalVerificationComponent, InitiateAdditionalPdComponent, DailyPurchaseDetailsComponent, ManageDailyPurchaseComponent,ManageRentalVerificationComponent,ImageCropComponent,PurchaseCalculationComponent], providers: [PdTrigerService, GetGeometricLocationService,{provide: MAT_DATE_LOCALE, useValue: 'en-GB'}, {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, - {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}, PdLocatedMapViewDirective], + {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}, PdLocatedMapViewDirective,QuesFormService], entryComponents: [DuplicatePdComponent,VendorPdAllocationComponent,PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent, AllocationViewMoreComponent, PersonalInfoComponent,BusinessAssetsInfoComponent, - ClientInfoComponent, SupplierInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent, AssessedIncomeComponent, GeneralInfoComponent, PdRequirementComponent,PdCollectedDocsComponent, ModelEditPdReportComponent, OtherApplicantDetailsComponent, NeighbourHoodComponent, DialogChangeCurrentVenrsion, FinalRemarksComponent, BusinessOtherFamilyMemberComponent, QcReviewComponent, BusinessInfoGroupComponent,BusinessBankingDetailsComponent, ManageSalesComponent, ManagePurchaseComponent, ManageBusinesExpenseComponent, ManageHouseHoldComponent, ManageOtherBusinessIncomeComponent, ManageDailySalesComponent,PdStatusChangeDialogueComponent, ViewLocationComponent, ConfirmAiDetailsComponent, RentalVerificationComponent, InitiateAdditionalPdComponent, ManageDailyPurchaseComponent,ManageRentalVerificationComponent,FuturePlansAndBusinessEnvironmentComponent,ImageCropComponent,QueriesDocsComponent], + ClientInfoComponent, SupplierInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent, AssessedIncomeComponent, GeneralInfoComponent, PdRequirementComponent,PdCollectedDocsComponent, ModelEditPdReportComponent, OtherApplicantDetailsComponent, NeighbourHoodComponent, DialogChangeCurrentVenrsion, FinalRemarksComponent, BusinessOtherFamilyMemberComponent, QcReviewComponent, BusinessInfoGroupComponent,BusinessBankingDetailsComponent, ManageSalesComponent, ManagePurchaseComponent, ManageBusinesExpenseComponent, ManageHouseHoldComponent, ManageOtherBusinessIncomeComponent, ManageDailySalesComponent,PdStatusChangeDialogueComponent, ViewLocationComponent, ConfirmAiDetailsComponent, RentalVerificationComponent, InitiateAdditionalPdComponent, ManageDailyPurchaseComponent,ManageRentalVerificationComponent,FuturePlansAndBusinessEnvironmentComponent,ImageCropComponent,QueriesDocsComponent, + DynamicFormComponent,DynamicQuestionTemplateComponent], }) export class ManagePdModule { } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts index 74a50890f..c77251b7e 100755 --- a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts @@ -368,6 +368,7 @@ export class PdTrigerService { catchError(this.handleError('operation', [])) ) } + // load PD question answers getAnswersForPD(list: any): Observable { @@ -945,7 +946,8 @@ export class PdTrigerService { getVendorDatas(form_name,pd_id?) { let formsDet = [{form_name:"general",form_id:"18"},{form_name:"address",form_id:"5"},{form_name:"business_info",form_id:"13"}, {form_name:"business_assets",form_id:"22"},{form_name:"neighbourhood_details",form_id:"19"}, - {form_name:"final_remarks",form_id:"20"} + {form_name:"final_remarks",form_id:"20"}, + {form_name:"queries_form",form_id:"24"} ] // let records = {"records":data[form_name]} @@ -957,4 +959,21 @@ export class PdTrigerService { getVendorAnswers(params):Observable { return this._http.post(this.apiUrl+'getVendorAnswers',params) } + + + covid19Ques() { + return this._http.get('../../../assets/sample_covid19_ques.json') + } + + loadCreditPDTemplate(params) { + return this._http.post(this.apiUrl+'loadCreditPDTemplate', params) + + // dummy data + // return this._http.get('../../../assets/sample_covid19_ques.json').map(result=>{ + // console.log(result) + // let apivalue ={dataStatus:true,records:{template:JSON.stringify(result)}} + // console.log(apivalue) + // return apivalue + // }) + } } diff --git a/ng6-seed/src/assets/sample_covid19_ques.json b/ng6-seed/src/assets/sample_covid19_ques.json new file mode 100644 index 000000000..b4d884221 --- /dev/null +++ b/ng6-seed/src/assets/sample_covid19_ques.json @@ -0,0 +1,319 @@ +{ + "section_id":"1", + "section_name":"Covid 19 Questions", + "onsubmit":null, + "questions":[ + { + "question":" Is your business adversely impacted by coronavirus outbreak ?", + "question_key":"business_impacted_by_covid19", + "type":"2", + "field_width":"100", + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes" + }, + { + "answer_id":"No", + "answer":"No" + } + ], + "api_properties":null, + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"business_impacted_by_covid19", + "expression":"(String('business_impacted_by_covid19') == String('Yes'))", + "value_keys":[ + "business_impacted_by_covid19" + ], + "questions":[ + { + "question":"Choose any", + "question_key":"business_impacted_by_covid19_Yes", + "place_holder":"", + "field_type":"string", + "type":"9", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Employees/labour not available", + "answer":"Employees/labour not available" + }, + { + "answer_id":"business closed during lockdown", + "answer":"business closed during lockdown" + }, + { + "answer_id":"sales reduced due to lockdown", + "answer":"sales reduced due to lockdown" + }, + { + "answer_id":"sales not picking up post lock down etc", + "answer":"sales not picking up post lock down etc" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + } + ] + }, + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"business_impacted_by_covid19", + "expression":"(String('business_impacted_by_covid19') == String('No'))", + "value_keys":[ + "business_impacted_by_covid19" + ], + "questions":[ + { + "question":"Choose any", + "question_key":"business_impacted_by_covid19_No", + "place_holder":"", + "field_type":"string", + "type":"9", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Business falls under essential services like chemist", + "answer":"Business falls under essential services like chemist" + }, + { + "answer_id":" grocery store etc", + "answer":"grocery store etc" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + } + ] + } + ], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":" Did you avail the loan moratorium facility on your existing loans which is extended by your bank or financial institution? ", + "question_key":"avail_loan_moratorium_facility", + "type":"2", + "field_width":"100", + "onchange_properties":[], + "api_properties":null, + "answers":[ + { + "answer":"Yes", + "answer_id":"Yes" + }, + { + "answer":"No", + "answer_id":"No" + } + ], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Are you planning to avail/ or already availed any loan or any other term facility for your business or personal use?", + "question_key":"avail_any_loan", + "type":"2", + "field_width":"100", + "api_properties":null, + "answers":[ + { + "answer":"Yes", + "answer_id":"Yes" + }, + { + "answer":"No", + "answer_id":"No" + } + ], + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"avail_any_loan", + "expression":"(String('avail_any_loan') == String('Yes'))", + "value_keys":[ + "avail_any_loan" + ], + "questions":[ + { + "question":"Please specify amount, lender etc.", + "question_key":"avail_any_loan_Yes", + "type":"7", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + } + ] + } + ] + }], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"How much is your sales/revenue from April till date?", + "question_key":"sales_or_revenue_amt", + "place_holder":"Enter amount", + "type":"1", + "field_width":"100", + "answers":null, + "api_properties":null, + "is_repeatable":null, + "field_type":"numtoword", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Is turnover mentioned above validated?", + "question_key":"mentioned_turover_validated", + "type":"2", + "field_width":"100", + "api_properties":null, + "answers":[ + { + "answer":"Yes", + "answer_id":"Yes" + }, + { + "answer":"No", + "answer_id":"No" + } + ], + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"mentioned_turover_validated", + "expression":"(String('mentioned_turover_validated') == String('Yes'))", + "value_keys":[ + "mentioned_turover_validated" + ], + "questions":[ + { + "question":"Choose any", + "question_key":"mentioned_turover_validated_Yes", + "place_holder":"", + "field_type":"string", + "type":"9", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":[ + { + "answer_id":"Bills", + "answer":"Bills" + }, + { + "answer_id":"Gst returns", + "answer":"Gst returns" + }, + { + "answer_id":"records shown", + "answer":"records shown" + } + ], + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + } + ] + } + ], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + } + + ] + } \ No newline at end of file