Commit 9ee00663 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat: [BienCulturelInfo] Render the source of the instance, which is the graph...

feat: [BienCulturelInfo] Render the source of the instance, which is the graph in the sparql endpoint
parent 25def0086bce
Pipeline #15212 failed with stages
in 4 minutes and 17 seconds
......@@ -32,7 +32,7 @@ const DESCRIPTOR_BIENCULTURELCLASS: definition.ViewDescriptor = {
interface BienCulturelClassProps {
label: string;
instances: string[];
instances: { uri: string; graph: string }[];
dataFetcher?: implementation.DataFetcher;
generateUrl?: (uri: string) => string;
}
......@@ -65,7 +65,7 @@ const BienCulturelClass: React.FC<BienCulturelClassProps> = (props) => {
React.useEffect(() => {
Promise.all(
instances.map((instance) =>
dataFetcher.fetchDataFromURI(instance, {
dataFetcher.fetchDataFromURI(instance.uri, {
typeUris: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
label: 'http://www.w3.org/2000/01/rdf-schema#label',
locationUri: CULT('aPourLocalisation').value,
......@@ -74,7 +74,8 @@ const BienCulturelClass: React.FC<BienCulturelClassProps> = (props) => {
).then((instancesData) =>
setBienCulturelInstances(
instancesData.map((instanceData, index) => ({
uri: instances[index],
uri: instances[index].uri,
graph: instances[index].graph,
typeUris: instanceData.typeUris instanceof Array ? instanceData.typeUris : [instanceData.typeUris],
label: instanceData.label instanceof Array ? instanceData.label[0] : instanceData.label,
locationUri:
......@@ -221,7 +222,9 @@ class BienCulturelClassRendering implements implementation.ViewImplementation {
const targetSym = $rdf.sym(target);
const bienCulturelClass = {
label: context.anyJS(targetSym, RDFS('label')),
instances: context.each(null, RDF('type'), targetSym).map((node) => node.value),
instances: context
.statementsMatching(null, RDF('type'), targetSym, null)
.map((statement) => ({ uri: statement.subject.value, graph: statement.graph.value })),
dataFetcher,
generateUrl,
};
......
......@@ -40,6 +40,7 @@ interface BienCulturelProps {
export interface BienCulturelInfoProps {
uri?: string;
graph?: string;
typeUris: string[];
label: string;
dataFetcher?: implementation.DataFetcher;
......@@ -54,6 +55,7 @@ export interface Location {
export const BienCulturelInfo: React.FC<BienCulturelInfoProps> = (props) => {
const {
uri,
graph,
typeUris,
label,
dataFetcher = { fetchDataFromURI: () => Promise.reject('Not implemented') },
......@@ -68,6 +70,7 @@ export const BienCulturelInfo: React.FC<BienCulturelInfoProps> = (props) => {
<URIBadge uri={uri} dataFetcher={dataFetcher} generateUrl={generateUrl} />
))}
</h5>
{graph && <span>Source : {graph} </span>}
</>
);
};
......
Supports Markdown
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