Load articles when needed.

This commit is contained in:
Emmanuel 2022-08-26 17:43:10 +02:00
parent a64aa82835
commit d5bd9adedd
3 changed files with 43 additions and 4 deletions

View file

@ -4,7 +4,7 @@
import type { Aggregate } from "$lib/aggregates"
import ArticleView from "$lib/components/ArticleView.svelte"
import type { SectionTa } from "$lib/legal"
import { pathnameFromLegalId, type SectionTa } from "$lib/legal"
import { summarizeLegalObject } from "$lib/summaries"
export let data: Aggregate
@ -35,7 +35,12 @@
<ul class="inline">
{#each [...iterArrayOrSingleton(sectionTa.STRUCTURE_TA.LIEN_ART)] as lienArt}
<li class="inline after:content-[',_'] after:last:content-['']">
<a
class="link link-hover link-primary"
href={pathnameFromLegalId(lienArt["@id"])}
>
Article {lienArt["@num"]}
</a>
</li>
{/each}
</ul>

View file

@ -4,7 +4,7 @@
import type { Aggregate } from "$lib/aggregates"
import ArticleView from "$lib/components/ArticleView.svelte"
import SectionTaView from "$lib/components/SectionTaView.svelte"
import type { Textelr } from "$lib/legal"
import { pathnameFromLegalId, type Textelr } from "$lib/legal"
export let data: Aggregate
export let level = 1
@ -23,7 +23,12 @@
<ul class="inline">
{#each [...iterArrayOrSingleton(textelr.STRUCT.LIEN_ART)] as lienArt}
<li class="inline after:content-[',_'] after:last:content-['']">
<a
class="link link-hover link-primary"
href={pathnameFromLegalId(lienArt["@id"])}
>
Article {lienArt["@num"]}
</a>
</li>
{/each}
</ul>

View file

@ -1,6 +1,9 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import { goto } from "$app/navigation"
import { page } from "$app/stores"
import type { Follow } from "$lib/aggregates"
import IdPagesSwitcher from "$lib/components/IdPagesSwitcher.svelte"
import TexteVersionView from "$lib/components/TexteVersionView.svelte"
import { summarizeLegalObject } from "$lib/summaries"
@ -9,17 +12,43 @@
export let data: PageData
let follow = data.follow
let showArticles = false
let showRawData = false
$: id = data.id!
$: texteVersion = data.texte_version![id]
$: url = $page.url
$: summary = summarizeLegalObject(
{ key: "texte_version" },
"texte_version",
texteVersion,
)
$: if (
showArticles &&
!(["STRUCT.LIEN_ART.@id", "STRUCTURE_TA.LIEN_ART.@id"] as Follow[]).every(
(aFollow) => follow.includes(aFollow),
)
) {
const newFollow = new Set(follow)
for (const aFollow of [
"STRUCT.LIEN_ART.@id",
"STRUCTURE_TA.LIEN_ART.@id",
] as Follow[]) {
newFollow.add(aFollow)
}
const searchParams = new URLSearchParams(url.search)
searchParams.delete("follow")
for (const aFollow of [...newFollow].sort()) {
searchParams.append("follow", aFollow)
}
goto(new URL(`${url.pathname}?${searchParams.toString()}`, url), {
keepfocus: true,
noscroll: true,
})
}
</script>
<IdPagesSwitcher {id} />