Skip to content

Commit

Permalink
[#1152] Fix yellow background in datapoint when reset in diff questio…
Browse files Browse the repository at this point in the history
…n group
  • Loading branch information
ifirmawan committed Feb 12, 2024
1 parent 9fe7317 commit b47212f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions frontend/src/pages/manage-data/DataDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const DataDetail = ({
const hasNewValue = prev
.find((p) => p.id === parentId)
?.question?.some((q) => typeof q.newValue !== "undefined");
setEditedRecord({ [record.id]: hasNewValue });
setEditedRecord({ ...editedRecord, [record.id]: hasNewValue });
setDataset(prev);
};

Expand All @@ -80,7 +80,14 @@ const DataDetail = ({
}
: qg
);
setEditedRecord({ [record.id]: false });
/**
* Check whether it still has newValue or not
* in all groups of questions
*/
const hasNewValue = prev
?.flatMap((p) => p?.question)
?.find((q) => q?.newValue);
setEditedRecord({ ...editedRecord, [record.id]: hasNewValue });
setDataset(prev);
};

Expand Down
11 changes: 9 additions & 2 deletions frontend/src/pages/submissions/BatchDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const BatchDetail = ({
return typeof q.newValue !== "undefined";
});
});
setEditedRecord({ [expanded.id]: hasNewValue });
setEditedRecord({ ...editedRecord, [expanded.id]: hasNewValue });
setRawValue({
...rawValue,
data,
Expand Down Expand Up @@ -179,7 +179,14 @@ const BatchDetail = ({
return rq;
}),
}));
setEditedRecord({ [expanded.id]: false });
/**
* Check whether it still has newValue or not
* in all groups of questions
*/
const hasNewValue = data
?.flatMap((d) => d?.question)
?.find((q) => q?.newValue);
setEditedRecord({ ...editedRecord, [expanded.id]: hasNewValue });
setRawValue({
...prev,
data,
Expand Down

0 comments on commit b47212f

Please sign in to comment.