Skip to content
Snippets Groups Projects
Commit b6eacbc4 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Fix: Simplify detection of adults and children when editing test case.

parent c07242e0
Branches
Tags
No related merge requests found
......@@ -52,13 +52,6 @@
.map(([name]) => name),
)
$: adultsId = [...new Array(countAdults(situation, firstGroupEntity))].map(
(_, index) => `Adulte ${index + 1}`,
)
$: childrenId = [
...new Array(countChildren(situation, firstGroupEntity)),
].map((_, index) => `Enfant ${index + 1}`)
$: persons = Object.entries(
(situation[personEntity.key_plural] ?? {}) as {
[id: string]: PopulationWithoutId
......@@ -72,6 +65,13 @@
persons.map((person) => [person.id, person]),
)
$: adultsId = [
...Object.keys(personById).filter((id) => id.startsWith("Adulte ")),
]
$: childrenId = [
...Object.keys(personById).filter((id) => id.startsWith("Enfant ")),
]
$: yearString = year.toString()
$: updateInputInstantsByVariableName(inputInstantsByVariableName)
......@@ -313,12 +313,6 @@
}
function deletePerson(personId: string): void {
const personById = {
...situation[personEntity.key_plural],
}
delete personById[personId]
situation = { ...situation, [personEntity.key_plural]: personById }
for (const groupEntity of Object.values(entityByKey) as GroupEntity[]) {
if (groupEntity.is_person) {
continue
......@@ -357,6 +351,14 @@
}
}
// Delete person only after it has been removed from all its groups.
// To avoid to create a duplicate person.
const personById = {
...situation[personEntity.key_plural],
}
delete personById[personId]
situation = { ...situation, [personEntity.key_plural]: personById }
if (
calculationNames.some(
(calculationName) => !$requestedCalculationsName.has(calculationName),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment