Skip to content

Commit

Permalink
Merge pull request #434 from diggsweden/DIGG-384
Browse files Browse the repository at this point in the history
Digg 384 Specification and terminology link url update
  • Loading branch information
AlessandroGasperini authored Jun 25, 2024
2 parents 86c1054 + f492c3f commit 6bb44aa
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 15 deletions.
21 changes: 20 additions & 1 deletion 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 @@ -461,7 +462,25 @@ 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 */}
Expand Down
2 changes: 1 addition & 1 deletion components/content/Entryscape/SpecificationPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,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
18 changes: 9 additions & 9 deletions components/content/Search/SearchResults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ export const SearchResults: FC<SearchResultsProps> = ({
}}
className="group block no-underline"
>
<Heading
level={3}
size="sm"
className="focus--underline mb-sm font-normal text-green-600 group-hover:underline"
lang={hit.titleLang}
>
{hit.title}
</Heading>

{hit.metadata &&
search.allFacets &&
!search.loadingFacets &&
Expand All @@ -250,15 +259,6 @@ export const SearchResults: FC<SearchResultsProps> = ({
</span>
)}

<Heading
level={3}
size="sm"
className="focus--underline mb-sm font-normal text-green-600 group-hover:underline"
lang={hit.titleLang}
>
{hit.title}
</Heading>

{isCompact && hit.descriptionLang && (
<p className="mb-xs">{hit.description}</p>
)}
Expand Down
2 changes: 1 addition & 1 deletion locales/en/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"resource_specification": "Resource",
"scheme_download": "Download schema",
"guidance_download": "Download guidance",
"specification_download": "Download specification",
"specification_download": "Access URL",
"related_datasets": "Related datasets",
"download": "Download"
},
Expand Down
2 changes: 1 addition & 1 deletion locales/sv/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
"resource_specification": "Resurs",
"scheme_download": "Ladda ner schema",
"guidance_download": "Ladda ner guidance",
"specification_download": "Ladda ner specifikation",
"specification_download": "Åtkomst",
"related_datasets": "Relaterade datamängder",
"download": "Ladda ner"
},
Expand Down
28 changes: 26 additions & 2 deletions providers/EntrystoreProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SettingsUtil } from "@/env/SettingsUtil";
//unfortunate hack to get a entrystore class instance, script is inserted in head
declare var ESJS: any;

type ConformsTo = {
type RelationObj = {
title: string;
url: string;
};
Expand All @@ -33,7 +33,8 @@ export interface ESEntry {
termPublisher: string;
definition: string;
contact?: ESContact;
conformsTo?: ConformsTo[];
conformsTo?: RelationObj[];
hasResource?: RelationObj[];
mqaCatalog?: string;
}

Expand All @@ -52,6 +53,7 @@ const defaultESEntry: ESEntry = {
termPublisher: "",
definition: "",
conformsTo: [],
hasResource: [],
};

export const EntrystoreContext = createContext<ESEntry>(defaultESEntry);
Expand Down Expand Up @@ -217,6 +219,12 @@ export const EntrystoreProvider: React.FC<EntrystoreProviderProps> = ({
.uriProperty("dcterms:conformsTo", resourceURI)
.getEntries();

const hasResource = await es
.newSolrQuery()
.rdfType(["dcterms:Standard", "prof:Profile"])
.uriProperty("prof:hasResource", resourceURI)
.getEntries();

const datasetArr = await Promise.all(
datasets.map(async (ds: any) => {
const title = await getLocalizedValue(
Expand All @@ -234,6 +242,21 @@ export const EntrystoreProvider: React.FC<EntrystoreProviderProps> = ({
}),
);

const resourceArr = await Promise.all(
hasResource.map(async (spec: any) => {
const title = await getLocalizedValue(
spec.getAllMetadata(),
"dcterms:title",
nextLang,
es,
);
return {
title: title,
url: spec.getResourceURI(),
};
}),
);

//the getLocalizedValue function might fetch from network, so start all IO with promises
valuePromises.push(
getLocalizedValue(graph, "dcterms:title", nextLang, es, {
Expand Down Expand Up @@ -294,6 +317,7 @@ export const EntrystoreProvider: React.FC<EntrystoreProviderProps> = ({
defaultESEntry.publisher = results[3];
defaultESEntry.definition = results[4];
defaultESEntry.conformsTo = datasetArr || null;
defaultESEntry.hasResource = resourceArr || null;

if (fetchMore && !isConcept) {
if (results[5] || results[6]) {
Expand Down

0 comments on commit 6bb44aa

Please sign in to comment.