From fc43d45d7dfcea350e999d0965d65ddddd58a3c5 Mon Sep 17 00:00:00 2001 From: tree Date: Tue, 12 Apr 2022 09:47:33 +0200 Subject: [PATCH] update --- src/lib/Event.svelte | 35 ++++++--------- src/lib/Tooltip.svelte | 91 ++++++++++++++++++++++++++++++++++++++ src/lib/events.js | 15 +++++++ src/routes/program.svelte | 12 ++++- src/routes/udalosti.svelte | 14 +++++- 5 files changed, 143 insertions(+), 24 deletions(-) create mode 100644 src/lib/Tooltip.svelte create mode 100644 src/lib/events.js diff --git a/src/lib/Event.svelte b/src/lib/Event.svelte index b6a8d86..2aec634 100644 --- a/src/lib/Event.svelte +++ b/src/lib/Event.svelte @@ -1,12 +1,14 @@
- +
{e.name} @@ -75,15 +68,15 @@
{trackRender(e.track)}
-
{e.duration}m
+ {#if duration}
{duration}m
{/if}
- {#if getParents(e).length > 0} + {#if getChildrens(e).length > 0}
- {#each getParents(e) as pe} -
+ {#each getChildrens(e) as pe} +
{#if pe.speakers.length === 0} diff --git a/src/lib/Tooltip.svelte b/src/lib/Tooltip.svelte new file mode 100644 index 0000000..c69f6e8 --- /dev/null +++ b/src/lib/Tooltip.svelte @@ -0,0 +1,91 @@ + + + + +
+ + + +
+ {#if tip} +
{@html tip}
+ {:else} + + {/if} + +
+
diff --git a/src/lib/events.js b/src/lib/events.js new file mode 100644 index 0000000..52fa974 --- /dev/null +++ b/src/lib/events.js @@ -0,0 +1,15 @@ + +export default function calcDuration(e, bundle) { + if (!bundle) { + return 0 + } + if (e.duration) { + return e.duration + } + const childrens = bundle.spec.events.filter((i) => i.parent === e.id); + if (childrens.length > 0) { + let total = childrens.reduce((p, c) => p + (c.duration ? c.duration : 0), 0) + total += 5 * (childrens.length-1) + return total + } +} diff --git a/src/routes/program.svelte b/src/routes/program.svelte index 88f2068..842dcb2 100644 --- a/src/routes/program.svelte +++ b/src/routes/program.svelte @@ -5,6 +5,14 @@ @@ -27,8 +35,8 @@
přednášejících
-
{$bundle.spec.events.reduce((p, c) => p + c.duration, 0)}
-
minut obsahu
+
{Math.round((totalDuration/60)*100)/100}
+
hodin obsahu
diff --git a/src/routes/udalosti.svelte b/src/routes/udalosti.svelte index a20c876..92b642f 100644 --- a/src/routes/udalosti.svelte +++ b/src/routes/udalosti.svelte @@ -9,6 +9,8 @@ import { bundle, userData } from "$lib/stores.js"; import EventTypeLabel from "$lib/EventTypeLabel.svelte"; import Avatar from "$lib/Avatar.svelte"; + import Event from "$lib/Event.svelte"; + import calcDuration from "$lib/events.js"; import SvelteMarkdown from "svelte-markdown"; import Link from "$lib/Link.svelte"; @@ -16,6 +18,8 @@ $: id = getId($page.url.search); $: e = $bundle ? $bundle.spec.events.find((ev) => ev.id === id) : null; + $: duration = e ? calcDuration(e, $bundle) : null + $: childrens = $bundle.spec.events.filter(i => i.parent === e.id); function getId(search) { const searchParams = new URLSearchParams(search); @@ -51,7 +55,7 @@
{trackRender(e.track)}
-
{e.duration}m
+
{duration}m

{e.name}

{#if e.speakers && e.speakers.length > 0} @@ -71,5 +75,13 @@ {/if}
+ {#if childrens.length} +

Obsahuje události ({ childrens.length })

+
+ {#each childrens as child} + + {/each} +
+ {/if} {/if}