Commit e40e2980 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Series View: Sort studies by year.

parent 15c1991c
Pipeline #227078 failed with stage
in 2 minutes and 42 seconds
<script lang="ts">
import JsonTree from "svelte-json-tree"
// import JsonTree from "svelte-json-tree"
import { stores } from "@sapper/app"
// import { stores } from "@sapper/app"
import {
extractCodeBookText,
// extractCodeBookText,
iterCodeBookDepositors,
iterCodeBookDistributors,
iterCodeBookProducers,
......@@ -15,13 +15,13 @@
import OrganizationName from "./OrganizationName.svelte"
import StudiesList from "./StudiesList.svelte"
import type { Series } from "../data"
import type { Series, Study } from "../data"
//import type { CodeBookVersion } from "../raw_types/codebooks"
import { localize } from "../stores"
export let series: Series
const { page } = stores()
// const { page } = stores()
$: _ = $localize
......@@ -42,11 +42,24 @@
codeBook === undefined ? [] : [...iterCodeBookDistributors(codeBook)]
$: depositors =
codeBook === undefined ? [] : [...iterCodeBookDepositors(codeBook)]
$: years = series.termsLabelByRelation?.year
.sort()
.map((year) => parseInt(year))
$: studies =
series.studies == null
? undefined
: [...series.studies].sort((study1, study2) =>
getStudyYear(study1).localeCompare(getStudyYear(study2)),
)
$: years = series.termsLabelByRelation?.year?.map((year) => parseInt(year))
$: yearsRange =
years === undefined ? undefined : [Math.min(...years), Math.max(...years)]
function getStudyYear(study: Study): string {
const years = study.termsLabelByRelation?.year?.map((year) =>
parseInt(year),
)
return years == null ? "" : Math.max(...years).toString()
}
</script>
<!-- grid-->
......@@ -147,7 +160,7 @@
{_("Keywords")}{_("colon")}
<hr class="sep h-2" />
<p class="text-xs">
{#each keywords as keyword, index}
{#each keywords as keyword}
<span class="badge ~neutral my-1 mx-1">{keyword}</span>
{/each}
</p>
......@@ -184,8 +197,8 @@
<!-- ONGLET STUDIES -->
<div class="flex flex-col overflow-hidden ml-6 mr-6 my-4">
{#if series.studies != null}
<StudiesList count={series.studies.length} studies={series.studies} />
{#if studies != null}
<StudiesList count={studies.length} {studies} />
{/if}
<hr class="sep h-20" />
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment