Remote event segments

This commit is contained in:
tree 2023-02-23 06:45:52 +01:00
parent 4d05afe592
commit e17c580183
2 changed files with 21 additions and 5 deletions

View File

@ -9,6 +9,21 @@
export let entry;
export let bundle;
export let event = null;
for (let i = 0; i < segments.length; i++) {
const sg = segments[i]
if (sg.remote) {
console.log(i)
const event = bundle.events.find(e => e.id === sg.remote)
const remoteSegments = event.segments.map(rs => Object.assign(rs, {
event,
remote: true
}))
segments.splice(i, remoteSegments.length, ...remoteSegments)
}
}
console.log(segments)
</script>
<div class="text-2xl">
@ -37,14 +52,14 @@
<ItemLogo item={segment.event || event} width={event ? 'w-8' : 'w-10'} />
</a>
<div>
{#if !event}
{#if !event || segment.remote}
{#if (segment.event || event).hidden}
{(segment.event || event)[event && event.shortname ? 'shortname' : 'name']}*
{(segment.event || event)[(segment.event || event).shortname ? 'shortname' : 'name']}*
{:else}
<a
href="/{entry}/{col}/{(segment.event || event).id}"
class="text-pbw-red hover:underline"
>{(segment.event || event)[event && event.shortname ? 'shortname' : 'name']}</a
>{(segment.event || event)[(segment.event || event).shortname ? 'shortname' : 'name']}</a
>
{/if}
{:else}
@ -56,7 +71,7 @@
</div>
</div>
<div class="flex flex-wrap gap-2">
{#if !event}
{#if !event && !segment.remote}
<div class="gap-1 items-center md:ml-2 hidden md:inline-flex text-xs">
{#each (segment.event || event).types as type}
<EventTypeBadge {type} />

View File

@ -28,6 +28,7 @@
function eventDates(event) {
const dates = [];
for (const seg of event.segments) {
if (seg.remote) continue;
const date = format(new Date(seg.startTime), 'yyyy-MM-dd');
if (!dates.includes(date)) {
dates.push(date);
@ -322,7 +323,7 @@
<div class="mt-4">
<CalendarList
{date}
segments={item.segments.filter((s) => s.startTime.match(new RegExp('^' + date)))}
segments={item.segments.filter((s) => s.remote || s.startTime.match(new RegExp('^' + date)))}
{entry}
bundle={data.bundle}
event={item}