From 219c312441eeeba79df4b7295d9fd63542b65cd1 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg <andreass@dsv.su.se> Date: Fri, 7 Feb 2025 07:50:02 +0100 Subject: [PATCH] Fix localizer warning on the finishing up tab for each author (#101) Fixes #48 The `getReflectionText` method was calling `getString` when no reflection has been submitted. This is not a relevant case for the editing form since it can not be accessed when there is no reflection. Inlined the method call and removed the non-submitted case, the default will be an empty string. ## How to test 1. Log in as a supervisor 2. Open a project that has a Daisy connection (`identifier`is non-null on the `Project`) 3. Go to the "Finishing up" tab 4. Go to the tab for the author with no reflection submitted 5. See that no warning is logged Co-authored-by: Nico Athanassiadis <nico@dsv.su.se> Reviewed-on: https://gitea.dsv.su.se/DMC/scipro/pulls/101 Reviewed-by: Nico Athanassiadis <nico@dsv.su.se> Co-authored-by: Andreas Svanberg <andreass@dsv.su.se> Co-committed-by: Andreas Svanberg <andreass@dsv.su.se> --- .../su/dsv/scipro/grading/ReflectionModalBodyPanel.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/view/src/main/java/se/su/dsv/scipro/grading/ReflectionModalBodyPanel.java b/view/src/main/java/se/su/dsv/scipro/grading/ReflectionModalBodyPanel.java index 986d509685..a7e48a1f1c 100644 --- a/view/src/main/java/se/su/dsv/scipro/grading/ReflectionModalBodyPanel.java +++ b/view/src/main/java/se/su/dsv/scipro/grading/ReflectionModalBodyPanel.java @@ -178,7 +178,13 @@ class ReflectionModalBodyPanel extends Panel { public SupervisorEditReflectionForm(String id, IModel<Reflection> reflectionModel) { super(id, reflectionModel); - IModel<String> reflectionTextModel = new Model<>(getReflectionText(reflectionModel.getObject())); + IModel<String> reflectionTextModel = new Model<>(); + Reflection reflection = reflectionModel.getObject(); + if (reflection instanceof Reflection.Submitted submitted) { + reflectionTextModel.setObject(submitted.reflection()); + } else if (reflection instanceof Reflection.ImprovementsNeeded improvementsNeeded) { + reflectionTextModel.setObject(improvementsNeeded.oldReflection()); + } TextArea<String> reflectionTextArea = new TextArea<>("reflection", reflectionTextModel); reflectionTextArea.setRequired(true);