From 2bae66064f948144e0285491c9214293aa3b4182 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 23 May 2024 13:56:59 +0200 Subject: [PATCH 1/2] fixed --- .../components/SimpleTests/SimpleTests.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/SimpleTests/SimpleTests.tsx b/frontend/src/components/SimpleTests/SimpleTests.tsx index dd76da91..a8eecfd2 100644 --- a/frontend/src/components/SimpleTests/SimpleTests.tsx +++ b/frontend/src/components/SimpleTests/SimpleTests.tsx @@ -365,7 +365,18 @@ export default function SimpleTests(props: { // check local const oldConstraint = local_constraints_plus_zip.find(constraint => constraint.id === id); const newConstraint = new Constraint(type, "CHANGE_ME", newId, id, oldConstraint!.depth+1); - const sub_items = zip.local_constraints.filter(constraint => constraint.parent_id === id); + + let sub_item_ids = [id]; // get subitems recursively + let sub_items = []; + for (let try_sub_constraint of zip.local_constraints) { + if (try_sub_constraint.parent_id !== undefined) { + if (sub_item_ids.includes(try_sub_constraint.parent_id)) { + sub_item_ids.push(try_sub_constraint.id); + sub_items.push(try_sub_constraint); + } + } + } + let index!: number; if (sub_items.length === 0) { // No sub-items yet. Put directly after item. @@ -640,9 +651,9 @@ export default function SimpleTests(props: { contentStyle={{width: 'auto'}} >
- - - + + +
} From 6844293c695cfe5880bf3535cfad7d0fffd3b836 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 23 May 2024 13:59:20 +0200 Subject: [PATCH 2/2] linting --- frontend/src/components/SimpleTests/SimpleTests.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/SimpleTests/SimpleTests.tsx b/frontend/src/components/SimpleTests/SimpleTests.tsx index a8eecfd2..d79256f6 100644 --- a/frontend/src/components/SimpleTests/SimpleTests.tsx +++ b/frontend/src/components/SimpleTests/SimpleTests.tsx @@ -366,9 +366,9 @@ export default function SimpleTests(props: { const oldConstraint = local_constraints_plus_zip.find(constraint => constraint.id === id); const newConstraint = new Constraint(type, "CHANGE_ME", newId, id, oldConstraint!.depth+1); - let sub_item_ids = [id]; // get subitems recursively - let sub_items = []; - for (let try_sub_constraint of zip.local_constraints) { + const sub_item_ids = [id]; // get subitems recursively + const sub_items: Constraint[] = []; + for (const try_sub_constraint of zip.local_constraints) { if (try_sub_constraint.parent_id !== undefined) { if (sub_item_ids.includes(try_sub_constraint.parent_id)) { sub_item_ids.push(try_sub_constraint.id);