Skip to content

Commit

Permalink
1133 | Allow adding questionGroup only if none of the existing ones …
Browse files Browse the repository at this point in the history
…are empty
  • Loading branch information
himeshr authored and petmongrels committed Jun 10, 2024
1 parent caa63e4 commit a0a9002
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dataEntryApp/components/QuestionGroupFormElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function QuestionGroupFormElement({
concept={childFormElement.concept}
obsHolder={obsHolder}
value={value}
validationResults={validationResults.filter(itr => itr.questionGroupIndex === questionGroupIndex)}
validationResults={validationResults}
uuid={childFormElement.uuid}
update={newValue => {
updateObs(formElement, newValue, childFormElement, questionGroupIndex);
Expand Down
7 changes: 5 additions & 2 deletions src/dataEntryApp/components/RepeatableQuestionGroupElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ export function RepeatableQuestionGroupElement({
if (hasNoObservation) repeatableQuestionGroup = new RepeatableQuestionGroup();
const repeatableQuestionGroupValue = repeatableQuestionGroup.getValue();
const hasMultipleElements = repeatableQuestionGroupValue.length > 1;
const oneOfTheQuestionGroupObservationsIsEmpty = _.some(repeatableQuestionGroupValue, x => _.isEmpty(x.groupObservations));
return repeatableQuestionGroupValue.map((x, index) => {
const isLastElement = !hasNoObservation && repeatableQuestionGroupValue.length === index + 1;
const isLastElement =
!hasNoObservation && !oneOfTheQuestionGroupObservationsIsEmpty && repeatableQuestionGroupValue.length === index + 1;
const quesGrpValidationResults = validationResults.filter(itr => itr.questionGroupIndex === index);
return (
<div key={index}>
<QuestionGroupFormElement
formElement={formElement}
filteredFormElements={filteredFormElements}
obsHolder={obsHolder}
updateObs={updateObs}
validationResults={validationResults}
validationResults={quesGrpValidationResults}
isRepeatable={true}
questionGroupIndex={index}
key={index}
Expand Down

0 comments on commit a0a9002

Please sign in to comment.