Fix for project title commit 90604b8ef1f82343e913319c54802dbd09278027

The project title was added to the wrong panel which caused side effect of showing a title when
creating a new template. Moved the previous code it is only shown when editing a template.

Also changed it to read the title from the database using the LoadableDetachableModel pattern.

Now the project title should only be shown when editing an existing template.
This commit is contained in:
Nico Athanassiadis 2024-11-20 11:07:07 +01:00
parent 3c59348636
commit 774f1e9d7a
6 changed files with 12 additions and 8 deletions

@ -3,6 +3,11 @@
<body>
<wicket:extend>
<div wicket:id="feedback"></div>
<div class="mb-3 lead">
<wicket:message key="project_type_name_editing">
<span wicket:id="project_type_name"></span>
</wicket:message>
</div>
<form wicket:id="form">
<div wicket:id="editing" class="mb-3"></div>
<div class="position-sticky bottom-0 bg-white p-3 border line-length-limit hstack">

@ -4,8 +4,11 @@ import jakarta.inject.Inject;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import se.su.dsv.scipro.admin.pages.AbstractAdminProjectPage;
import se.su.dsv.scipro.grading.GradingReportTemplateService;
@ -16,6 +19,7 @@ import se.su.dsv.scipro.report.GradingReportTemplate;
import se.su.dsv.scipro.report.NoSuchTemplateException;
import se.su.dsv.scipro.report.TemplateLockedException;
import se.su.dsv.scipro.report.ValidDateMustBeInTheFutureException;
import se.su.dsv.scipro.system.ProjectType;
import java.util.ArrayList;
import java.util.List;
@ -41,6 +45,8 @@ public class AdminGradingTemplateEditPage extends AbstractAdminProjectPage imple
editingGradingTemplate = new EditingGradingTemplate(template);
add(new FeedbackPanel("feedback"));
IModel<GradingReportTemplate> model = LoadableDetachableModel.of(() -> gradingReportTemplateService.getTemplate(id));
add(new Label("project_type_name", model.map(GradingReportTemplate::getProjectType).map(ProjectType::getName)));
Form<EditingGradingTemplate> form = new Form<>("form") {
@Override

@ -9,12 +9,6 @@
</head>
<body>
<wicket:panel>
<div class="mb-3 lead">
<wicket:message key="project_type_name_editing">
<span wicket:id="project_type_name"></span>
</wicket:message>
</div>
<div class="mb-3 line-length-limit">
<label class="form-label" wicket:for="valid_from">
Valid from

@ -33,7 +33,6 @@ class EditingGradingTemplateComponentPanel extends GenericPanel<EditingGradingTe
setOutputMarkupId(true);
add(new Label("project_type_name", editingGradingTemplateModel.map(EditingGradingTemplate::getProjectType)));
TextField<LocalDate> validFromField = new RequiredTextField<>("valid_from",
LambdaModel.of(editingGradingTemplateModel,
EditingGradingTemplate::getValidFrom,

@ -11,4 +11,3 @@ Type.INDIVIDUAL=Individually for each author
minimum.Required=You must set the minimum number of points for each grade
grade.Required=You must set the letter for each grade
flag.nullValid=None
project_type_name_editing=You are editing a ${project_type_name} grading template.

@ -4,3 +4,4 @@ another_template_exists_for_the_given_date_date=There is already another ${proje
template_is_locked=You can not edit templates that have become current. The template you are trying to edit became current at ${validFrom}.
template_created=New template for ${name} created.
unsaved_changes=The grading template has been changed, unsaved changes will be lost if you do not save.
project_type_name_editing=You are editing a ${project_type_name} grading template.