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 798f51d..bfd0423 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 @@ -16,6 +16,7 @@ export class DynamicFormComponent implements OnInit { @Input() questions_JSON:any; @Input() json_answers:any; step: number=0; + isDefaultGenerated:boolean = false step_child:number = 0 @ViewChild('mapanel') matExpansionPanel:MatExpansionPanel @ViewChild('accordion') Accordion: MatAccordion @@ -31,7 +32,8 @@ export class DynamicFormComponent implements OnInit { this.generateGroupControls(); } generateGroupControls() { - if(this.json_answers && this.json_answers != null ){ + if(this.json_answers && this.json_answers != null){ + this.isDefaultGenerated = true; this.questions_JSON.questions.forEach(parent_ques=>{ // debugger; 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 f77a095..e19bf8b 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 @@ -5,6 +5,7 @@ import { startWith, map } from 'rxjs/operators'; import { Observable, ReplaySubject } from 'rxjs'; import { MatDialog } from '@angular/material'; import { AnswerOptionCreateDialogComponent } from '../../answer-option-create-dialog/answer-option-create-dialog.component'; +import { LoaderService } from 'app/shared/loaderService/loader.service'; @Component({ selector: 'app-dynamic-question-template', @@ -27,7 +28,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { autoCompleteAns:Observable public commonFilterCtrl:FormControl = new FormControl(); public ngxFilteredValue:ReplaySubject = new ReplaySubject(1); - constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog) { } + constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog, private loaderService:LoaderService) { } ngOnInit() { this.parent_ques = this.currFormArrayObj @@ -50,7 +51,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.onChangeProperty({value:this.json_answers[this.parent_ques.question_key]},this.parent_ques,'') + 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){ // this.formGroupN.patchValue((this.json_answers[this.group_key] || '')) @@ -74,7 +75,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { if(this.whole_form.get(this.group_key) && this.whole_json.length > 0) { let curr_obj=this.whole_json.filter(vl=>vl.question_key == vv)[0] - this.onChangeProperty({value:value[vv]},curr_obj,'') + this.onChangeProperty({value:value[vv]},curr_obj,'','','','TS') } } @@ -98,7 +99,12 @@ export class DynamicQuestionTemplateComponent implements OnInit { // setTimeout(()=>{ // this.json_answers = null // },700) - this.quesService.formanswers=null; + // if(this.json_answers == ) + // console.log("KEY TO BE FIND",this.json_index,this.whole_json) + setTimeout(() => { + // this.quesService.formanswers=null; + this.loaderService.closeMatSpinnerDialog(); + },0) } // console.log(this.parent_ques,this.formGroupN,this.whole_json ,this.json_answers); @@ -169,7 +175,12 @@ export class DynamicQuestionTemplateComponent implements OnInit { control.removeAt(i); } } - onChangeProperty(event,sec_control,question_key,options?,sec_index?){ + onChangeProperty(event,sec_control,question_key,options?,sec_index?,from?){ + console.log(from,"sadf") + if(!from && from != 'TS' && this.quesService.formanswers != null) { + console.log("Value changes",from); + this.quesService.formanswers = null + } // this.fileredSearchValue=[] @@ -325,12 +336,12 @@ export class DynamicQuestionTemplateComponent implements OnInit { // for calculation field from multiple arr values if(onChangeProperty.purpose == 'answer_value_arr') { let index = JSON.parse(JSON.stringify(this.json_index)) - this.setModifiedValuetoControl_frommultiple(onChangeProperty,this.whole_form.get(this.group_key),index) + this.setModifiedValuetoControl_frommultiple(onChangeProperty,this.whole_form.get(this.group_key),index,sec_control) } }) } } - setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index ?) { + setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index ?,sec_control?) { if(curr_obj && curr_obj.value_keys.length > 0 && curr_obj.arr_include.length > 0 ) { let expression_value=curr_obj.expression @@ -360,12 +371,20 @@ export class DynamicQuestionTemplateComponent implements OnInit { let control_value = formArray.getRawValue()[value_index] ? formArray.getRawValue()[value_index][value] : '' if(control_value) { + + if(sec_control.type == '1' && sec_control.field_type == 'num' || sec_control.field_type == 'numtoword') { + let val = Number(control_value) + + if(val == undefined || isNaN(val)) { + control_value = 0 + } + } expression_value = expression_value.split(value+'['+index_str+']').join(control_value) } else{ if(formArray.value.length > curr_index+1) { - this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1) + this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1,sec_control) } return @@ -373,6 +392,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } if(expression_value) { + let calc_exp=eval(expression_value) if(calc_exp){ @@ -383,7 +403,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { formArray.controls[curr_index].controls[curr_obj.insert_control].setValue(calc_exp) if(formArray.value.length > curr_index+1) { - this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1) + this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1,sec_control) } } } 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 index 9ac7a0e..8708743 100644 --- 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 @@ -12,7 +12,8 @@ -
No Templates Found
+
No Templates Found
+
Loading...