STRUCT is optional in TEXTELR

This commit is contained in:
Emmanuel 2023-06-19 13:50:06 +02:00
parent cff3202a1b
commit 5080b139b7
3 changed files with 9 additions and 7 deletions

View file

@ -13,13 +13,13 @@
</script>
{#if showArticles}
{#each [...iterArrayOrSingleton(textelr.STRUCT.LIEN_ART)] as lienArt}
{#each [...iterArrayOrSingleton(textelr.STRUCT?.LIEN_ART)] as lienArt}
{@const article = data.article?.[lienArt["@id"]]}
{#if article !== undefined}
<ArticleView {article} {data} level={level + 1} />
{/if}
{/each}
{:else if textelr.STRUCT.LIEN_ART !== undefined}
{:else if textelr.STRUCT?.LIEN_ART !== undefined}
<ul class="inline">
{#each [...iterArrayOrSingleton(textelr.STRUCT.LIEN_ART)] as lienArt}
<li class="inline after:content-[',_'] after:last:content-['']">
@ -34,7 +34,7 @@
</ul>
{/if}
{#each [...iterArrayOrSingleton(textelr.STRUCT.LIEN_SECTION_TA)] as lienSectionTa}
{#each [...iterArrayOrSingleton(textelr.STRUCT?.LIEN_SECTION_TA)] as lienSectionTa}
{@const sectionTa = data.section_ta?.[lienSectionTa["@id"]]}
{#if sectionTa !== undefined}
<SectionTaView {data} level={level + 1} {sectionTa} {showArticles} />

View file

@ -457,7 +457,7 @@ export interface Textelr {
META_TEXTE_CHRONICLE: MetaTexteChronicle
}
}
STRUCT: {
STRUCT?: {
LIEN_ART?: LienArt | LienArt[]
LIEN_SECTION_TA?: LienSectionTa | LienSectionTa[]
}

View file

@ -65,7 +65,7 @@ export class Aggregator {
this.textekali[id] = textekali
if (this.follow.has("STRUCT.LIEN_ART.@id")) {
for (const lien of iterArrayOrSingleton(textekali.STRUCT.LIEN_ART)) {
for (const lien of iterArrayOrSingleton(textekali.STRUCT?.LIEN_ART)) {
this.requestId(lien["@id"])
}
}
@ -84,13 +84,15 @@ export class Aggregator {
this.textelr[id] = textelr
if (this.follow.has("STRUCT.LIEN_ART.@id")) {
for (const lien of iterArrayOrSingleton(textelr.STRUCT.LIEN_ART)) {
for (const lien of iterArrayOrSingleton(textelr.STRUCT?.LIEN_ART)) {
this.requestId(lien["@id"])
}
}
if (this.follow.has("STRUCT.LIEN_SECTION_TA.@id")) {
for (const lien of iterArrayOrSingleton(textelr.STRUCT.LIEN_SECTION_TA)) {
for (const lien of iterArrayOrSingleton(
textelr.STRUCT?.LIEN_SECTION_TA,
)) {
this.requestId(lien["@id"])
}
}