Changed RepeatingView to ListView

This commit is contained in:
Nico Athanassiadis 2025-04-10 10:11:10 +02:00
parent b82dc71aa5
commit fd93a8bd65
3 changed files with 25 additions and 20 deletions
view/src/main
java/se/su/dsv/scipro/supervisor/panels
webapp/js

@ -29,7 +29,9 @@
<wicket:container wicket:id="rows">
<div wicket:id="cells" class="calendar-cell">
<div wicket:id="day-number" class="day-number"></div>
<wicket:container wicket:id="calendar-events" />
<wicket:container wicket:id="calendar-events">
<span wicket:id="eventLabel"></span>
</wicket:container>
</div>
</wicket:container>
</div>

@ -14,6 +14,8 @@ import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.RepeatingView;
import se.su.dsv.scipro.firstmeeting.FirstMeetingCalendarEvent;
@ -133,17 +135,20 @@ public class MyCalendarPanel extends Panel {
dayLabel.add(new AttributeModifier("class", dayClass));
cell.add(dayLabel);
RepeatingView eventView = new RepeatingView("calendar-events");
for (FirstMeetingCalendarEvent event : events) {
if (event.date().equals(day)) {
Label eventLabel = new Label(
eventView.newChildId(),
String.format("%s - %s - %s", event.title(), event.room(), event.projectId())
);
ListView<FirstMeetingCalendarEvent> eventView = new ListView<>(
"calendar-events",
events.stream().filter(event -> event.date().equals(day)).toList()
) {
@Override
protected void populateItem(ListItem<FirstMeetingCalendarEvent> item) {
FirstMeetingCalendarEvent event = item.getModelObject();
Label eventLabel = new Label("eventLabel", String.format("%s<br>%s", event.title(), event.room()));
eventLabel.add(new AttributeModifier("title", String.format("Project: %s", event.projectTitle())));
eventLabel.setEscapeModelStrings(false);
eventLabel.add(new AttributeModifier("class", "calendar-event"));
eventView.add(eventLabel);
item.add(eventLabel);
}
}
};
cell.add(eventView);
rowItem.add(cell);

@ -1,28 +1,26 @@
console.log("This is my.js");
function normalizeCalendarHeights() {
const cells = document.querySelectorAll('.calendar-cell');
const cells = document.querySelectorAll(".calendar-cell");
let maxHeight = 0;
if (cells.length === 0) return;
cells.forEach(cell => {
cell.style.height = 'auto';
cells.forEach((cell) => {
cell.style.height = "auto";
const height = cell.scrollHeight;
if (height > maxHeight) maxHeight = height;
});
cells.forEach(cell => {
cell.style.height = maxHeight + 'px';
cells.forEach((cell) => {
cell.style.height = maxHeight + "px";
});
}
// Run once when the full page loads
window.addEventListener('load', normalizeCalendarHeights);
window.addEventListener("load", normalizeCalendarHeights);
// ✨ Run after every Wicket AJAX update too — even if you add AJAX later
if (typeof Wicket !== 'undefined') {
Wicket.Event.subscribe('/ajax/call/complete', function() {
if (typeof Wicket !== "undefined") {
Wicket.Event.subscribe("/ajax/call/complete", function () {
normalizeCalendarHeights();
});
}