Template : Asset details changes and common remarks in all forms, App : Second branching question removal and filter_properties for master data filter

This commit is contained in:
venbatechnologies@gmail.com 2020-11-23 19:33:05 +05:30
parent 260e96b8b1
commit ffecdb2dec
16 changed files with 446 additions and 47 deletions

View File

@ -93,7 +93,7 @@
<mat-label>{{parent_ques.question}}</mat-label>
<mat-select multiple [formControlName]="parent_ques.question_key"
(selectionChange)="onChangeProperty($event,parent_ques,'','','')">
<mat-option>Select</mat-option>
<!-- <mat-option>Select</mat-option> -->
<mat-option *ngFor="let val of parent_ques.answers"
[value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>

View File

@ -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);

View File

@ -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)

View File

@ -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":[
]
}
]

View File

@ -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":[
]
}
]

View File

@ -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":[
]
}
]
}

View File

@ -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":[
]
}
]

View File

@ -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":[
]
}
]
}

View File

@ -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":[
]
}
]
}

View File

@ -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":[
]
}
]

View File

@ -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":[
]
}
]
}

View File

@ -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":[
]
}
]
}

View File

@ -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":[
]
}
]

View File

@ -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":[
]
}
]

View File

@ -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":[
]
}
]
}

View File

@ -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":[
]
}
]