Show database links pointing to texts

This commit is contained in:
Emmanuel 2024-12-07 08:08:58 +01:00
parent 2ee17b6b3e
commit 8b3a32d3c0
2 changed files with 54 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import { error } from "@sveltejs/kit" import { error } from "@sveltejs/kit"
import type { TexteVersion } from "$lib/legal" import type { TexteVersion } from "$lib/legal"
import type { ArticleLienDb, TexteVersionLienDb } from "$lib/legal/shared"
import { db } from "$lib/server/databases" import { db } from "$lib/server/databases"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
@ -16,5 +17,17 @@ export const load: PageServerLoad = async ({ params }) => {
if (texteVersion === undefined) { if (texteVersion === undefined) {
error(404, `TEXTE_VERSION ${params.id} non trouvé`) error(404, `TEXTE_VERSION ${params.id} non trouvé`)
} }
return { texte_version: texteVersion }
const articleLienDbArray = await db<ArticleLienDb[]>`
SELECT * FROM article_lien WHERE id = ${params.id}
`
const texteVersionLienDbArray = await db<TexteVersionLienDb[]>`
SELECT * FROM texte_version_lien WHERE id = ${params.id}
`
return {
article_lien: articleLienDbArray,
texte_version: texteVersion,
texte_version_lien: texteVersionLienDbArray,
}
} }

View file

@ -3,15 +3,21 @@
import IdPagesSwitcher from "$lib/components/IdPagesSwitcher.svelte" import IdPagesSwitcher from "$lib/components/IdPagesSwitcher.svelte"
import { import {
summarizeTexteVersionProperties, summarizeArticleLienDbProperties,
summarizeLegalObject, summarizeLegalObject,
summarizeTexteVersionLienDbProperties,
summarizeTexteVersionProperties,
} from "$lib/summaries" } from "$lib/summaries"
import type { PageData } from "./$types" import type { PageData } from "./$types"
export let data: PageData export let data: PageData
$: ({ texte_version: texteVersion } = data) $: ({
article_lien: articleLienDbArray,
texte_version: texteVersion,
texte_version_lien: texteVersionLienDbArray,
} = data)
$: summary = summarizeLegalObject( $: summary = summarizeLegalObject(
{ key: "texte_version" }, { key: "texte_version" },
@ -42,3 +48,35 @@
summarize={summarizeTexteVersionProperties} summarize={summarizeTexteVersionProperties}
value={texteVersion} value={texteVersion}
/> />
<section class="mt-4">
<h2
class="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0"
>
Articles pointant sur le texte
</h2>
<TreeView
access={{ key: "article_lien" }}
frame={false}
open
summarize={summarizeArticleLienDbProperties}
value={articleLienDbArray}
/>
</section>
<section class="mt-4">
<h2
class="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0"
>
Textes pointant sur le texte
</h2>
<TreeView
access={{ key: "texte_version_lien" }}
frame={false}
open
summarize={summarizeTexteVersionLienDbProperties}
value={texteVersionLienDbArray}
/>
</section>