Fix idea table being updated with first meeting information after scheduling

What happened was the idea was loaded (the model got attached) without a first meeting, then the first meeting was created separately in a different model. After creating the first meeting the second model had its object updated in place so no call to IModel#setObject was made. Even if it had been called since there was this separation the idea model would not have been updated either way. Implementing #setObject in the FirstMeetingModel (in FirstMeetingPanel) that would update the idea model would not have solved since its #setObject was never called.

To get around this we either have to update the idea models object in place (the chosen solution) or detaching it, forcing a reload from the database that would see the newly created first meeting.
This commit is contained in:
Andreas Svanberg 2025-02-10 13:31:54 +01:00
parent 8900909191
commit 12badef08b

@ -169,7 +169,11 @@ public class FirstMeetingPanel extends GenericPanel<Idea> {
}
private void saveAndNotify() {
firstMeetingRepository.save(getModelObject());
FirstMeeting saved = firstMeetingRepository.save(getModelObject());
// After saving the first meeting we have to populate it on the already loaded idea to
// make sure that other places that want to render the first meeting get the correct data.
// An alternative would be to detach the idea model to force a database refresh.
FirstMeetingPanel.this.getModelObject().setFirstMeeting(saved);
NotificationSource source = new NotificationSource();
String date = dateService.format(getModelObject().getFirstMeetingDate(), DateStyle.DATETIME);
String room = getModelObject().getRoom();