From 5ca13d5d32328ddbc0dfc04d1895116c08f3a508 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg Date: Tue, 7 Jan 2025 15:12:09 +0100 Subject: [PATCH 1/5] Require authors to fill in background, literature, problem, method, and interests when submitting ideas --- .../se/su/dsv/scipro/DataInitializer.java | 5 ++ .../match/IdeaTholanderCompletionPanel.html | 5 ++ .../match/IdeaTholanderCompletionPanel.java | 47 +++++++------------ 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/core/src/main/java/se/su/dsv/scipro/DataInitializer.java b/core/src/main/java/se/su/dsv/scipro/DataInitializer.java index 7ab805cd7a..85a1f413a7 100644 --- a/core/src/main/java/se/su/dsv/scipro/DataInitializer.java +++ b/core/src/main/java/se/su/dsv/scipro/DataInitializer.java @@ -172,6 +172,11 @@ public class DataInitializer implements Lifecycle { stina_student = createStudent(STUDENT_2); sid_student = createStudent(STUDENT_3); simon_student = createStudent(STUDENT_4); + + // Used to test submitting ideas + // can not be used as author on any idea + // can not be used as author on any project + createStudent("Stig"); } private User createStudent(String firstName) { diff --git a/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.html b/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.html index 40725f810c..6fd8e9a15e 100755 --- a/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.html +++ b/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.html @@ -8,6 +8,7 @@
+
Describe the background of your topic, preferably both theoretical, empirical and/or practical. @@ -16,6 +17,7 @@
+
Describe the connection to your background, for example literature, theory and methodology related to the topic, courses that you have taken that relates to the topic. @@ -24,6 +26,7 @@
+
Here you describe the problem you want to address and solve by your work, preferably formulated as a research question. @@ -32,6 +35,7 @@
+
The method you plan to use in order to solve the problem and answer the research question. @@ -40,6 +44,7 @@
+
Please note that when you propose your own topic, it is not guaranteed that your topic will be approved. In that case, you will be assigned a different topic by your supervisor. Specify which topics of interest you have, relating to the research fields or the courses that you have taken at DSV. diff --git a/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.java b/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.java index 26d4ce15c0..d2040c2644 100755 --- a/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.java +++ b/view/src/main/java/se/su/dsv/scipro/match/IdeaTholanderCompletionPanel.java @@ -1,6 +1,7 @@ package se.su.dsv.scipro.match; import org.apache.wicket.markup.html.form.TextArea; +import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.LambdaModel; @@ -12,36 +13,20 @@ public class IdeaTholanderCompletionPanel extends Panel { super(id, model); final IModel tholanderBox = model.map(Idea::getTholanderBox); - final StringValidator lengthValidator = StringValidator.maximumLength(TholanderBox.MAX_CHARS); - add( - new TextArea<>( - "background", - LambdaModel.of(tholanderBox, TholanderBox::getBackground, TholanderBox::setBackground) - ).add(lengthValidator) - ); - add( - new TextArea<>( - "literature", - LambdaModel.of(tholanderBox, TholanderBox::getLiterature, TholanderBox::setLiterature) - ).add(lengthValidator) - ); - add( - new TextArea<>( - "problem", - LambdaModel.of(tholanderBox, TholanderBox::getProblem, TholanderBox::setProblem) - ).add(lengthValidator) - ); - add( - new TextArea<>( - "method", - LambdaModel.of(tholanderBox, TholanderBox::getMethod, TholanderBox::setMethod) - ).add(lengthValidator) - ); - add( - new TextArea<>( - "interests", - LambdaModel.of(tholanderBox, TholanderBox::getInterests, TholanderBox::setInterests) - ).add(lengthValidator) - ); + textField("background", LambdaModel.of(tholanderBox, TholanderBox::getBackground, TholanderBox::setBackground)); + textField("literature", LambdaModel.of(tholanderBox, TholanderBox::getLiterature, TholanderBox::setLiterature)); + textField("problem", LambdaModel.of(tholanderBox, TholanderBox::getProblem, TholanderBox::setProblem)); + textField("method", LambdaModel.of(tholanderBox, TholanderBox::getMethod, TholanderBox::setMethod)); + textField("interests", LambdaModel.of(tholanderBox, TholanderBox::getInterests, TholanderBox::setInterests)); + } + + private void textField(String id, IModel model) { + TextArea textArea = new TextArea<>(id, model); + textArea.add(StringValidator.maximumLength(TholanderBox.MAX_CHARS)); + textArea.setRequired(true); + add(textArea); + + ComponentFeedbackPanel feedback = new ComponentFeedbackPanel(id + "_feedback", textArea); + add(feedback); } } -- 2.39.5 From 57e6f5c1ccdcef75c349808608e9a1dc8d6b9c94 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg Date: Fri, 10 Jan 2025 10:21:02 +0100 Subject: [PATCH 2/5] Validate the type selection in the same way as the other fields. Removed the client-side validation (HTML required attribute) and rely on server-side validation with a red feedback message instead. --- .../scipro/match/ProjectIdeaSubmissionPanel.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java index acdf6b0655..f22d2d041a 100755 --- a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java +++ b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java @@ -18,6 +18,7 @@ import org.apache.wicket.model.*; import org.apache.wicket.model.util.ListModel; import org.apache.wicket.model.util.SetModel; import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.util.value.IValueMap; import org.apache.wicket.validation.validator.StringValidator; import se.su.dsv.scipro.components.*; import se.su.dsv.scipro.generalsystemsettings.GeneralSystemSettings; @@ -187,7 +188,17 @@ public class ProjectIdeaSubmissionPanel extends GenericPanel { LambdaModel.of(getModel(), Idea::getProjectType, Idea::setProjectType), projectTypes, new LambdaChoiceRenderer<>(ProjectType::getName, ProjectType::getId) - ); + ) { + @Override + protected IValueMap getAdditionalAttributes(int index, ProjectType choice) { + IValueMap valueMap = super.getAdditionalAttributes(index, choice); + // Have to remove the client side validation for required + // to have this field behave like all the others on the form. + // Can't remove the call to #setRequired(true) as it is needed for server side validation. + valueMap.remove("required"); + return valueMap; + } + }; projectTypeChoice.add( new AjaxFormChoiceComponentUpdatingBehavior() { @Override -- 2.39.5 From 5d475c961c25ea1709e6ffb6cc5f36eda486a792 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg Date: Fri, 10 Jan 2025 10:24:08 +0100 Subject: [PATCH 3/5] Improve the topmost error message to help guide the authors what to do. --- .../su/dsv/scipro/match/ProjectIdeaSubmissionPanel.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.properties b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.properties index f713e10b6b..30169daf53 100644 --- a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.properties +++ b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.properties @@ -26,7 +26,7 @@ you.are.partner.on.other.idea= You have already been added as a partner to anoth too.many.authors= Too many authors for a ${name}-idea. May not be more than ${maxAuthors} including yourself. too.few.authors= Too few authors for a ${name}-idea. Must be at least ${minAuthors} including yourself. keywordError= You need to select between 1 and 5 keywords. -submissionFailed= Idea could not be submitted. +submissionFailed= Idea could not be submitted. Correct the highlighted fields and try again. ideaSubmitted= You have successfully submitted your ${projectType.name} student idea, for the application period \ ${applicationPeriod.name}. ideaUpdated= You have successfully updated your ${projectType.name} student idea, in the application period \ -- 2.39.5 From 164271a6e5a77b688178fde60ced3608ca1e65a2 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg Date: Wed, 15 Jan 2025 10:52:43 +0100 Subject: [PATCH 4/5] Remove all client-side validation and rely on server-side validation Gives better error messages to the user. --- .../su/dsv/scipro/match/ProjectIdeaSubmissionPanel.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.html b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.html index 0a61f7fb47..226197684d 100755 --- a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.html +++ b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.html @@ -17,7 +17,14 @@ an idea if you couldn't find any suitable supervisor provided ideas.
-
+ +

-- 2.39.5 From 2bf6abb72046e048d094b3b1749d1821734f2b7f Mon Sep 17 00:00:00 2001 From: Andreas Svanberg Date: Wed, 15 Jan 2025 10:56:47 +0100 Subject: [PATCH 5/5] Client-side validation is turned off for the entire form so this hack is no longer necessary. --- .../scipro/match/ProjectIdeaSubmissionPanel.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java index f22d2d041a..acdf6b0655 100755 --- a/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java +++ b/view/src/main/java/se/su/dsv/scipro/match/ProjectIdeaSubmissionPanel.java @@ -18,7 +18,6 @@ import org.apache.wicket.model.*; import org.apache.wicket.model.util.ListModel; import org.apache.wicket.model.util.SetModel; import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.util.value.IValueMap; import org.apache.wicket.validation.validator.StringValidator; import se.su.dsv.scipro.components.*; import se.su.dsv.scipro.generalsystemsettings.GeneralSystemSettings; @@ -188,17 +187,7 @@ public class ProjectIdeaSubmissionPanel extends GenericPanel { LambdaModel.of(getModel(), Idea::getProjectType, Idea::setProjectType), projectTypes, new LambdaChoiceRenderer<>(ProjectType::getName, ProjectType::getId) - ) { - @Override - protected IValueMap getAdditionalAttributes(int index, ProjectType choice) { - IValueMap valueMap = super.getAdditionalAttributes(index, choice); - // Have to remove the client side validation for required - // to have this field behave like all the others on the form. - // Can't remove the call to #setRequired(true) as it is needed for server side validation. - valueMap.remove("required"); - return valueMap; - } - }; + ); projectTypeChoice.add( new AjaxFormChoiceComponentUpdatingBehavior() { @Override -- 2.39.5