diff --git a/src/common.ts b/src/common.ts index 7275a7d..4a723c4 100644 --- a/src/common.ts +++ b/src/common.ts @@ -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; }, });