Skip to content
Snippets Groups Projects
Commit 219be9cb authored by uhensler's avatar uhensler
Browse files

OO-4630: Disable to move appointments that already have participations

parent a166f6be
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
package org.olat.course.nodes.appointments;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.stream.Collectors;
......@@ -113,6 +114,10 @@ public class ParticipationSearchParams {
.map(AppointmentRef::getKey)
.collect(Collectors.toSet());
}
public void setAppointment(AppointmentRef appointment) {
this.appointmentKeys = Collections.singletonList(appointment.getKey());
}
public Date getStartAfter() {
return startAfter;
......
......@@ -56,6 +56,7 @@ public class AppointmentEditController extends FormBasicController {
private Topic topic;
private Appointment appointment;
private final boolean hasParticipations;
@Autowired
private AppointmentsService appointmentsService;
......@@ -63,12 +64,18 @@ public class AppointmentEditController extends FormBasicController {
public AppointmentEditController(UserRequest ureq, WindowControl wControl, Topic topic) {
super(ureq, wControl);
this.topic = topic;
this.hasParticipations = false;
initForm(ureq);
}
public AppointmentEditController(UserRequest ureq, WindowControl wControl, Appointment appointment) {
super(ureq, wControl);
this.appointment = appointment;
ParticipationSearchParams params = new ParticipationSearchParams();
params.setAppointment(appointment);
this.hasParticipations = appointmentsService.getParticipationCount(params).longValue() > 0;
initForm(ureq);
}
......@@ -78,12 +85,14 @@ public class AppointmentEditController extends FormBasicController {
startEl = uifactory.addDateChooser("appointment.start", start, formLayout);
startEl.setDateChooserTimeEnabled(true);
startEl.setMandatory(true);
startEl.setEnabled(!hasParticipations);
startEl.addActionListener(FormEvent.ONCHANGE);
Date end = appointment != null? appointment.getEnd(): null;
endEl = uifactory.addDateChooser("appointment.end", end, formLayout);
endEl.setDateChooserTimeEnabled(true);
endEl.setMandatory(true);
endEl.setEnabled(!hasParticipations);
String location = appointment != null? appointment.getLocation(): null;
locationEl = uifactory.addTextElement("appointment.location", 128, location, formLayout);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment