Max available points should be updated when adding new points to criterion

Previously max available points where only updated when you added a new criterion.

It is beneficial that the user can see the max available points as they have completed editing the
template without having to click on the create button or add a new criterion.
This commit is contained in:
Nico Athanassiadis 2024-11-20 10:37:42 +01:00
parent edd6e9214d
commit 3ec0356b3a

@ -22,6 +22,9 @@ import java.time.LocalDate;
import java.util.List;
class EditingGradingTemplateComponentPanel extends GenericPanel<EditingGradingTemplate> {
private final Label maxPointsAvailable;
EditingGradingTemplateComponentPanel(
String id,
IModel<EditingGradingTemplate> editingGradingTemplateModel)
@ -51,7 +54,10 @@ class EditingGradingTemplateComponentPanel extends GenericPanel<EditingGradingTe
add(new GradeLimitsPanel("grade_limits", editingGradingTemplateModel.map(EditingGradingTemplate::getGradeLimits)));
add(new Label("max_points_available", editingGradingTemplateModel.map(EditingGradingTemplate::getMaxPointsAvailable)));
maxPointsAvailable = new Label("max_points_available", editingGradingTemplateModel.map(EditingGradingTemplate::getMaxPointsAvailable));
maxPointsAvailable.setOutputMarkupId(true);
add(maxPointsAvailable);
add(new ListView<>("criteria", editingGradingTemplateModel.map(EditingGradingTemplate::getCriteria)) {
{
@ -181,6 +187,7 @@ class EditingGradingTemplateComponentPanel extends GenericPanel<EditingGradingTe
EditingGradingTemplate.Criteria.Point newPoint = criteria.new Point();
criteria.getPoints().add(newPoint);
target.add(CriteriaEditingPanel.this);
target.add(maxPointsAvailable);
onTemplateChanged(target);
}
});