Use background events to show times blocked by parent reservations

This commit is contained in:
Adam Goldsmith 2024-03-28 11:58:05 -04:00
parent cfdd261f13
commit 56bbe84249

View File

@ -67,6 +67,7 @@ export function main(
.filter(([shop_name, shop]) => shop.calendar !== undefined)
.forEach(([shop_name, shop], idx) => {
calendar.addEventSource({
id: shop_name,
url: '/calendar/ical/' + shop.calendar + '/public/basic.ics',
format: 'ics',
color: colors[idx],
@ -91,6 +92,22 @@ export function main(
);
}
}
// Add background event if resource has children
let tool_resource = calendar.getResourceById(eventData.resourceId);
let children = tool_resource?.getChildren();
if (tool_resource && children?.length) {
let new_event = {
...eventData,
resourceIds: [
tool_resource.id,
...children.map((resource) => resource.id),
],
display: 'background',
};
calendar.addEvent(new_event, shop_name);
}
return eventData;
},
});