Show database links & improve generation of codes
This commit is contained in:
parent
0dd6d392cd
commit
a50e1361e7
9 changed files with 734 additions and 493 deletions
|
@ -24,13 +24,13 @@
|
|||
|
||||
<div class="ml-4">
|
||||
{#if showArticles}
|
||||
{#each [...iterArrayOrSingleton(sectionTa.STRUCTURE_TA.LIEN_ART)] as lienArt}
|
||||
{#each [...iterArrayOrSingleton(sectionTa.STRUCTURE_TA?.LIEN_ART)] as lienArt}
|
||||
{@const article = data.article?.[lienArt["@id"]]}
|
||||
{#if article !== undefined}
|
||||
<ArticleView {article} {data} level={level + 1} />
|
||||
{/if}
|
||||
{/each}
|
||||
{:else if sectionTa.STRUCTURE_TA.LIEN_ART !== undefined}
|
||||
{:else if sectionTa.STRUCTURE_TA?.LIEN_ART !== undefined}
|
||||
<ul class="inline">
|
||||
{#each [...iterArrayOrSingleton(sectionTa.STRUCTURE_TA.LIEN_ART)] as lienArt}
|
||||
<li class="inline after:content-[',_'] after:last:content-['']">
|
||||
|
@ -45,7 +45,7 @@
|
|||
</ul>
|
||||
{/if}
|
||||
|
||||
{#each [...iterArrayOrSingleton(sectionTa.STRUCTURE_TA.LIEN_SECTION_TA)] as lienSectionTa}
|
||||
{#each [...iterArrayOrSingleton(sectionTa.STRUCTURE_TA?.LIEN_SECTION_TA)] as lienSectionTa}
|
||||
{@const sectionTa = data.section_ta?.[lienSectionTa["@id"]]}
|
||||
{#if sectionTa !== undefined}
|
||||
<svelte:self {data} level={level + 1} {sectionTa} {showArticles} />
|
||||
|
|
|
@ -418,7 +418,7 @@ export interface SectionTa {
|
|||
ID: string
|
||||
CONTEXTE: Contexte
|
||||
TITRE_TA: string
|
||||
STRUCTURE_TA: {
|
||||
STRUCTURE_TA?: {
|
||||
LIEN_ART?: LienArt | LienArt[]
|
||||
LIEN_SECTION_TA?: LienSectionTa | LienSectionTa[]
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export class Aggregator {
|
|||
|
||||
if (this.follow.has("STRUCTURE_TA.LIEN_ART.@id")) {
|
||||
for (const lien of iterArrayOrSingleton(
|
||||
sectionTa.STRUCTURE_TA.LIEN_ART,
|
||||
sectionTa.STRUCTURE_TA?.LIEN_ART,
|
||||
)) {
|
||||
this.requestId(lien["@id"])
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ export class Aggregator {
|
|||
|
||||
if (this.follow.has("STRUCTURE_TA.LIEN_SECTION_TA.@id")) {
|
||||
for (const lien of iterArrayOrSingleton(
|
||||
sectionTa.STRUCTURE_TA.LIEN_SECTION_TA,
|
||||
sectionTa.STRUCTURE_TA?.LIEN_SECTION_TA,
|
||||
)) {
|
||||
this.requestId(lien["@id"])
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import {
|
|||
type TmLienTxt,
|
||||
type VersionsWrapper,
|
||||
} from "$lib/legal"
|
||||
import type { ArticleLienDb, TexteVersionLienDb } from "$lib/legal/shared"
|
||||
|
||||
export const summarizeAggregateProperties: Summarizer = (access, value) => {
|
||||
for (const summarizer of [
|
||||
|
@ -49,6 +50,69 @@ export const summarizeAggregateProperties: Summarizer = (access, value) => {
|
|||
return undefined
|
||||
}
|
||||
|
||||
export const summarizeArticleLienDb: Summarizer = (access, value) => {
|
||||
const articleLien = value as ArticleLienDb | undefined
|
||||
if (articleLien === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return {
|
||||
items: [
|
||||
{
|
||||
content: `Article ${articleLien.article_id}`,
|
||||
href: pathnameFromLegalId(articleLien.article_id) as string,
|
||||
type: "link",
|
||||
},
|
||||
` ${articleLien.typelien} ${articleLien.cible ? "CIBLE" : "SOURCE"} `,
|
||||
articleLien.cidtexte === null
|
||||
? `cidtexte : null`
|
||||
: {
|
||||
content: `cidtexte : ${articleLien.cidtexte}`,
|
||||
href: pathnameFromLegalId(articleLien.cidtexte) as string,
|
||||
type: "link",
|
||||
},
|
||||
", id : ",
|
||||
{
|
||||
content: articleLien.id,
|
||||
href: pathnameFromLegalId(articleLien.id) as string,
|
||||
type: "link",
|
||||
},
|
||||
],
|
||||
type: "concatenation",
|
||||
}
|
||||
}
|
||||
|
||||
export const summarizeArticleLienDbProperties: Summarizer = (access, value) => {
|
||||
if (
|
||||
access?.key === "article_lien" &&
|
||||
(value === undefined ||
|
||||
// Ensure that value is not a dictionary of article by id.
|
||||
Object.keys(value as { [key: string]: unknown }).some(
|
||||
(key) => key.match(/^[A-Z]{8}\d{12}$/) === null,
|
||||
))
|
||||
) {
|
||||
return summarizeArticleLienDb(access, value)
|
||||
}
|
||||
if (
|
||||
access?.access?.key === "article_lien" &&
|
||||
(Array.isArray(access.parent) ||
|
||||
(typeof access?.key === "string" &&
|
||||
access.key.match(/^[A-Z]{8}\d{12}$/) !== null))
|
||||
) {
|
||||
return summarizeArticleLienDb(access, value)
|
||||
}
|
||||
|
||||
if (access?.key === "article_id") {
|
||||
return summarizeLegalIdToLink(access, value)
|
||||
}
|
||||
if (access?.key === "cidtexte") {
|
||||
return summarizeLegalIdToLink(access, value)
|
||||
}
|
||||
if (access?.key === "id") {
|
||||
return summarizeLegalIdToLink(access, value)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export const summarizeArticleProperties: Summarizer = (access, value) => {
|
||||
if (
|
||||
access?.key === "article" &&
|
||||
|
@ -317,7 +381,7 @@ export function summarizeLegalIdToValueArrowLink(
|
|||
content: JSON.stringify(value),
|
||||
type: "raw_data",
|
||||
},
|
||||
{ class: "mx-1 mt-1", icon: arrowRight, inline: true, type: "icon" },
|
||||
{ class: "mr-1 mt-0.5 w-3 flex-none", icon: MoveRight, type: "icon" },
|
||||
uidLinkSummary,
|
||||
],
|
||||
type: "concatenation",
|
||||
|
@ -472,7 +536,7 @@ export const summarizeLienArtId: Summarizer = (access, value) => {
|
|||
content: JSON.stringify(lienArt["@id"]),
|
||||
type: "raw_data",
|
||||
},
|
||||
{ class: "mt-1 mx-1", icon: arrowRight, inline: true, type: "icon" },
|
||||
{ class: "mr-1 mt-0.5 w-3 flex-none", icon: MoveRight, type: "icon" },
|
||||
summarizeLienArt(access, lienArt) as Summary,
|
||||
],
|
||||
type: "concatenation",
|
||||
|
@ -494,7 +558,7 @@ export const summarizeLienId: Summarizer = (access, value) => {
|
|||
content: JSON.stringify(lien["@id"]),
|
||||
type: "raw_data",
|
||||
},
|
||||
{ class: "mt-1 mx-1", icon: arrowRight, inline: true, type: "icon" },
|
||||
{ class: "mr-1 mt-0.5 w-3 flex-none", icon: MoveRight, type: "icon" },
|
||||
{
|
||||
content: lien["#text"],
|
||||
href: pathname,
|
||||
|
@ -528,7 +592,7 @@ export const summarizeLienSectionTaId: Summarizer = (access, value) => {
|
|||
content: JSON.stringify(lienSectionTa["@id"]),
|
||||
type: "raw_data",
|
||||
},
|
||||
{ class: "mt-1 mx-1", icon: arrowRight, inline: true, type: "icon" },
|
||||
{ class: "mr-1 mt-0.5 w-3 flex-none", icon: MoveRight, type: "icon" },
|
||||
summarizeLienSectionTa(access, lienSectionTa) as Summary,
|
||||
],
|
||||
type: "concatenation",
|
||||
|
@ -708,6 +772,72 @@ export const summarizeTextelrProperties: Summarizer = (access, value) => {
|
|||
return undefined
|
||||
}
|
||||
|
||||
export const summarizeTexteVersionLienDb: Summarizer = (access, value) => {
|
||||
const texteVersionLien = value as TexteVersionLienDb | undefined
|
||||
if (texteVersionLien === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return {
|
||||
items: [
|
||||
{
|
||||
content: `TexteVersion ${texteVersionLien.texte_version_id}`,
|
||||
href: pathnameFromLegalId(texteVersionLien.texte_version_id) as string,
|
||||
type: "link",
|
||||
},
|
||||
` ${texteVersionLien.typelien} ${texteVersionLien.cible ? "CIBLE" : "SOURCE"} `,
|
||||
texteVersionLien.cidtexte === null
|
||||
? `cidtexte : null`
|
||||
: {
|
||||
content: `cidtexte : ${texteVersionLien.cidtexte}`,
|
||||
href: pathnameFromLegalId(texteVersionLien.cidtexte) as string,
|
||||
type: "link",
|
||||
},
|
||||
", id : ",
|
||||
{
|
||||
content: texteVersionLien.id,
|
||||
href: pathnameFromLegalId(texteVersionLien.id) as string,
|
||||
type: "link",
|
||||
},
|
||||
],
|
||||
type: "concatenation",
|
||||
}
|
||||
}
|
||||
|
||||
export const summarizeTexteVersionLienDbProperties: Summarizer = (
|
||||
access,
|
||||
value,
|
||||
) => {
|
||||
if (
|
||||
access?.key === "texte_version_lien" &&
|
||||
(value === undefined ||
|
||||
// Ensure that value is not a dictionary of TexteVersion by id.
|
||||
Object.keys(value as { [key: string]: unknown }).some(
|
||||
(key) => key.match(/^[A-Z]{8}\d{12}$/) === null,
|
||||
))
|
||||
) {
|
||||
return summarizeTexteVersionLienDb(access, value)
|
||||
}
|
||||
if (
|
||||
access?.access?.key === "texte_version_lien" &&
|
||||
(Array.isArray(access.parent) ||
|
||||
(typeof access?.key === "string" &&
|
||||
access.key.match(/^[A-Z]{8}\d{12}$/) !== null))
|
||||
) {
|
||||
return summarizeTexteVersionLienDb(access, value)
|
||||
}
|
||||
|
||||
if (access?.key === "texte_version_id") {
|
||||
return summarizeLegalIdToLink(access, value)
|
||||
}
|
||||
if (access?.key === "cidtexte") {
|
||||
return summarizeLegalIdToLink(access, value)
|
||||
}
|
||||
if (access?.key === "id") {
|
||||
return summarizeLegalIdToLink(access, value)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export const summarizeTexteVersionProperties: Summarizer = (access, value) => {
|
||||
if (
|
||||
access?.key === "texte_version" &&
|
||||
|
@ -754,7 +884,7 @@ export const summarizeTitreTmId: Summarizer = (access, value) => {
|
|||
content: JSON.stringify(titreTm["@id"]),
|
||||
type: "raw_data",
|
||||
},
|
||||
{ class: "mt-1 mx-1", icon: arrowRight, inline: true, type: "icon" },
|
||||
{ class: "mr-1 mt-0.5 w-3 flex-none", icon: MoveRight, type: "icon" },
|
||||
{
|
||||
content: titreTm["#text"],
|
||||
href: pathname,
|
||||
|
@ -780,7 +910,7 @@ export const summarizeTitreTxtIdTxt: Summarizer = (access, value) => {
|
|||
content: JSON.stringify(titreTxt["@id_txt"]),
|
||||
type: "raw_data",
|
||||
},
|
||||
{ class: "mt-1 mx-1", icon: arrowRight, inline: true, type: "icon" },
|
||||
{ class: "mr-1 mt-0.5 w-3 flex-none", icon: MoveRight, type: "icon" },
|
||||
{
|
||||
content: titreTxt["#text"],
|
||||
href: pathname,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { error } from "@sveltejs/kit"
|
||||
|
||||
import type { Article } from "$lib/legal"
|
||||
import type { ArticleLienDb, TexteVersionLienDb } from "$lib/legal/shared"
|
||||
import { db } from "$lib/server/databases"
|
||||
|
||||
import type { PageServerLoad } from "./$types"
|
||||
|
@ -16,5 +17,17 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||
if (article === undefined) {
|
||||
error(404, `Article ${params.id} non trouvé`)
|
||||
}
|
||||
return { article }
|
||||
|
||||
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,
|
||||
article_lien: articleLienDbArray,
|
||||
texte_version_lien: texteVersionLienDbArray,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,26 @@
|
|||
import { TreeView, SummaryView } from "augmented-data-viewer"
|
||||
|
||||
import {
|
||||
summarizeArticleLienDbProperties,
|
||||
summarizeArticleProperties,
|
||||
summarizeLegalObject,
|
||||
summarizeTexteVersionLienDbProperties,
|
||||
} from "$lib/summaries"
|
||||
|
||||
import type { PageData } from "./$types"
|
||||
|
||||
export let data: PageData
|
||||
|
||||
$: ({ article } = data)
|
||||
$: ({
|
||||
article,
|
||||
article_lien: articleLienDbArray,
|
||||
texte_version_lien: texteVersionLienDbArray,
|
||||
} = data)
|
||||
|
||||
$: summary = summarizeLegalObject({ key: "article" }, "article", article)
|
||||
</script>
|
||||
|
||||
<header class="prose my-6 max-w-full">
|
||||
<header class="my-6 max-w-full">
|
||||
<h2
|
||||
class="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0"
|
||||
>
|
||||
|
@ -35,3 +41,35 @@
|
|||
summarize={summarizeArticleProperties}
|
||||
value={article}
|
||||
/>
|
||||
|
||||
<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 l'article
|
||||
</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 l'article
|
||||
</h2>
|
||||
|
||||
<TreeView
|
||||
access={{ key: "texte_version_lien" }}
|
||||
frame={false}
|
||||
open
|
||||
summarize={summarizeTexteVersionLienDbProperties}
|
||||
value={texteVersionLienDbArray}
|
||||
/>
|
||||
</section>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { error } from "@sveltejs/kit"
|
||||
|
||||
import type { SectionTa } from "$lib/legal"
|
||||
import type { ArticleLienDb, TexteVersionLienDb } from "$lib/legal/shared"
|
||||
import { db } from "$lib/server/databases"
|
||||
|
||||
import type { PageServerLoad } from "./$types"
|
||||
|
@ -16,5 +17,17 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||
if (sectionTa === undefined) {
|
||||
error(404, `SECTION_TA ${params.id} non trouvé`)
|
||||
}
|
||||
return { section_ta: sectionTa }
|
||||
|
||||
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,
|
||||
section_ta: sectionTa,
|
||||
texte_version_lien: texteVersionLienDbArray,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,21 @@
|
|||
import { TreeView, SummaryView } from "augmented-data-viewer"
|
||||
|
||||
import {
|
||||
summarizeSectionTaProperties,
|
||||
summarizeArticleLienDbProperties,
|
||||
summarizeLegalObject,
|
||||
summarizeSectionTaProperties,
|
||||
summarizeTexteVersionLienDbProperties,
|
||||
} from "$lib/summaries"
|
||||
|
||||
import type { PageData } from "./$types"
|
||||
|
||||
export let data: PageData
|
||||
|
||||
$: ({ section_ta: sectionTa } = data)
|
||||
$: ({
|
||||
article_lien: articleLienDbArray,
|
||||
section_ta: sectionTa,
|
||||
texte_version_lien: texteVersionLienDbArray,
|
||||
} = data)
|
||||
|
||||
$: summary = summarizeLegalObject(
|
||||
{ key: "section_ta" },
|
||||
|
@ -19,7 +25,7 @@
|
|||
)
|
||||
</script>
|
||||
|
||||
<header class="prose my-6 max-w-full">
|
||||
<header class="my-6 max-w-full">
|
||||
<h2
|
||||
class="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0"
|
||||
>
|
||||
|
@ -39,3 +45,35 @@
|
|||
summarize={summarizeSectionTaProperties}
|
||||
value={sectionTa}
|
||||
/>
|
||||
|
||||
<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 la SECTION_TA
|
||||
</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 la SECTION_TA
|
||||
</h2>
|
||||
|
||||
<TreeView
|
||||
access={{ key: "texte_version_lien" }}
|
||||
frame={false}
|
||||
open
|
||||
summarize={summarizeTexteVersionLienDbProperties}
|
||||
value={texteVersionLienDbArray}
|
||||
/>
|
||||
</section>
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue