diff --git a/client/src/pages/home/filters.jsx b/client/src/pages/home/filters.jsx
index 54448dc8..1e261fbb 100644
--- a/client/src/pages/home/filters.jsx
+++ b/client/src/pages/home/filters.jsx
@@ -43,15 +43,6 @@ export default function Filters({ sendQuery }) {
}
}, [searchParams, setSearchParams]);
- const onDatasourcesChange = (key) => {
- const { datasources } = currentSearchParams;
- if (datasources.includes(key)) {
- setSearchParams({ ...currentSearchParams, datasources: datasources.filter((datasource) => datasource !== key) });
- } else {
- setSearchParams({ ...currentSearchParams, datasources: [...datasources, key] });
- }
- };
-
const onIdentifiersChange = (label) => {
const { dataIdentifiers } = currentSearchParams;
if (dataIdentifiers.includes(label)) {
@@ -74,8 +65,6 @@ export default function Filters({ sendQuery }) {
sendQuery(currentSearchParams);
};
- const checkSource = (source) => (currentSearchParams?.datasources ?? []).includes(source);
-
return (
<>
@@ -88,22 +77,6 @@ export default function Filters({ sendQuery }) {
onInputHandler={setOnInputAffiliationsHandler}
/>
-
- Datasources
-
- {
- sources.map((source) => (
- onDatasourcesChange(source.key)}
- size="sm"
- />
- ))
- }
-
-
diff --git a/client/src/pages/home/index.jsx b/client/src/pages/home/index.jsx
index 0f591628..cc361d0e 100644
--- a/client/src/pages/home/index.jsx
+++ b/client/src/pages/home/index.jsx
@@ -2,7 +2,7 @@
/* eslint-disable indent */
/* eslint-disable jsx-a11y/control-has-associated-label */
/* eslint-disable no-case-declarations */
-import { Button, Col, Container, Notice, Row, Tab, Tabs } from '@dataesr/react-dsfr';
+import { Button, Checkbox, CheckboxGroup, Col, Container, Notice, Row, Tab, Tabs } from '@dataesr/react-dsfr';
import { useQuery } from '@tanstack/react-query';
import { useEffect, useState } from 'react';
@@ -41,6 +41,7 @@ const TO_BE_DECIDED_STATUS = 'to be decided';
const VALIDATED_STATUS = 'validated';
const EXCLUDED_STATUS = 'excluded';
const REGEXP_ROR = /^(https:\/\/ror\.org\/|ror\.org\/){0,1}0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$/;
+const DATASOURCES = [{ key: 'bso', label: 'French OSM' }, { key: 'openalex', label: 'OpenAlex' }];
const getRorAffiliations = (affiliations) => {
const notRorAffiliations = [];
@@ -104,6 +105,7 @@ export default function Home() {
const [allAffiliations, setAllAffiliations] = useState([]);
const [allDatasets, setAllDatasets] = useState([]);
const [allPublications, setAllPublications] = useState([]);
+ const [filteredDatasources, setFilteredDatasources] = useState(DATASOURCES.map((datasource) => datasource.key));
const [isLoading, setIsLoading] = useState(false);
const [options, setOptions] = useState({});
const [regexp, setRegexp] = useState();
@@ -200,16 +202,18 @@ export default function Home() {
let allDatasetsTmp = [];
let allPublicationsTmp = [];
if (data) {
- allDatasetsTmp = data.datasets.map((dataset) => ({
- ...dataset,
- affiliationsHtml: getAffiliationsHtmlField(dataset, regexp),
- affiliationsSearch: getAffiliationsSearchField(dataset),
- allIdsHtml: getAllIdsHtmlField(dataset),
- authorsHtml: getAuthorsHtmlField(dataset),
- authorsTooltip: getAuthorsTooltipField(dataset),
- status: TO_BE_DECIDED_STATUS,
- }));
+ allDatasetsTmp = data.datasets
+ .map((dataset) => ({
+ ...dataset,
+ affiliationsHtml: getAffiliationsHtmlField(dataset, regexp),
+ affiliationsSearch: getAffiliationsSearchField(dataset),
+ allIdsHtml: getAllIdsHtmlField(dataset),
+ authorsHtml: getAuthorsHtmlField(dataset),
+ authorsTooltip: getAuthorsTooltipField(dataset),
+ status: TO_BE_DECIDED_STATUS,
+ }));
allPublicationsTmp = data.publications
+ .filter((publication) => filteredDatasources.includes(publication.datasource))
.map((publication) => ({
...publication,
affiliationsHtml: getAffiliationsHtmlField(publication, regexp),
@@ -222,12 +226,12 @@ export default function Home() {
}
setAllDatasets(allDatasetsTmp);
setAllPublications(allPublicationsTmp);
- }, [data, regexp]);
+ }, [data, filteredDatasources, regexp]);
useEffect(() => {
groupByAffiliations(allPublications, regexp);
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [allPublications]);
+ }, [allPublications, regexp]);
const tagPublications = (publications, action) => {
const allPublicationsTmp = [...allPublications];
@@ -250,6 +254,7 @@ export default function Home() {
setAllAffiliations(allAffiliationsTmp);
setSelectedAffiliations([]);
};
+
const renderAffiliationsButtons = () => (
<>
);
+ const onDatasourcesChange = (datasource) => {
+ if (filteredDatasources.includes(datasource.key)) {
+ setFilteredDatasources(filteredDatasources.filter((filteredDatasource) => filteredDatasource !== datasource.key));
+ } else {
+ setFilteredDatasources(filteredDatasources.concat([datasource.key]));
+ }
+ };
+
return (
<>
@@ -394,18 +407,34 @@ export default function Home() {
/>
-
-
- {(isFetching || isLoading) && ()}
- {!isFetching && !isLoading && (
+ {(isFetching || isLoading) && ()}
+ {(!isFetching && !isLoading) && (
+
+
+
+ {DATASOURCES.map((datasource) => (
+ onDatasourcesChange(datasource)}
+ size="sm"
+ />
+ ))}
+
+
+
- )}
-
-
+
+
+ )}
{renderWorksButtons(selectedPublications)}
diff --git a/client/src/pages/home/views/works.jsx b/client/src/pages/home/views/works.jsx
index b51c38e6..1eacf182 100644
--- a/client/src/pages/home/views/works.jsx
+++ b/client/src/pages/home/views/works.jsx
@@ -6,7 +6,6 @@ import {
affiliationsTemplate,
allIdsTemplate,
authorsTemplate,
- sourcesFilterTemplate,
statusFilterTemplate,
statusTemplate,
typeFilterTemplate,
@@ -40,7 +39,7 @@ export default function WorksView({
-
+
diff --git a/client/src/utils/templates.jsx b/client/src/utils/templates.jsx
index 98759846..98dc36eb 100644
--- a/client/src/utils/templates.jsx
+++ b/client/src/utils/templates.jsx
@@ -34,7 +34,7 @@ const getAffiliationsHtmlField = (rowData, regexp) => {
.flat();
affiliations = [...new Set(affiliations)];
let html = '';
- html += affiliations.map((affiliation, index) => `- ${affiliation}
`);
+ html += affiliations.map((affiliation, index) => `- ${affiliation}
`).join('');
html += '
';
return html;
};
@@ -63,7 +63,7 @@ const getAllIdsHtmlField = (rowData) => {
const getAuthorsHtmlField = (rowData) => {
let html = ``;
- html += rowData.authors.slice(0, 3).map((author, index) => `- ${author.full_name}
`);
+ html += rowData.authors.slice(0, 3).map((author, index) => `- ${author.full_name}
`).join('');
if (rowData.authors.length > 3) {
html += `- et al. (${rowData.authors.length - 3})
`;
}
@@ -73,7 +73,7 @@ const getAuthorsHtmlField = (rowData) => {
const getAuthorsTooltipField = (rowData) => {
let html = '';
- html += rowData.authors.map((author, index) => `- ${author.full_name}
`);
+ html += rowData.authors.map((author, index) => `- ${author.full_name}
`).join('');
html += '
';
return html;
};
@@ -111,18 +111,6 @@ const statusFilterTemplate = (options) => (
/>
);
-const sourcesFilterTemplate = (options) => (
- options.filterApplyCallback(e.value)}
- options={['bso', 'openalex']}
- placeholder=""
- showClear
- style={{ width: '3rem' }}
- value={options.value}
- />
-);
-
const typeFilterTemplate = (options) => (