From 532cc20c7d8d896d24071b26bb2f52c1001f3da7 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 29 Oct 2020 18:49:14 +0530 Subject: [PATCH] Fairoj : discussion enabled and template and forms enabled --- .vscode/settings.json | 3 + .../list-pd/add-pd/add-pd.component.html | 6 +- .../list-pd/add-pd/add-pd.component.ts | 2 +- .../excel-upload-dialog.component.scss | 6 +- .../list-pd/all-pd/all-pd.component.ts | 14 +- .../completed-pd/completed-pd.component.ts | 14 +- .../inprogress-pd/inprogress-pd.component.ts | 16 +- .../pd-status-change-dialogue.component.ts | 1 + .../qc-completed-pd.component.ts | 14 +- .../scheduled-pd/scheduled-pd.component.ts | 16 +- .../dynamic-form/dynamic-form.component.html | 69 +++ .../dynamic-form/dynamic-form.component.scss | 0 .../dynamic-form.component.spec.ts | 24 + .../dynamic-form/dynamic-form.component.ts | 68 +++ .../dynamic-question-template.component.html | 184 ++++++ .../dynamic-question-template.component.scss | 34 ++ ...ynamic-question-template.component.spec.ts | 24 + .../dynamic-question-template.component.ts | 465 +++++++++++++++ .../ques-form/ques-form.service.spec.ts | 12 + .../ques-form/ques-form.service.ts | 395 +++++++++++++ .../start-pd/forms/form/form.component.html | 43 ++ .../start-pd/forms/form/form.component.scss | 31 + .../forms/form/form.component.spec.ts | 25 + .../start-pd/forms/form/form.component.ts | 171 ++++++ .../list-pd/start-pd/start-pd.component.html | 5 +- .../list-pd/start-pd/start-pd.component.ts | 48 +- .../list-pd/start-pd/start-pd.module.ts | 16 +- .../list-pd/view-pd/view-pd.component.html | 5 +- .../list-pd/view-pd/view-pd.component.ts | 4 +- .../pd-service/pd-triger.service.ts | 40 +- .../assets/data/SMC_CREDIT_TEMPLATES/1.json | 206 +++++++ .../assets/data/SMC_CREDIT_TEMPLATES/2.json | 236 ++++++++ .../assets/data/SMC_CREDIT_TEMPLATES/3.json | 541 ++++++++++++++++++ 33 files changed, 2708 insertions(+), 30 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.spec.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.spec.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.spec.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.spec.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts create mode 100644 ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/1.json create mode 100644 ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/2.json create mode 100644 ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/3.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3b66410 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html index 0772f3e..2f4558f 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html @@ -25,7 +25,7 @@
- + PD Details @@ -169,7 +169,7 @@ - + Address Details @@ -243,7 +243,7 @@ - + Applicant Details diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts index 748b1b8..0322e98 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts @@ -1120,7 +1120,7 @@ searchFun(control:any,i:number,option){ } openExcelUploadModal() { const dialogRef = this.matDialog.open(ExcelUploadDialogComponent,{ - minWidth:'30vw', + minWidth:'50vw', maxWidth:'75vw' }) dialogRef.afterClosed().subscribe(result=>{ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/excel-upload-dialog/excel-upload-dialog.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/excel-upload-dialog/excel-upload-dialog.component.scss index 76245f6..e9c31fc 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/excel-upload-dialog/excel-upload-dialog.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/excel-upload-dialog/excel-upload-dialog.component.scss @@ -2,8 +2,12 @@ input[type="file"] { display: none; } .custom-file-upload { - border: 1px solid #ccc; + border: 1px solid red; display: inline-block; padding: 6px 12px; cursor: pointer; +} +.custom-file-upload :hover{ + background-color: rgba(255, 0, 0, 0.317); + color: rgba(255, 0, 0, 0.317); } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts index 3f70d0d..e8d69f8 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts @@ -68,8 +68,20 @@ export class AllPdComponent implements OnInit, OnChanges { }); this.getcommonDropDown(); - this.common = JSON.parse(localStorage.getItem('commonSettings')).default_pd_list_count; + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; this.common = this.common.count+' '+this.common.factor + } + else{ + setTimeout(()=>{ + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + },2000) + } } ngOnInit() { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts index 5c5e16f..4a46632 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts @@ -68,8 +68,20 @@ export class CompletedPdComponent implements OnInit, OnChanges { }); this.getcommonDropDown(); - this.common = JSON.parse(localStorage.getItem('commonSettings')).default_pd_list_count; + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; this.common = this.common.count+' '+this.common.factor + } + else{ + setTimeout(()=>{ + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + },2000) + } } ngOnInit() { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts index 39e2529..9ae1424 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts @@ -65,8 +65,20 @@ export class InprogressPdComponent implements OnInit, OnChanges { }); this.getcommonDropDown(); - this.common = JSON.parse(localStorage.getItem('commonSettings')).default_pd_list_count; - this.common = this.common.count+' '+this.common.factor + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + else{ + setTimeout(()=>{ + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + },2000) + } } ngOnInit() { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts index d62a553..a97b3d3 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts @@ -60,6 +60,7 @@ export class PdStatusChangeDialogueComponent implements OnInit { changePDStatus(status: string): void { let update_status = { "pd_id":this.data.pdid, + "random_string":this.data.random_string }; this.pd.editPdMasterDetails(update_status, status).subscribe(result => { if (result.status == 200) { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts index 59c04ae..40796f8 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts @@ -67,8 +67,20 @@ export class QcCompletedPdComponent implements OnInit, OnChanges { }); this.getcommonDropDown(); - this.common = JSON.parse(localStorage.getItem('commonSettings')).default_pd_list_count; + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; this.common = this.common.count+' '+this.common.factor + } + else{ + setTimeout(()=>{ + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + },2000) + } } ngOnInit() { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts index c5d8475..f89d512 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts @@ -66,8 +66,20 @@ export class ScheduledPdComponent implements OnInit, OnChanges { }); this.getcommonDropDown(); - this.common = JSON.parse(localStorage.getItem('commonSettings')).default_pd_list_count; - this.common = this.common.count+' '+this.common.factor + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + else{ + setTimeout(()=>{ + this.common = JSON.parse(localStorage.getItem('commonSettings')) + if(this.common) { + this.common =this.common.default_pd_list_count; + this.common = this.common.count+' '+this.common.factor + } + },2000) + } } ngOnInit() { 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 0000000..c0f51dc --- /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 0000000..e69de29 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 0000000..ad74d0c --- /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 0000000..51d6239 --- /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 0000000..406995e --- /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}} + + + + + {{parent_ques.question}} + + + + close + + + -- + + {{val.answer}} + + + + {{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 0000000..eec25d9 --- /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 0000000..2fbd70c --- /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 0000000..be90a00 --- /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,465 @@ +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, ReplaySubject } 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 + public commonFilterCtrl:FormControl = new FormControl(); + public ngxFilteredValue:ReplaySubject = new ReplaySubject(1); + 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)) + ) + } + if(this.parent_ques.type == '8') { + console.log("Initial",this.parent_ques.answers) + if(this.parent_ques.answers && this.parent_ques.answers.length > 0){ + this.ngxFilteredValue.next(this.parent_ques.answers.slice()) + this.filterList() + } + else{ + setTimeout(()=>{ + console.log("last",this.parent_ques.answers) + if(this.parent_ques.answers && this.parent_ques.answers.length > 0){ + this.ngxFilteredValue.next(this.parent_ques.answers.slice()) + this.filterList() + } + },1600) + } + this.filterList() + } + } + + 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) + } + } + filterList() { + this.commonFilterCtrl.valueChanges.pipe().subscribe(()=>{ + console.log("valuechanges",this.parent_ques) + if(this.parent_ques.type == '8' && this.parent_ques.answers && this.parent_ques.answers.length > 0) { + this.applyFilter(this.commonFilterCtrl.value,this.ngxFilteredValue,this.parent_ques.answers,'answer') + } + }) + + } + applyFilter(filtered_text,filter_list,raw_list,obj_name) { + if (!raw_list) { + return; + } + // get the search keyword + let search = filtered_text; + if (!search) { + filter_list.next(raw_list.slice()); + return; + } else { + search = search.toLowerCase(); + } + // filter the banks + filter_list.next( + raw_list.filter(bank => bank[obj_name].toLowerCase().indexOf(search) > -1) + ); + } + 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?){ + console.log(sec_control); + // 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); + // // updatedParams = JSON.parse(updatedParams) + // console.log(JSON.parse(updatedParams),updatedParams,JSON.parse(JSON.stringify(updatedParams))) + // debugger; + let params={records:{state_id:event.value}} + console.log("after",onChangeProperty) + this.quesService.apiCall(onChangeProperty.api,params,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 0000000..56b5b15 --- /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 0000000..d3c7cdf --- /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,395 @@ +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 { + + pd_all_details:any= {} + 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) { + if(group_indi.api_properties.hasOwnProperty('purpose') && group_indi.api_properties.purpose == 'answer_options_local') { + if(group_indi.api_properties.master_name == 'pd_applicants') { + group_indi.answers = (this.convertArrayNames( group_indi.api_properties.fields,this.pd_all_details.pdapplicants_detials)) + val.question[arr_index].answers = group_indi.answers + } + } + else{ + 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) { + if(val.api_properties.hasOwnProperty('purpose') && val.api_properties.purpose == 'answer_options_local') { + if(val.api_properties.master_name == 'pd_applicants') { + val.answers = (this.convertArrayNames( val.api_properties.fields,this.pd_all_details.pdapplicants_detials)) + } + } + else{ + 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/form/form.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.html new file mode 100644 index 0000000..e50e719 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.html @@ -0,0 +1,43 @@ +

+
+ {{main_applicant}} {{lender_applicant_id ? '('+lender_applicant_id+')' : ''}}, {{customer_segment_abbr}} - {{subproduct_abbr}}
+ {{questions_JSON.section_name}} +
+
+ +
+

+ + +
No Templates Found
+ + + + + + + + + + +
+ + +
+ +
+
+ + + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.scss new file mode 100644 index 0000000..9ee1ab3 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.scss @@ -0,0 +1,31 @@ +.paragraph_change { + color: #fff !important; + background-color: #e00201 !important; + } + ::ng-deep { .no-padding > mat-dialog-container { + // background: black; + padding: 0; + // overflow-y: scroll !important; + } +} + // mat-placeholder{ + // margin-top: 20px; + // word-wrap: break-word; + // } +// input{ +// height:40px; +// } + + .mat-form-field-label { + white-space: normal; + } + + textarea.mat-input-element { + padding: 0px 0; + margin: 5px 0; + } + + .mat-input-placeholder { + white-space: normal; + } + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.spec.ts new file mode 100644 index 0000000..0ace80a --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FormComponent } from './form.component'; + +describe('FormComponent', () => { + let component: FormComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FormComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FormComponent); + 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/form/form.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts new file mode 100644 index 0000000..d23c908 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts @@ -0,0 +1,171 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material'; +import { ActivatedRoute, Router } from '@angular/router'; +import { NotifierService } from 'angular-notifier'; +import { AwsService } from 'app/AwsService/aws.service'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; +import { QuesFormService } from '../dynamic-form/ques-form/ques-form.service'; + +@Component({ + selector: 'app-form', + templateUrl: './form.component.html', + styleUrls: ['./form.component.scss'] +}) +export class FormComponent implements OnInit { + form_id: number; + parent_pdid: any; + pdid: any; + notifier: NotifierService; + main_applicant: any; + lender_applicant_id: any; + subproduct_abbr: any; + customer_segment_abbr: any; + lenderShortName: any; + fk_pd_type: any; + image_doc_params: { pdid: any; form_id: any; company_id: string; }; + questions_JSON: any = {questions:[],section_name:''}; + commonFormGroup:FormGroup; + form_answers: any; + constructor(notifier: NotifierService, + private fb: FormBuilder, + private route: ActivatedRoute, + private router: Router, + private _pd: PdTrigerService, + private dialogRef: MatDialogRef, + private dialog: MatDialog, private quesService:QuesFormService, + @Inject(MAT_DIALOG_DATA) public pd_all_details: any, + private pdTriggerService:PdTrigerService, + private awsService:AwsService) { + // console.log(this.pd_all_details) + this.form_id = 24; + this.pd_all_details.pdmaster_details=this.pd_all_details.pdmaster_details[0] + this.parent_pdid = this.pd_all_details.pdmaster_details.parent_pd_id; + this.pdid = this.pd_all_details.pdmaster_details.pd_id; + this.notifier = notifier; + this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; + this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; + this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; + this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; + this.lenderShortName = this.pd_all_details.pdmaster_details.lender_short_name; + this.fk_pd_type = this.pd_all_details.pdmaster_details.fk_pd_type; + this.image_doc_params={pdid:this.pdid,form_id:this.form_id,company_id:''} + this.quesService.pd_all_details = this.pd_all_details + console.log('image_doc_params',this.image_doc_params) + } + + ngOnInit() { + this.loadTemplate() + if(this.pd_all_details.is_answered == '1') { + this.getSectionData() + } + else{ + this.getExcelData(); + } + } + loadTemplate() { + // let localId = this.getLocalFormId() + console.log("d",this.pd_all_details.form_id,Number(this.pd_all_details.form_id)) + // this.pdTriggerService.loadTemplate(Number(this.pd_all_details.form_id)).subscribe(result=>{ + let params = {"fk_entity_id":"35","fk_product_id":"","pd_form_id":this.pd_all_details.form_id,"fk_pd_id":this.pd_all_details.pdmaster_details.pd_id} + this.pdTriggerService.loadCreditPDTemplate(params).subscribe(result=>{ + if(result.dataStatus) { + let question_template: any = result.records + if (question_template && question_template != null && question_template != undefined + ) { + // question_template = JSON.parse(question_template) + if (question_template.hasOwnProperty('template') && question_template.template) { + question_template =JSON.parse(question_template.template); + this.commonFormGroup = new FormGroup({}) + this.questions_JSON = question_template; + console.log(this.questions_JSON); + // setTimeout(() => { + // this.covidAnswers = null + // console.log("cleared") + // }, 2000) + } + } + } + }) + } + getSectionData() { + let params = {"fk_pd_id":this.pd_all_details.pdmaster_details.pd_id,"fk_form_id":this.pd_all_details.form_id} + this.pdTriggerService.getSMCCreditPDSectionData(params).subscribe(result=>{ + if(result['dataStatus']) { + let records = result['records'] + let formValues:any ={}; + if(records && records.hasOwnProperty('json') && records.json) { + formValues = JSON.parse(records.json) + // console.log(this.form) + this.form_answers= formValues + setTimeout(()=>{ + this.form_answers = null + },2000) + // this.commonFormGroup.patchValue(formValues) + } + } + + }) + } + getExcelData() { + let params = {"pd_id":this.pd_all_details.pdmaster_details.pd_id,"random_string":this.pd_all_details.pdmaster_details.random_string,"form_id":this.pd_all_details.form_id} + this.pdTriggerService.loadDataFromExcel(params).subscribe(result=>{ + if(result['dataStatus']) { + let records = result['records'] + let formValues:any ={}; + if(records && records.length > 0) { + records.forEach(val=>{ + if(val) { + formValues[val.key_name] = val.value + } + }) + // console.log(this.form) + this.form_answers= formValues + setTimeout(()=>{ + this.form_answers = null + },2000) + // this.commonFormGroup.patchValue(formValues) + } + } + }) + } + getLocalFormId() { + console.log(this.pd_all_details) + switch(this.pd_all_details.form_id) { + case '5': + return 2 + break + case '18': + return 1 + break; + case '10': + return 3 + break; + } + + } + saveForm() { + console.log("values",this.commonFormGroup.getRawValue(),this.questions_JSON) + if(this.commonFormGroup.invalid) { + this.commonFormGroup.markAsDirty(); + this.commonFormGroup.markAsTouched() + this.notifier.notify("info","Please fill all the required fields"); + return + } + let params = {"fk_pd_id":this.pd_all_details.pdmaster_details.pd_id,"fk_form_id":this.pd_all_details.form_id,"json":this.commonFormGroup.getRawValue(),createdby:''} + this.pdTriggerService.saveSMCCreditPDsection(params).subscribe(result=>{ + if(result['dataStatus']) { + this.notifier.notify("success","Saved successfully..") + setTimeout(()=>{ + this.dialogRef.close() + },1500) + } + else { + this.notifier.notify("warning","Something went wrong"); + } + },err=>{ + this.notifier.notify("warning","Network Error"); + }) + } + +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html index bde4525..6b24c40 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html @@ -6,7 +6,8 @@ {{pdMasterList.customer_segment_name}}
-

{{pdMasterList.product_name}}/{{pdMasterList.subproduct_name}}  +

{{pdMasterList.product_name}} +

@@ -16,7 +17,7 @@
- + {{quesIndex+1}}
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 4be5791..c9efb56 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 @@ -6,6 +6,7 @@ import {NotifierService} from 'angular-notifier'; import {ListPdComponent} from './../list-pd.component'; import {PdTrigerService} from '../../../pd-service/pd-triger.service'; import { PdStatusChangeDialogueComponent } from '../pd-status-change-dialogue/pd-status-change-dialogue.component'; +import { FormComponent } from './forms/form/form.component'; @Component({ selector: 'app-start-pd', @@ -104,12 +105,13 @@ export class StartPdComponent implements OnInit, OnDestroy { data => { // console.log("after reponse = ", data); if (data.status == 200) { - this.pdMasterList=data.records.pdmaster_details; + this.pdMasterList=data.records.pdmaster_details[0] // this.categoryList=data.records.question_answers; let filterApplicantName= data.records.pdapplicants_detials.filter(item => item.applicant_type == 1); this.mainApplicantName = filterApplicantName.length > 0 ? filterApplicantName[0].applicant_name : ''; this.currentPDStatus = data.records.pdmaster_details.pd_status=='INPROGRESS' ? true : data.records.pdmaster_details.pd_status=='SCHEDULED' ? true :data.records.pdmaster_details.pd_status=='ALLOCATED' ? true : false; - this.categoryFormButtons = Object.keys(data.records.template_forms).map((item)=>data.records.template_forms[item]).filter(item=>item.isAnswerable===true); + // this.categoryFormButtons = Object.keys(data.records.template_forms).map((item)=>data.records.template_forms[item]).filter(item=>item.isAnswerable===true); + this.categoryFormButtons = data.records.template_details // this.categoryFormButtons = this.categoryFormButtons.filter(item=>item.isAnswerable===true); this.actualQuestions = this.categoryFormButtons.length; let getAnsweredFormsCount = this.categoryFormButtons.filter(item=>item.isAnswered===true); @@ -168,7 +170,45 @@ export class StartPdComponent implements OnInit, OnDestroy { } }); } - + OnSelectDirectForms(details: any) { + // console.log(details) + // this.formsCategoryEnable = true; + this.selectedFormsCategory = details; + let curr_vendor_ans_fetch_status = null + if(this.pdMasterList.fk_pd_type == '2') { + if(this.vendor_status_arr && this.vendor_status_arr.length > 0 && this.selectedFormsCategory.form_id != 13) { + console.log(this.vendor_status_arr,this.selectedFormsCategory) + curr_vendor_ans_fetch_status =this.vendor_status_arr.filter(val=>val.fk_form_id == String(this.selectedFormsCategory.form_id)) + if(curr_vendor_ans_fetch_status.length > 0) { + curr_vendor_ans_fetch_status = curr_vendor_ans_fetch_status[0].form_status + } + else { + curr_vendor_ans_fetch_status = null + } + } + } + this.pdFullDetails.pdmaster_details.curr_vendor_ans_fetch_status = curr_vendor_ans_fetch_status + this.pdFullDetails.form_id= this.selectedFormsCategory.fk_form_id + this.pdFullDetails.is_answered = this.selectedFormsCategory.is_answered + console.log(this.pdFullDetails); + const dialogRef = this.dialog.open(FormComponent, { + data: this.pdFullDetails, + // position: { right: '0'}, + maxWidth: '100vw', + maxHeight: '100vh', + height: '100%', + width: '100%', + disableClose: true, + closeOnNavigation:true, + panelClass:'no-padding' + }); + dialogRef.afterClosed() + .subscribe(dataresult => { + // this.notifier.notify('success', 'Successfully allocated.!'); + this.loadTemplates(this.startPD,2,this.randomString); + }); + } + // start // direct form based questions // OnSelectDirectForms(details: any) { @@ -536,7 +576,7 @@ export class StartPdComponent implements OnInit, OnDestroy { } // load pd view component loadPdViewCompoent() { - this.router.navigate(['../../../../viewpd', this.pdMasterList.parent_pd_id,this.randomString], {relativeTo: this.route}); + this.router.navigate(['../../../../../viewpd', this.pdMasterList.parent_pd_id,this.randomString], {relativeTo: this.route}); } } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.module.ts index e7fa795..bbe3172 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.module.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.module.ts @@ -6,6 +6,13 @@ import { StartPdComponent } from './start-pd.component'; import { SharedModule } from 'app/shared/shared.module'; import { DemoMaterialModule } from 'app/shared/demo.module'; import { NotifierModule, NotifierOptions } from 'angular-notifier'; +import { FormComponent } from './forms/form/form.component'; +import { DynamicFormComponent } from './forms/dynamic-form/dynamic-form/dynamic-form.component'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { DynamicQuestionTemplateComponent } from './forms/dynamic-form/dynamic-question-template/dynamic-question-template.component'; +import { NgxMatSelectSearchModule } from 'ngx-mat-select-search'; +import { MatIconModule } from '@angular/material'; const pdCustomNotifierOptions: NotifierOptions = { position: { @@ -54,9 +61,14 @@ const pdCustomNotifierOptions: NotifierOptions = { StartPdRoutingModule, SharedModule, DemoMaterialModule, + ReactiveFormsModule, + FormsModule, + FlexLayoutModule, NotifierModule.withConfig(pdCustomNotifierOptions), + NgxMatSelectSearchModule, + MatIconModule ], - declarations: [StartPdComponent], - entryComponents:[] + declarations: [StartPdComponent, FormComponent,DynamicFormComponent,DynamicQuestionTemplateComponent], + entryComponents:[FormComponent] }) export class StartPdModule { } 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 19ef20e..dfacff8 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 @@ -142,6 +142,7 @@
+ - +
@@ -197,7 +198,7 @@
- +
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 aac0454..1bcb301 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 @@ -295,9 +295,9 @@ export class ViewPdComponent implements OnInit, OnDestroy { // start pd getPDStart(pdDetails: any, status: string) { this.destroyType = 3; - if (status == this.pdStatusCheck.ALLOCATED || status == this.pdStatusCheck.SCHEDULED) { + if (status == this.pdStatusCheck.ALLOCATED || status == this.pdStatusCheck.SCHEDULED || status == this.pdStatusCheck.TRIGGERED) { const dialogRef = this.dialog.open(PdStatusChangeDialogueComponent, { - data: { pdid: pdDetails.assigned_pd, pd_status: this.pdStatusCheck.INPROGRESS }, + data: { pdid: pdDetails.assigned_pd, pd_status: this.pdStatusCheck.INPROGRESS,random_string:this.pdMasterData[0].random_string }, disableClose: true, minWidth: '30%', maxWidth: '40%', 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 a9a06d9..37d4199 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 @@ -168,10 +168,11 @@ export class PdTrigerService { // get pd details getPdDetails(lenderId): Observable { - let userid=this._aws.getlocale() + let entity_id=localStorage.getItem('LocalSetEntity'); + // let userid=this._aws.getlocale() - const Lender = userid ? - { params: new HttpParams().set('lenderid', userid) } : {}; + const Lender = entity_id ? + { params: new HttpParams().set('lenderid', entity_id) } : {}; return this._http.get(this.apiUrl + "listLessPDDetails/get",Lender) .pipe( catchError(this.handleError('operation', [])) @@ -183,10 +184,11 @@ export class PdTrigerService { // const tabStatus = status ? // { params: new HttpParams().set('status', status)} : {}; + let entity_id=localStorage.getItem('LocalSetEntity'); let userid_local:string=this._aws.getlocale() - const paramHttp= userid_local && status ? - {params : new HttpParams().set('lenderid', userid_local).set('status',status)} : {}; + const paramHttp= entity_id && status ? + {params : new HttpParams().set('lenderid', entity_id).set('status',status)} : {}; return this._http.get(this.apiUrl + "listLessPDDetails/get", paramHttp) .pipe( catchError(this.handleError('operation', [])) @@ -267,7 +269,9 @@ export class PdTrigerService { loadPDTemplates(pdId: string,randString): Observable { const options = pdId ? { params: new HttpParams().set('pd_id', pdId).set('random_string',randString) } : {}; - return this._http.get(this.apiUrl + "loadFullTemplate", options) + // return this._http.get(this.apiUrl + "loadFullTemplate", options) + return this._http.get(this.apiUrl + "loadSMCPDTemplate", options) + .pipe( catchError(this.handleError('operation', [])) ) @@ -797,6 +801,30 @@ uploadSMCDataFile(file) { formData.append("records",JSON.stringify(records)) return this._http.post(this.apiUrl+'uploadSMCDataFile',formData) } +loadTemplate(form_id) { + return this._http.get('assets/data/SMC_CREDIT_TEMPLATES/'+form_id+'.json').map(rr=>{ + let returnValue ={dataStatus:true,status:200,records:{template:JSON.stringify(rr)}} + // this.raw_credit_pd_template= returnValue.records.template + return returnValue + }) + } + loadCreditPDTemplate(params):Observable { + return this._http.post(this.apiUrl+'loadCreditPDTemplate',params) + .pipe(catchError(this.handleError("loadCreditPDTemplate",[]))) + } + saveSMCCreditPDsection(params1):Observable { + params1.createdby = this._aws.getlocale() + // "fk_pd_id":"1","fk_form_id":"1","json":"SOMEDATA","fk_createdby":"12" + // let params = {"records":{"smc_credit_pd":this.curr_credit_pd_data.smc_credit_pd,"lender_id":this.curr_credit_pd_data.lender_id,"product_id":this.curr_credit_pd_data.product_id,"fk_createdby":this._awsService.getlocale(),"geo_location":"","section_id":params1.section_id,"questions":params1.questions,"is_complete":"0"}} + return this._http.post(this.apiUrl+'saveSMCCreditPDsection',{records:params1}) + } + getSMCCreditPDSectionData(params) { + // {"fk_pd_id":"1","fk_form_id":"1"} + return this._http.post(this.apiUrl+'getSMCCreditPDSectionData',{records:params}) + } + loadDataFromExcel(params) { + return this._http.post(this.apiUrl+'loadDataFromExcel',{records:params}) + } } diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/1.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/1.json new file mode 100644 index 0000000..4802437 --- /dev/null +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/1.json @@ -0,0 +1,206 @@ +{ + "section_id":"1", + "section_name":"Borrower & Guarantor Details", + "onsubmit":null, + "questions":[ + { + "question":"Borrower Type", + "question_key":"borrower_type", + "type":"1", + "field_width":"100", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Name", + "question_key":"borrower_name", + "type":"1", + "field_width":"100", + "onchange_properties":null, + "api_properties":null, + "answers":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Entity Type", + "question_key":"entity_type", + "type":"1", + "field_width":"100", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Designation", + "question_key":"designation", + "type":"1", + "field_width":"100", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Relationship to", + "question_key":"relationship_to", + "type":"1", + "field_width":"100", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Relationship", + "question_key":"relationship", + "type":"1", + "field_width":"100", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Relationship", + "question_key":"relationship", + "type":"1", + "field_width":"100", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Met / Not Met", + "question_key":"borrower_met", + "type":"2", + "field_width":"100", + "api_properties":null, + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes" + }, + { + "answer_id":"No", + "answer":"No" + } + ], + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Age", + "question_key":"borrower_age", + "type":"1", + "field_width":"45", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Numbers of years for which the business has been running", + "question_key":"numbers_of_years_business_running", + "type":"1", + "field_width":"45", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + } + ] +} diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/2.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/2.json new file mode 100644 index 0000000..ab86e51 --- /dev/null +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/2.json @@ -0,0 +1,236 @@ +{ + "section_id":"2", + "section_name":"Address details", + "onsubmit":null, + "questions":[ + { + "question":"Address at which PD was initiated", + "question_key":"initiated_address", + "type":"7", + "field_width":"100", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Is this the address where PD is done ?", + "question_key":"is_pd_done_on_initiated_address", + "type":"2", + "field_width":"45", + "onchange_properties": [{ + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"is_pd_done_on_initiated_address", + "expression":"(String('is_pd_done_on_initiated_address') == String('No'))", + "value_keys":[ + "is_pd_done_on_initiated_address" + ], + "questions":[ + { + "question":"Enter actual PD address", + "question_key":"alternative_address", + "place_holder":"", + "field_type":"string", + "type":"7", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"is_pd_done_on_initiated_address", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + } + ] + }], + "api_properties":null, + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes" + }, + { + "answer_id":"No", + "answer":"No" + } + ], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Type of PD address", + "question_key":"address_type", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"ADDRESSTYPE" + }, + "fields":[ + "address_type_id", + "address_type" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"PD locality", + "question_key":"pd_locality", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"LOCALITY" + }, + "fields":[ + "locality_id", + "locality_name" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Approach to PD location*", + "question_key":"pd_location", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"PDLOCATIONAPPROACH" + }, + "fields":[ + "pd_location_approach_id", + "description" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Comment on locality", + "question_key":"comment_locality", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"COMMENTSONLOCALITY" + }, + "fields":[ + "comments_on_locality_id", + "rating" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Estimated Area of the business along with UOM", + "question_key":"business_estimated_area", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"UOM" + }, + "fields":[ + "uom_id", + "name" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + } + ] + } + \ No newline at end of file diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/3.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/3.json new file mode 100644 index 0000000..1b21750 --- /dev/null +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/3.json @@ -0,0 +1,541 @@ +{ + "section_id":"2", + "section_name":"Loan details", + "onsubmit":null, + "questions":[ + { + "question":"Loan amount applied for", + "question_key":"loan_amount", + "type":"1", + "field_width":"100", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Loan Tenure", + "question_key":"loan_tenure", + "type":"1", + "field_width":"100", + "onchange_properties": null, + "api_properties":null, + "answers":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Sub Product", + "question_key":"sub_product", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"SUBPRODUCTS" + }, + "fields":[ + "subproduct_id", + "name" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"End use of loan", + "question_key":"end_use", + "type":"1", + "field_width":"100", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Total fund requirement", + "question_key":"total_fund_requirement", + "type":"1", + "field_width":"45", + "api_properties":null, + "answers":null, + "onchange_properties": [{ + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"total_fund_requirement", + "expression":"(String('total_fund_requirement') != String(''))", + "value_keys":[ + "total_fund_requirement" + ], + "questions":[ + { + "question":"Fund Requirement for end use", + "question_key":"end_use_fund_requirement", + "place_holder":"", + "field_type":"string", + "type":"1", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"total_fund_requirement", + "answers":null, + "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":"Is there a BT?", + "question_key":"is_transfer", + "type":"9", + "field_width":"45", + "api_properties":null, + "answers":[ + { + "answer_id":"Yes", + "answer":"Yes" + }, + { + "answer_id":"No", + "answer":"No" + } + ], + "onchange_properties": [{ + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"is_transfer", + "expression":"(String('is_transfer') == String('Yes'))", + "value_keys":[ + "is_transfer" + ], + "questions":[ + { + "question":"What is the amount of balance transfer", + "question_key":"balance_transfer_amount", + "place_holder":"", + "field_type":"numtoword", + "type":"1", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"is_transfer", + "answers":null, + "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":"Lender from where BT is done", + "question_key":"lender", + "type":"8", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"BTLENDERLIST" + }, + "fields":[ + "bt_lender_list_id", + "lender_name" + ] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Top up amount", + "question_key":"topup_amount", + "type":"1", + "field_type":"numtoword", + "field_width":"45", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Type of property being Mortgaged", + "question_key":"property_type", + "type":"1", + "field_width":"45", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Name of Owner", + "question_key":"owner_name", + "type":"3", + "field_width":"45", + "api_properties": + { + "purpose":"answer_options_local", + "master_name":"pd_applicants", + "fields":["pd_co_applicant_id","applicant_name"] + }, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field Required", + "value":null + } + ] + }, + { + "question":"Property Completion Stage", + "question_key":"construction_status", + "type":"1", + "field_width":"45", + "api_properties":null, + "answers":null, + "onchange_properties":[ + { + "insert_index":"construction_status", + "expression":"(String('construction_status') == String('Under Construction'))", + "value_keys":[ + "construction_status" + ], + "questions":[ + { + "question":"Stage of Construction", + "question_key":"construction_stage", + "place_holder":"", + "field_type":"string", + "type":"1", + "field_width":"45", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"construction_status", + "answers":null, + "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":"Estimated market value as per customer", + "question_key":"emv_per_customer", + "place_holder":"", + "field_type":"numtoword", + "type":"1", + "field_width":"100", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + }, + { + "question":"Market Value Considered for LTV Calculation (Rs)", + "question_key":"ltv_market_value_calculation", + "place_holder":"", + "field_type":"numtoword", + "type":"1", + "field_width":"45", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + }, + { + "question":"Address of the proposed property", + "question_key":"address", + "place_holder":"Enter door no,street", + "type":"7", + "answers":null, + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Address Required", + "value":null + } + ] + }, + { + "question":"State", + "question_key":"state", + "type":"8", + "field_width":"45", + "answers":null, + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"STATE" + }, + "fields":[ + "state_id", + "name" + ] + }, + "onchange_properties":[ + { + "purpose":"api", + "api":"getListOfStatesAndCities", + "api_method":"POST", + "params":"{records:{state_id:'value_of_answer'}}", + "fields":[ + "state_id", + "name" + ], + "local_variable":"local_city" + } + ], + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"State Required", + "value":null + } + ] + }, + { + "question":"City", + "question_key":"city", + "type":"8", + "field_width":"45", + "answers":null, + "api_properties":"local_city", + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"CIty Required", + "value":null + } + ] + }, + { + "question":"Pincode", + "question_key":"pincode", + "type":"8", + "field_width":"45", + "answers":null, + "api_properties":"local_pincode", + "onchange_properties":null, + "is_repeatable":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Pincode Required", + "value":null + } + ] + }, + { + "question":"Property Usage", + "question_key":"property_usage", + "place_holder":"", + "field_type":"string", + "type":"1", + "field_width":"45", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + }, + { + "question":"Structure Type", + "question_key":"structure_type", + "place_holder":"", + "field_type":"string", + "type":"1", + "field_width":"45", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + + ] + } + \ No newline at end of file