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 committed May 3, 2024
1 parent 6fa2833 commit 011ce17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"material-table": "1.43.0",
"moment": "^2.22.2",
"openchs-idi": "git+https://github.com/avniproject/openchs-idi#b6c57e051b91ed4bc2634f4f087dba51cc3a01c8",
"openchs-models": "1.31.64",
"openchs-models": "1.31.69",
"popper.js": "^1.14.3",
"prismjs": "^1.17.1",
"prop-types": "^15.7.2",
Expand Down
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 011ce17

Please sign in to comment.