Fixed behavior of valid from date when creating new template

Previously if you created a new grading template chose a date for `Valid from` field and then added a criterion.
The valid from date would reset to null. This would create a validation error on save.
This creates unnecessary confusion for the user.

Now when you have chosen a date and then choose to add a criterion to the template the date does not reset.

The reason for this was that the AutoSave() added to the field was using the wrong event to trigger the setValidFrom().
Since we use bootstraps date picker we have to trigger on "changeDate" event.
This commit is contained in:
Nico Athanassiadis 2024-11-19 10:06:43 +01:00
parent b27102596e
commit d0baa11d3b

@ -37,7 +37,7 @@ class EditingGradingTemplateComponentPanel extends GenericPanel<EditingGradingTe
EditingGradingTemplate::setValidFrom), EditingGradingTemplate::setValidFrom),
LocalDate.class); LocalDate.class);
validFromField.add(new BootstrapDatePicker()); validFromField.add(new BootstrapDatePicker());
validFromField.add(new AutoSave()); validFromField.add(new AutoSave("changeDate"));
add(validFromField); add(validFromField);
add(new TextArea<>("note", LambdaModel.of( add(new TextArea<>("note", LambdaModel.of(
@ -298,6 +298,10 @@ class EditingGradingTemplateComponentPanel extends GenericPanel<EditingGradingTe
super("input"); super("input");
} }
public AutoSave(String event) {
super(event);
}
@Override @Override
protected void onUpdate(AjaxRequestTarget target) { protected void onUpdate(AjaxRequestTarget target) {
// just trigger the ajax call is enough to update the model object // just trigger the ajax call is enough to update the model object