Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
child multi mapping validation correction (#33)
Browse files Browse the repository at this point in the history
Co-authored-by: Karyamsetty Helen Grace <[email protected]>
  • Loading branch information
devikasuresh20 and Karyamsetty Helen Grace authored Oct 16, 2023
1 parent ff3b353 commit 136dd66
Showing 1 changed file with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,45 +538,65 @@ export class EcdQuestionnaireComponent implements OnInit {
const indexToRemove = questionnaire.enabledQues.indexOf(answer.parentQuesId);
if (indexToRemove !== -1) {
questionnaire.enabledQues.splice(indexToRemove, 1);
questionnaire.answer = null;
if(questionnaire.enabledQues.length <= 0){
questionnaire.answer = null;
}
this.processFilteredQuestionnaires(questionnaire);
}
}
}
})

} else if((questionnaire.parentQuestionId === selectedAnsweredQues.questionid) &&
(selectedAnsweredQues.answer == null || !questionnaire.parentAnswer.includes(selectedAnsweredQues.answer) )) {
questionnaire.enabledQues = false;
questionnaire.answer = null;
this.processFilteredQuestionnaires(questionnaire);
} else if(questionnaire.parentQuestionId !== null && questionnaire.parentQuestionId.includes(selectedAnsweredQues.questionid) &&
selectedAnsweredQues.answer == null){ // || !questionnaire.parentAnswer.includes(selectedAnsweredQues.answer) )) {
questionnaire.parentAnswer.forEach((answer: any) => {
const indexToRemove = questionnaire.enabledQues.indexOf(answer.parentQuesId);
if (indexToRemove !== -1) {
questionnaire.enabledQues.splice(indexToRemove, 1);
if(questionnaire.enabledQues.length <= 0){
questionnaire.answer = null;
this.processFilteredQuestionnaires(questionnaire);
}
}
});
}
} else if (selectedAnsweredQues.answerType != null && selectedAnsweredQues.answerType != undefined &&
selectedAnsweredQues.answerType.toLowerCase() === "multiple") {
if(questionnaire.parentQuestionId != null && questionnaire.parentQuestionId.includes(selectedAnsweredQues.questionid) &&
selectedAnsweredQues.answer != null){ // && selectedAnsweredQues.answer.includes(questionnaire.parentAnswer)) {
questionnaire.parentAnswer.forEach((answer: any) => {
if(answer.parentQuesId == selectedAnsweredQues.questionid)
if(answer.parentAnswerList.filter((item:any) => item.includes(selectedAnsweredQues.answer))){
console.log("Condition passed: answer.parentAnswerList includes selectedAnsweredQues.answer");
if (answer.parentAnswerList.some((item: any) => selectedAnsweredQues.answer.includes(item))) {
console.log("Condition passed: at least one item in answer.parentAnswerList matches selectedAnsweredQues.answer");
if(!questionnaire.enabledQues.includes(answer.parentQuesId) ){
questionnaire.enabledQues.push(answer.parentQuesId);
}
} else {
const indexToRemove = questionnaire.enabledQues.indexOf(answer.parentQuesId);
if (indexToRemove !== -1) {
questionnaire.enabledQues.splice(indexToRemove, 1);
questionnaire.answer = null;
if(questionnaire.enabledQues.length <= 0){
questionnaire.answer = null;
}
this.processFilteredQuestionnaires(questionnaire);
}
}
});
}
}else if((questionnaire.parentQuestionId === selectedAnsweredQues.questionid) &&
else if(questionnaire.parentQuestionId !== null && questionnaire.parentQuestionId.includes(selectedAnsweredQues.questionid) &&
(selectedAnsweredQues.answer == null)){ //|| !selectedAnsweredQues.answer.includes(questionnaire.parentAnswer))) {
questionnaire.enabledQues = false;
questionnaire.answer = null;
questionnaire.parentAnswer.forEach((answer: any) => {
const indexToRemove = questionnaire.enabledQues.indexOf(answer.parentQuesId);
if (indexToRemove !== -1) {
questionnaire.enabledQues.splice(indexToRemove, 1);
if(questionnaire.enabledQues.length <= 0){
questionnaire.answer = null;
this.processFilteredQuestionnaires(questionnaire);
}
//}
}
});
}
}
});
});
}
Expand Down

0 comments on commit 136dd66

Please sign in to comment.