From c5259757ba2be4beed443af5efb7485691de8281 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Aug 2021 17:43:47 +0530 Subject: [PATCH] latest changes --- .../dynamic-form/dynamic-form.component.ts | 10 +-- .../dynamic-question-template.component.ts | 14 ++--- .../ques-form/ques-form.service.ts | 62 +++++++++++-------- .../start-pd/forms/form/form.component.ts | 37 +++++++++-- .../data/SMC_CREDIT_TEMPLATES/LFMP/5.json | 22 +++++-- package.json | 1 + 6 files changed, 95 insertions(+), 51 deletions(-) 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 index f40d096..ac74359 100644 --- 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 @@ -22,15 +22,11 @@ export class DynamicFormComponent implements OnInit { @ViewChild('mapanel') matExpansionPanel:MatExpansionPanel @ViewChild('accordion') Accordion: MatAccordion constructor(private _fb:FormBuilder,private questionService:QuesFormService) { } - + ngOnInit() { - //console.log('testing'); - // console.log(this.json_answers); - // this.questions_JSON.questions.push({"ans_length":this.json_answers.key_stakeholders.length}) - //this.length=this.questionService.ques_length(this.json_answers.key_stakeholders.length) + this.form_group_name=this.questionService.assignFormControl_array(this.form_group_name,this.questions_JSON.questions) - - // debugger + this.generateGroupControls(); } 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 index 1895365..2f785d9 100644 --- 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 @@ -30,13 +30,11 @@ export class DynamicQuestionTemplateComponent implements OnInit { autoCompleteAns:Observable public commonFilterCtrl:FormControl = new FormControl(); public ngxFilteredValue:ReplaySubject = new ReplaySubject(1); - parent_ques1: any; + constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog, private loaderService:LoaderService) { } ngOnInit() { - this.parent_ques = this.currFormArrayObj - 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(''), @@ -68,7 +66,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { vintage_in_current_biz2: 6, total_work_exp2: 0, started_biz2: "", - + stakeholder_length:'2', company_name: 3}, { stakeholder_name0: "SUMIT KHANDELWAL", @@ -93,7 +91,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { total_work_exp2: 8, started_biz2: "", - + stakeholder_length:'2', company_name: 2},{ stakeholder_name0: "SUMIT KHANDELWAL", share_holding0: 25, @@ -117,7 +115,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { total_work_exp2: 9, started_biz2: "", - + stakeholder_length:'2', company_name: 1} ] @@ -129,7 +127,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { if(this.json_answers!=null && this.json_answers!= undefined && this.json_answers&& !this.group_key) { this.formGroupN.get(this.parent_ques.question_key).patchValue((this.json_answers[this.parent_ques.question_key] || '')) - // this.formGroupN.get(this.parent_ques1.question_key).patchValue((this.json_answers[1][this.parent_ques1.question_key] || '')) + this.onChangeProperty({value:this.json_answers[this.parent_ques.question_key]},this.parent_ques,'','','','TS') } else if(this.json_answers!=null && this.json_answers != undefined && this.json_answers){ @@ -142,7 +140,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { this.generateGroupControls.emit() } - console.log(this.json_answers); + this.json_answers.forEach((value,index)=>{ 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 index 3708cbd..1261dff 100644 --- 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 @@ -13,11 +13,12 @@ export class QuesFormService { formgroup_company:FormGroup; ques_data_company:any; company_name:any; - + length:any; + len:any; formanswers=null; pd_all_details:any= {} datepipe: DatePipe; - length: string; + //length: any; constructor(private _fb:FormBuilder,private http:HttpClient) { this.datepipe=new DatePipe('en-US') // this.apiUrl = constantProvider.environment().url @@ -32,25 +33,25 @@ export class QuesFormService { // console.log(choosed_answer_obj.answer) // if(choosed_answer_obj.answer!='') // { - // console.log('changed'); + // console.log(hanged'); // this.company_name=choosed_answer_obj.answer // } // } - + ques_length(length1: any) + { + this.len=length1; + + // return length1; + } assignFormControl_array(formgroup: FormGroup, ques_data: any) { - + const control: any = formgroup - console.log('control'); - console.log(formgroup); - ques_data.forEach((val, index) => { 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] @@ -58,19 +59,28 @@ export class QuesFormService { // })) control.addControl(val.group_key, this._fb.array([])) - - + + let childControl: any = control.get(val.group_key) as FormArray + //let childControl1: any = control.get(val.value) as FormArray - console.log('childControl'); - console.log(childControl); - console.log(val.group_key); + // const formControlArray = []; + // FormArray.forEach(data => { + // formControlArray.push(new FormControl(data.value)); + // }) + // console.log('tamil'); + // console.log(formControlArray); + //formgroup = new FormGroup ({ + // data: this.fb.array(formControlArray) + // }); + + // childControl.push(this._fb.group({ 'questions': this._fb.array([]) })) - this.length='3'; - if(this.length=='3' && val.form_name=='Key Stakeholders in Business') + + if(this.len=='3' && val.form_name=='Key Stakeholders in Business') { - + val.question.push({ "question":"", "question_key":"stakeholder_name1", @@ -154,7 +164,7 @@ export class QuesFormService { "questions":[ { "question_key":"previous_experience_details1", - "question":"Previous Experience Details1", + "question":"Previous Experience Details", "place_holder":"Enter text", "type":"1", @@ -212,7 +222,7 @@ export class QuesFormService { ], "questions":[ { - "question":"Previous Experience Details1", + "question":"Previous Experience Details", "question_key":"previous_experience_details1", "place_holder":"Enter text", "type":"1", @@ -349,8 +359,8 @@ export class QuesFormService { ], "questions":[ { - "question_key":"previous_experience_details1", - "question":"Previous Experience Details1", + "question_key":"previous_experience_details2", + "question":"Previous Experience Details", "place_holder":"Enter text", "type":"1", @@ -408,7 +418,7 @@ export class QuesFormService { ], "questions":[ { - "question":"Previous Experience Details2", + "question":"Previous Experience Details", "question_key":"previous_experience_details2", "place_holder":"Enter text", "type":"1", @@ -466,7 +476,7 @@ export class QuesFormService { } ) } - else if(this.length=='2' && val.form_name=='Key Stakeholders in Business') + else if(this.len=='2' && val.form_name=='Key Stakeholders in Business') { val.question.push({ @@ -552,7 +562,7 @@ export class QuesFormService { "questions":[ { "question_key":"previous_experience_details1", - "question":"Previous Experience Details1", + "question":"Previous Experience Details", "place_holder":"Enter text", "type":"1", "api_properties":null, @@ -609,7 +619,7 @@ export class QuesFormService { ], "questions":[ { - "question":"Previous Experience Details1", + "question":"Previous Experience Details", "question_key":"previous_experience_details1", "place_holder":"Enter text", "type":"1", 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 index eaeb2ac..7877b15 100644 --- 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 @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit, ViewChild } from '@angular/core'; +import { Component, Inject, OnInit, ViewChild, Input } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material'; import { ActivatedRoute, Router } from '@angular/router'; @@ -30,6 +30,7 @@ export class FormComponent implements OnInit { questions_JSON: any = {questions:[],section_name:''}; commonFormGroup:FormGroup; form_answers: any; + @Input() json_answers:any; @ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent is_loading: boolean = false; constructor(notifier: NotifierService, @@ -40,7 +41,7 @@ export class FormComponent implements OnInit { private dialogRef: MatDialogRef, private dialog: MatDialog, public quesService:QuesFormService, @Inject(MAT_DIALOG_DATA) public pd_all_details: any, - + private pdTriggerService:PdTrigerService, private awsService:AwsService,private loaderService:LoaderService) { // console.log(this.pd_all_details) @@ -63,8 +64,7 @@ export class FormComponent implements OnInit { } ngOnInit() { - //alert(this.formanswers) - //alert(this.quesService.formanswers); + this.loadTemplate() console.log("answered",this.pd_all_details.is_answered) if(this.pd_all_details.is_answered == '1') { @@ -137,7 +137,19 @@ export class FormComponent implements OnInit { let formValues:any ={}; if(records && records.hasOwnProperty('json') && records.json) { formValues = JSON.parse(records.json) - // console.log(this.form) + + console.log('getsectionn'); + console.log(formValues); + if(formValues.key_stakeholders[0].stakeholder_length=='2') + { + let controlcount='2'; + this.quesService.ques_length(controlcount) + } + else + { + let controlcount1='3'; + this.quesService.ques_length(controlcount1) + } this.quesService.formanswers= formValues this.loaderService.showMatSpinnerDialog("") // setTimeout(()=>{ @@ -164,6 +176,21 @@ export class FormComponent implements OnInit { let formValues:any ={}; if(records ) { formValues = records + console.log('excel'); + console.log(formValues) + if(formValues.key_stakeholders[0].stakeholder_length=='2') + { + let controlcount='2'; + this.quesService.ques_length(controlcount) + } + else + { + let controlcount1='3'; + this.quesService.ques_length(controlcount1) + } + let datalength=formValues.key_stakeholders[0] + console.log(Object.keys(datalength).length); + // records.forEach(val=>{ // if(val) { // formValues[val.key_name] = val.value diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/5.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/5.json index 1c2ac43..eeb246c 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/5.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/5.json @@ -7,7 +7,7 @@ { "question":[ { - "question":"Name of the Company", + "question":"Name of the Entity", "question_key":"company_name", "place_holder":"Enter text", "type":"3", @@ -32,12 +32,24 @@ "name":"required", "isactive":"1", "validator":"Validators.required", - "message":"Company Name Required", + "message":"Entity Name Required", "value":null } ] - }, + }, + { + "question":"length", + "question_key":"stakeholder_length", + "type":"hidden", + + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string" + }, + { "question":"Name of key Stakeholder", "question_key":"stakeholder_name0", @@ -121,7 +133,7 @@ "questions":[ { "question_key":"previous_experience_details0", - "question":"Previous Experience Details0", + "question":"Previous Experience Details", "place_holder":"Enter text", "type":"1", @@ -179,7 +191,7 @@ ], "questions":[ { - "question":"Previous Experience Details0", + "question":"Previous Experience Details", "question_key":"previous_experience_details0", "place_holder":"Enter text", "type":"1", diff --git a/package.json b/package.json index 0967ef4..b44c264 100644 --- a/package.json +++ b/package.json @@ -1 +1,2 @@ {} + \ No newline at end of file