Skip to content

Commit

Permalink
Merge pull request #438 from diggsweden/release-5.0.6
Browse files Browse the repository at this point in the history
Release 5.0.6
  • Loading branch information
MickeA authored Jun 28, 2024
2 parents e9d27ab + 6bb44aa commit 2c9862a
Show file tree
Hide file tree
Showing 22 changed files with 855 additions and 175 deletions.
56 changes: 39 additions & 17 deletions components/content/Entryscape/ConceptPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { hemvist, linkBase } from "@/utilities";
import { Heading } from "@/components/global/Typography/Heading";
import { Container } from "@/components/layout/Container";
import { Preamble } from "@/components/global/Typography/Preamble";
import Link from "next/link";

export const ConceptPage: FC<{ curi?: string; scheme?: string }> = ({
curi,
Expand Down Expand Up @@ -327,7 +328,7 @@ export const ConceptPage: FC<{ curi?: string; scheme?: string }> = ({
"pages|concept_page$no_superior_concept",
)}</span></div>{{/ifprop}}' +
'{{#ifprop "skos:narrower"}}<div><h2>${t(
'{{#ifprop "skos:narrower"}}<div class="totMQA"><h2>${t(
"pages|concept_page$subordinate_concepts",
)}</h2>{{/ifprop}}' +
'{{#ifprop "skos:narrower"}}{{narrowerList}}</div>{{/ifprop}}' +
Expand Down Expand Up @@ -461,47 +462,68 @@ export const ConceptPage: FC<{ curi?: string; scheme?: string }> = ({
className="text-sm text-textSecondary"
data-entryscape="hemvist"
/>

{entry.hasResource && entry.hasResource?.length > 0 && (
<div>
<Heading
className="!text-[14px] font-strong text-textSecondary"
level={3}
>
{t("pages|datasetpage$related_specifications")}
</Heading>
{entry.hasResource.map(({ title, url }, idx) => (
<Link
className="block !text-[14px] text-green-600 hover:no-underline"
key={idx}
href={url}
>
{title}
</Link>
))}
</div>
)}
<span className="text-md" data-entryscape="terminology" />
<span data-entryscape="terminologyButton" />
{/* Download formats */}
<script
type="text/x-entryscape-handlebar"
data-entryscape="true"
data-entryscape-component="template"
dangerouslySetInnerHTML={{
__html: `
<div class="terminilogy__download-wrapper">
<h3 class="text-md">
${t("pages|concept_page$download_concept")}
<div class="mt-lg" >
<h3 class="text-md !mt-none">
${t("pages|datasetpage$download_link")}
</h3>
<div class="text-md"">
<div class="text-md flex flex-col gap-xs">
<a
class="terminology__download-link"
href="{{ metadataURI}}"
>
RDF/XML
${t(
"pages|datasetpage$download-metadata-as",
)} RDF/XML
</a>
<a
class="terminology__download-link"
href="{{ metadataURI }}?format=text/turtle"
href="{{ metadataURI }}?format=text/turtle&recursive=conceptscheme"
>
TURTLE
${t("pages|datasetpage$download-metadata-as")} TURTLE
</a>
<a
class="terminology__download-link"
href="{{ metadataURI }}?format=text/n-triples"
href="{{ metadataURI }}?format=text/n-triples&recursive=conceptscheme"
>
N-TRIPLES
${t(
"pages|datasetpage$download-metadata-as",
)} N-TRIPLES
</a>
<a
class="terminology__download-link"
href="{{ metadataURI }}?format=application/ld+json"
href="{{ metadataURI }}?format=application/ld+json&recursive=conceptscheme"
>
JSON-LD
${t(
"pages|datasetpage$download-metadata-as",
)} JSON-LD
</a>
</div>
</div>
Expand Down
104 changes: 91 additions & 13 deletions components/content/Entryscape/DataSetPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { Container } from "@/components/layout/Container";
import { Heading } from "@/components/global/Typography/Heading";
import { Preamble } from "@/components/global/Typography/Preamble";
import Link from "next/link";

const filterCatalogProperties = [
"dcat:keyword",
Expand All @@ -40,6 +41,7 @@ const filterAllExceptContactAndLandingPage = [
"dcterms:temporal",
"dcterms:accrualPeriodicity",
"dcterms:accessRights",
"dcterms:conformsTo",
];

const filterContactAndLandingPage = [
Expand All @@ -48,6 +50,7 @@ const filterContactAndLandingPage = [
"dcat:landingPage",
"http://data.europa.eu/r5r/applicableLegislation",
"http://xmlns.com/foaf/0.1/page",
"http://data.europa.eu/r5r/hvdCategory",
];

export const DataSetPage: React.FC = () => {
Expand All @@ -63,6 +66,11 @@ export const DataSetPage: React.FC = () => {
const postscribe = hasWindow && (window as any).postscribe;
const [showText, setShowText] = useState(false);
const [descriptionHeight, setDescriptionHeight] = useState(0);
const [showAllSpecs, setShowAllSpecs] = useState(false);
const relatedSpecs = showAllSpecs
? entry.conformsTo
: entry.conformsTo?.slice(0, 4);

/**
* Async load scripts requiered for EntryScape blocks,
* or else blocks wont have access to DOM
Expand Down Expand Up @@ -124,7 +132,7 @@ export const DataSetPage: React.FC = () => {
? env.ENTRYSCAPE_DATASETS_PATH
: "admin.dataportal.se"
}\/store'
};
};
function getApiExploreUrl(entryid,apientryid)
{
Expand Down Expand Up @@ -483,6 +491,35 @@ export const DataSetPage: React.FC = () => {

{/* About dataset */}
<div data-entryscape="aboutDataset" />
{entry.conformsTo && entry.conformsTo.length > 0 && (
<div>
<span className="rdformsLabel">
{t("pages|datasetpage$related_specifications")}
</span>
{relatedSpecs?.map((spec, idx) => (
<a
className="fit mb-sm block text-sm text-green-600 hover:no-underline"
key={idx}
href={spec.url}
>
{spec.title}
</a>
))}
{entry.conformsTo?.length > 4 && (
<Button
size={"xs"}
className="mt-xs px-sm py-xs !font-strong text-brown-600"
variant={"plain"}
label={
showAllSpecs
? t("pages|datasetpage$view_less")
: t("pages|datasetpage$view_more")
}
onClick={() => setShowAllSpecs(!showAllSpecs)}
/>
)}
</div>
)}
</div>

{/* Catalog informaton wrapper */}
Expand All @@ -494,6 +531,19 @@ export const DataSetPage: React.FC = () => {
>
{t("pages|datasetpage$catalog")}
</Heading>
{entry.mqaCatalog && (
<>
<h4 className="pb-xs text-sm font-strong text-brown-600">
{t("pages|datasetpage$mqa-catalog")}
</h4>
<Link
className="text-sm text-green-600 underline-offset-2 hover:no-underline"
href={`/metadatakvalitet/katalog/_quality/${cid}`}
>
{entry.mqaCatalog}
</Link>
</>
)}
<div />

{/* Catalog */}
Expand All @@ -515,25 +565,53 @@ export const DataSetPage: React.FC = () => {
}}
></script>

{/* Download RDF */}
{/* Download formats */}
<script
className="download__rdf"
type="text/x-entryscape-handlebar"
data-entryscape="true"
data-entryscape-block="template"
data-entryscape-component="template"
dangerouslySetInnerHTML={{
__html: `
<a class="text-white noUnderline" tabindex="-1" href="{{metadataURI}}?recursive=dcat">
<button class="button--primary button--large text-white flex items-center !no-underline">
${t("pages|datasetpage$rdf")}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M12 16L7 11L8.4 9.55L11 12.15V4H13V12.15L15.6 9.55L17 11L12 16ZM6 20C5.45 20 4.97917 19.8042 4.5875 19.4125C4.19583 19.0208 4 18.55 4 18V15H6V18H18V15H20V18C20 18.55 19.8042 19.0208 19.4125 19.4125C19.0208 19.8042 18.55 20 18 20H6Z" fill="#F0EFEE"/>
</svg>
</button>
</a>
<div>
<h3 class="text-md !mt-[12px]">
${t("pages|datasetpage$download_link")}
</h3>
<div class="text-md flex flex-col gap-xs">
<a
href="{{ metadataURI}}"
>
${t(
"pages|datasetpage$download-metadata-as",
)} RDF/XML
</a>
<a
href="{{ metadataURI }}?format=text/turtle"
>
${t("pages|datasetpage$download-metadata-as")} TURTLE
</a>
<a
href="{{ metadataURI }}?format=text/n-triples"
>
${t(
"pages|datasetpage$download-metadata-as",
)} N-TRIPLES
</a>
<a
href="{{ metadataURI }}?format=application/ld+json"
>
${t(
"pages|datasetpage$download-metadata-as",
)} JSON-LD
</a>
</div>
</div>
`,
}}
></script>
/>
</div>
</div>
</div>
Expand Down
38 changes: 36 additions & 2 deletions components/content/Entryscape/SpecificationPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import useTranslation from "next-translate/useTranslation";
import { FC, useContext, useEffect } from "react";
import { FC, useContext, useEffect, useState } from "react";
import { EntrystoreContext } from "@/providers/EntrystoreProvider";
import { SettingsContext } from "@/providers/SettingsProvider";
import { useRouter } from "next/router";
Expand All @@ -8,6 +8,7 @@ import { hemvist, keyword, linkBase } from "@/utilities";
import { Container } from "@/components/layout/Container";
import { Heading } from "@/components/global/Typography/Heading";
import { Preamble } from "@/components/global/Typography/Preamble";
import { Button } from "@/components/global/Button";

export const SpecificationPage: FC<{
curi?: string;
Expand All @@ -17,6 +18,10 @@ export const SpecificationPage: FC<{
const entry = useContext(EntrystoreContext);
const { lang, t } = useTranslation();
const { pathname } = useRouter() || {};
const [showAllDatasets, setShowAllDatasets] = useState(false);
const relatedDatasets = showAllDatasets
? entry.conformsTo
: entry.conformsTo?.slice(0, 4);

/**
* Async load scripts requiered for EntryScape blocks,
Expand Down Expand Up @@ -231,7 +236,7 @@ export const SpecificationPage: FC<{
"pages|specification_page$specification_download",
)}' +
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">' +
'<path d="M12 16L7 11L8.4 9.55L11 12.15V4H13V12.15L15.6 9.55L17 11L12 16ZM6 20C5.45 20 4.97917 19.8042 4.5875 19.4125C4.19583 19.0208 4 18.55 4 18V15H6V18H18V15H20V18C20 18.55 19.8042 19.0208 19.4125 19.4125C19.0208 19.8042 18.55 20 18 20H6Z" fill="#FFFFFF"/>' +
'<path d="M4.08008 11V13H16.0801L10.5801 18.5L12.0001 19.92L19.9201 12L12.0001 4.08002L10.5801 5.50002L16.0801 11H4.08008Z" fill="#6E615A"/>' +
'</svg>' +
'</button>' +
'</a>' +
Expand Down Expand Up @@ -338,6 +343,35 @@ export const SpecificationPage: FC<{
data-entryscape-filterpredicates="dcterms:title,dcterms:description,dcat:distribution,dcterms:publisher,prof:hasResource,adms:prev,dcat:keyword"
></div>
</div>
{entry.conformsTo && entry.conformsTo.length > 0 && (
<div>
<span className="rdformsLabel">
{t("pages|specification_page$related_datasets")}
</span>
{relatedDatasets?.map((ds, idx) => (
<a
className="fit mb-sm block text-sm text-green-600 hover:no-underline"
key={idx}
href={`/datasets${ds.url}`}
>
{ds.title}
</a>
))}
{entry.conformsTo?.length > 4 && (
<Button
size={"xs"}
className="mt-xs px-sm py-xs !font-strong text-brown-600"
variant={"plain"}
label={
showAllDatasets
? t("pages|datasetpage$view_less")
: t("pages|datasetpage$view_more")
}
onClick={() => setShowAllDatasets(!showAllDatasets)}
/>
)}
</div>
)}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 2c9862a

Please sign in to comment.