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 index b9c772c..d569073 100644 --- 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 @@ -93,7 +93,7 @@ {{parent_ques.question}} - Select + {{val.answer}} 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 d472ab1..1932f04 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 @@ -262,7 +262,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { }) } else{ - this.quesService.apiCall(onChangeProperty.api,onChangeProperty.params,onChangeProperty.api_method).subscribe(result=>{ + this.quesService.apiCall(onChangeProperty.api,onChangeProperty.params,onChangeProperty.api_method).subscribe((result:any)=>{ if(result['dataStatus']){ if(result.hasOwnProperty('records')){ result=result['records'] @@ -271,6 +271,10 @@ export class DynamicQuestionTemplateComponent implements OnInit { // if(options == 2){ // ques_control=group_ques.controls.questions['controls'] // } + if(onChangeProperty.hasOwnProperty('filter_properties') && onChangeProperty.filter_properties && result.length > 0) { + let filter_properties = onChangeProperty.filter_properties + result = result.filter(vv=>vv[filter_properties.key_name] == filter_properties.value) + } this.whole_json.forEach((val,index)=>{ @@ -524,7 +528,6 @@ export class DynamicQuestionTemplateComponent implements OnInit { this.quesService.addAdditionalControl(val, this.formGroupN, question_index_after+1,"") } console.log("After adding control",this.whole_json,this.formGroupN,this.whole_form); - } } else{ @@ -543,11 +546,23 @@ export class DynamicQuestionTemplateComponent implements OnInit { this.whole_json.splice(index,1) this.formGroupN.controls[val.question_key].reset() this.formGroupN.removeControl(val.question_key); + this.checkAndRemoveSubQuestion(control_key,ques_control) + // let getSubQuestion = this.whole_json.filter(vv=>vv.parent_question_key == control_key.question_key) + // console.log(getSubQuestion,control_key,this.whole_json) } } }) } } + checkAndRemoveSubQuestion(question_obj,ques_control) { + let getSubQuestion = this.whole_json.filter(vv=>vv.parent_question_key == question_obj.question_key) + if(getSubQuestion.length > 0) { + getSubQuestion.forEach(val=>{ + this.addOrRemoveControl(val,ques_control,'',2,val) + }) + } + console.log(getSubQuestion,question_obj,this.whole_json) + } setValidations_onChange(validation_obj_raw,group_ques,sec_control,sec_index){ @@ -665,6 +680,9 @@ export class DynamicQuestionTemplateComponent implements OnInit { } updateValidationMsg(ques_control,validation_obj){ console.log("updae msg",ques_control,validation_obj); + if(!ques_control) { + return; + } let updateMsg=ques_control.validations.filter(val=>val.name != validation_obj.name) updateMsg.push(validation_obj) // ques_control.controls.validations.setValue(updateMsg); 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 7b631b0..f64735c 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 @@ -223,10 +223,14 @@ export class QuesFormService { 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=>{ + this.apiCall(val.api_properties.api,val.api_properties.params,val.api_properties.api_method).subscribe((res:any)=>{ if(res['dataStatus']){ if(res.hasOwnProperty('records')){ res=res['records'] + } + if(val.api_properties.hasOwnProperty('filter_properties') && val.api_properties.filter_properties && res.length > 0) { + let filter_properties = val.api_properties.filter_properties + res = res.filter(vv=>vv[filter_properties.key_name] == filter_properties.value) } resolve(res) console.log(res) diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/11.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/11.json index 135293a..73ec622 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/11.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/11.json @@ -367,7 +367,21 @@ "value":null } ] - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/12.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/12.json index 809c231..5440241 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/12.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/12.json @@ -367,7 +367,21 @@ "value":null } ] - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/14.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/14.json index 7fa5d20..6f19b9e 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/14.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/14.json @@ -98,7 +98,21 @@ "value":null } ] - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] } \ No newline at end of file diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/16.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/16.json index da9cc1f..7f590cd 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/16.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/16.json @@ -182,6 +182,20 @@ "value":null } ] + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] } ] diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/18.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/18.json index e09078b..481c1aa 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/18.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/18.json @@ -34,6 +34,20 @@ "is_repeatable":"1", "group_title":"Query", "group_key":"cm_queries" - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] } \ No newline at end of file diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/2.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/2.json index 33fc031..44f02c2 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/2.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/2.json @@ -333,6 +333,20 @@ "value":null } ] + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] } ] } diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/3.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/3.json index 119cb4b..c5f06db 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/3.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/3.json @@ -612,6 +612,20 @@ "value":null } ] + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] } ] 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 2bd4021..9ea7618 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 @@ -198,6 +198,20 @@ "is_repeatable":"1", "group_title":"Details of Key Stakeholders in the Business", "group_key":"key_stakeholders" - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] } \ No newline at end of file diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/6.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/6.json index 634c009..50dd4e5 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/6.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/6.json @@ -89,6 +89,20 @@ } ], "onchange_properties":null + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] } ] } \ No newline at end of file diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/7.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/7.json index e036637..6d51168 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/7.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/7.json @@ -110,7 +110,21 @@ "field_width":"45", "validations":[ ] - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/8.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/8.json index ce3f38f..240e19a 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/8.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/8.json @@ -23,7 +23,7 @@ ] }, { - "question":" Is this the business address?", + "question":" Is this the business address?", "question_key":"is_business_address", "type":"2", "field_width":"100", @@ -397,9 +397,211 @@ "fields":[ "id", "name" - ] + ], + "filter_properties":{ + "key_name":"flag", + "value":"1" + } }, - "onchange_properties":null, + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"business_assets_mode", + "expression":"(String('business_assets_mode') == String('2'))", + "value_keys":[ + "business_assets_mode" + ], + "questions":[ + { + "question":"Property Type", + "question_key":"property_type", + "place_holder":"", + "field_type":"string", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"ADDRESSTYPE" + }, + "fields":[ + "address_type_id", + "address_type" + ] + }, + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[{ + "insert_index":"property_type", + "expression":"String('property_type') && (String('property_type') != String('')) && (String('business_assets_mode') == String('2'))", + "value_keys":[ + "property_type", + "business_assets_mode" + ], + "questions":[ + { + "question":"Address of the property", + "question_key":"property_address", + "place_holder":"", + "field_type":"string", + "type":"7", + "field_width":"45", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"property_type", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + }, + { + "insert_index":"property_type", + "expression":"(String('property_type') == String('1')) && (String('business_assets_mode') == String('2'))", + "value_keys":[ + "property_type", + "business_assets_mode" + ], + "questions":[ + { + "question":"Specify the Property", + "question_key":"property_type_others", + "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":"property_type", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + }] + } + ], + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"business_assets_mode", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + }, + { + "insert_index":"business_assets_mode", + "expression":"(String('business_assets_mode') == String('3'))", + "value_keys":[ + "business_assets_mode" + ], + "questions":[ + { + "question":"Type of Vehicle", + "question_key":"vehicle_type", + "place_holder":"", + "field_type":"string", + "type":"3", + "field_width":"45", + "api_properties":{ + "api":"getListOfMaster", + "api_method":"POST", + "params":{ + "master_name":"VEHICLETYPE" + }, + "fields":[ + "vehicle_type_id", + "vehicle_type_name" + ] + }, + "onchange_properties":[ + { + "purpose":"FORM_CTRL", + "form_controls":[ + { + "insert_index":"vehicle_type", + "expression":"(String('vehicle_type') == String('1')) && (String('business_assets_mode') == String('3'))", + "value_keys":[ + "vehicle_type", + "business_assets_mode" + ], + "questions":[ + { + "question":"Specify the Vehicle", + "question_key":"vehicle_type_others", + "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":"vehicle_type", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + }] + } + ], + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"business_assets_mode", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + } + ] + } + ] + } + ], "is_repeatable":null, "answers":null, "validations":[ @@ -422,13 +624,6 @@ "is_repeatable":null, "answers":null, "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Field required", - "value":null - } ] }, { @@ -449,33 +644,33 @@ "business_ownership_type" ], "questions":[ - { - "question":"Approximate Market value", - "question_key":"business_approximate_market_value", - "place_holder":"", - "field_type":"numtoword", - "type":"1", - "field_width":"45", - "api_properties":null, - "onchange_properties":null, - "is_repeatable":null, - "is_subfield":"1", - "parent_question_key":"business_ownership_type", - "answers":null, - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Field required", - "value":null - } - ] - }, + { + "question":"Approximate Market value", + "question_key":"business_approximate_market_value", + "place_holder":"", + "field_type":"numtoword", + "type":"1", + "field_width":"45", + "api_properties":null, + "onchange_properties":null, + "is_repeatable":null, + "is_subfield":"1", + "parent_question_key":"business_ownership_type", + "answers":null, + "validations":[ + { + "name":"required", + "isactive":"1", + "validator":"Validators.required", + "message":"Field required", + "value":null + } + ] + }, { - "question":"Factory owned by", + "question":"Asset owned by", "question_key":"business_name_of_the_owner", - "type":"3", + "type":"4", "field_width":"45", "api_properties": { @@ -673,7 +868,21 @@ "value":null } ] - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/9.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/9.json index 2765688..e2ac691 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/9.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/LFMP/9.json @@ -107,6 +107,20 @@ "is_repeatable": "1", "group_title": "Banking Details", "group_key": "banking_details" - } + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] + } ] } \ No newline at end of file diff --git a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/WCTL/3.json b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/WCTL/3.json index 0dbf310..6bc8ff2 100644 --- a/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/WCTL/3.json +++ b/ng6-seed/src/assets/data/SMC_CREDIT_TEMPLATES/WCTL/3.json @@ -189,6 +189,20 @@ "value":null } ] + }, + { + "question_key":"common_remarks", + "question":"Remarks", + "place_holder":"Enter the text", + "type":"7", + "api_properties":null, + "answers":null, + "onchange_properties":null, + "is_repeatable":null, + "field_type":"string", + "field_width":"45", + "validations":[ + ] } ]