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 @@ <wicket:panel> <div class="mb-3"> <label class="col-form-label" wicket:for="background">Background</label> + <div wicket:id="background_feedback"></div> <textarea wicket:id="background" class="form-control" rows="4"></textarea> <small class="form-text text-body-secondary"> Describe the background of your topic, preferably both theoretical, empirical and/or practical. @@ -16,6 +17,7 @@ <div class="mb-3"> <label class="col-form-label" wicket:for="literature">Literature</label> + <div wicket:id="literature_feedback"></div> <textarea wicket:id="literature" class="form-control" rows="4"></textarea> <small class="form-text text-body-secondary"> 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 @@ <div class="mb-3"> <label class="col-form-label" wicket:for="problem">Problem</label> + <div wicket:id="problem_feedback"></div> <textarea wicket:id="problem" class="form-control" rows="4"></textarea> <small class="form-text text-body-secondary"> Here you describe the problem you want to address and solve by your work, preferably formulated as a research question. @@ -32,6 +35,7 @@ <div class="mb-3"> <label class="col-form-label" wicket:for="method">Method</label> + <div wicket:id="method_feedback"></div> <textarea wicket:id="method" class="form-control" rows="4"></textarea> <small class="form-text text-body-secondary"> The method you plan to use in order to solve the problem and answer the research question. @@ -40,6 +44,7 @@ <div class="mb-3"> <label class="col-form-label" wicket:for="interests">My interests</label> + <div wicket:id="interests_feedback"></div> <textarea wicket:id="interests" class="form-control" rows="4"></textarea> <small class="form-text text-body-secondary"> 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> 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<String> model) { + TextArea<String> 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); } } 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. </div> - <form wicket:id="ideaForm"> + <!-- + Turn off all client-side validation using novalidate. + All input is validated server-side, and we want to validate it + that way to get nice error messages. + However, we also want to maintain the required/minlength/whatever + attributes on the input fields for accessibility. + --> + <form wicket:id="ideaForm" novalidate> <div class="mb-3"> <label class="col-form-label" wicket:for="title">Title</label> <p class="form-text"> 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 \