Skip to content

Commit

Permalink
feat(filter): add publication tags filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Nov 29, 2024
1 parent 9e81c26 commit 3f1e0b6
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 4 deletions.
1 change: 0 additions & 1 deletion client/src/pages/networks/components/graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default function NetworkGraph() {
if (!vosviewer?.network) return <Error204 />

const key = JSON.stringify({ currentTab, currentQuery, filters, ...parameters, lang, theme, focusItem })
console.log("key", key)

const vosparams = {
largest_component: false,
Expand Down
5 changes: 4 additions & 1 deletion client/src/pages/networks/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"networks.filters.current.publications.type": "Publikationstyp",
"networks.filters.current.publications.year": "Veröffentlichungsjahre",
"networks.filters.current.publications.projects.type": "Finanzierungstyp",
"networks.filters.current.publications.tags.id": "Tags",
"networks.filters.display": "Ergebnisse anzeigen",
"networks.filters.title": "Filter",
"networks.filters.active-filter-title": "Aktive Filter",
Expand All @@ -56,7 +57,9 @@
"search.filters.publications.by-organization": "Nach Zugehörigkeit filtern",
"search.filters.publications.by-organization-description": "Wählen Sie eine oder mehrere Zugehörigkeiten aus",
"search.filters.publications.by-country": "Nach Land filtern",
"search.filters.publications.by-country-description": "Wählen Sie ein oder mehrere Länder aus",
"search.filters.publications.by-country-description": "Wählen Sie eine oder mehrere Länder aus",
"search.filters.publications.by-tag": "Nach Tag filtern",
"search.filters.publications.by-tag-description": "Wählen Sie einen oder mehrere Tags aus",
"search.top.publications.filters.result-count": "{count, plural, =0 {# Veröffentlichung} one {# Veröffentlichung} other {# Veröffentlichungen}}",
"search.top.filters.display": "Ergebnisse anzeigen",
"search.top.result-more-than": "Mehr als ",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/networks/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"networks.filters.current.publications.type": "Publication Type",
"networks.filters.current.publications.year": "Publication Years",
"networks.filters.current.publications.projects.type": "Funding Type",
"networks.filters.current.publications.tags.id": "Tags",
"networks.filters.display": "Display Results",
"networks.filters.title": "Filters",
"networks.filters.active-filter-title": "Active Filters",
Expand All @@ -79,6 +80,8 @@
"search.filters.publications.by-organization-description": "Select one or more affiliations",
"search.filters.publications.by-country": "Filter by Country",
"search.filters.publications.by-country-description": "Select one or more countries",
"search.filters.publications.by-tag": "Filter by Tag",
"search.filters.publications.by-tag-description": "Select one or more tag",
"search.top.publications.filters.result-count": "{count, plural, =0 {# publication} one {# publication} other {# publications}}",
"search.top.filters.display": "Display Results",
"search.top.result-more-than": "More than ",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/networks/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"networks.filters.current.publications.type": "Tipo de Publicación",
"networks.filters.current.publications.year": "Años de Publicación",
"networks.filters.current.publications.projects.type": "Tipo de Financiamiento",
"networks.filters.current.publications.tags.id": "Etiquetas",
"networks.filters.display": "Mostrar Resultados",
"networks.filters.title": "Filtros",
"networks.filters.active-filter-title": "Filtros Activos",
Expand All @@ -57,6 +58,8 @@
"search.filters.publications.by-organization-description": "Seleccione una o más afiliaciones",
"search.filters.publications.by-country": "Filtrar por país",
"search.filters.publications.by-country-description": "Seleccione una o más países",
"search.filters.publications.by-tag": "Filtrar por etiqueta",
"search.filters.publications.by-tag-description": "Seleccione una o más etiquetas",
"search.top.publications.filters.result-count": "{count, plural, =0 {# publicación} one {# publicación} other {# publicaciones}}",
"search.top.filters.display": "Mostrar Resultados",
"search.top.result-more-than": "Más de ",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/networks/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"networks.filters.current.publications.type": "Type de publication",
"networks.filters.current.publications.year": "Années de publication",
"networks.filters.current.publications.projects.type": "Type de financement",
"networks.filters.current.publications.tags.id": "Tags",
"networks.filters.display": "Afficher les résultats",
"networks.filters.title": "Filtres",
"networks.filters.active-filter-title": "Filtres actifs",
Expand All @@ -79,6 +80,8 @@
"search.filters.publications.by-organization-description": "Sélectionnez une ou plusieurs affiliations",
"search.filters.publications.by-country": "Filtrer par pays",
"search.filters.publications.by-country-description": "Sélectionnez un ou plusieurs pays",
"search.filters.publications.by-tag": "Filter par tag",
"search.filters.publications.by-tag-description": "Sélectionnez un ou plusieurs tag",
"search.top.publications.filters.result-count": "{count, plural, =0 {# publication} one {# publication} other {# publications}}",
"search.top.filters.display": "Afficher les résultats",
"search.top.result-more-than": "Plus de ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import PublicationFunderFilter from "./funders";
import PublicationTypeFilter from "./types";
import PublicationYearFilter from "./years";
import PublicationCountriesFilter from "./countries"

import PublicationTagsFilter from "./tags"

export default function PublicationFilters() {
const intl = useIntl()
const { total, search: { isFetching } } = useSearchData();
const {
total,
search: { isFetching },
} = useSearchData()
const { api } = useUrl()
const id = `${api}-filters`

Expand All @@ -37,6 +40,8 @@ export default function PublicationFilters() {
<hr className="fr-mt-3w" />
<PublicationFunderFilter />
<hr className="fr-mt-3w" />
<PublicationTagsFilter />
<hr className="fr-mt-3w" />
</Container>
<div className="fr-modal__footer fr-px-0" style={{ display: "flex", width: "100%", alignItems: "center" }}>
<div style={{ flexGrow: 1 }}>
Expand Down
26 changes: 26 additions & 0 deletions client/src/pages/search/components/publications/filters/tags.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TagInput, Text } from "@dataesr/dsfr-plus"
import { FormattedMessage } from "react-intl"
import useUrl from "../../../hooks/useUrl"

export default function PublicationTagsFilter() {
const { currentFilters, handleFilterChange } = useUrl()

const key = JSON.stringify(currentFilters?.["tags.id"]?.values?.map((tag) => String(tag.value)) || {})

return (
<>
<Text className="fr-mb-1v" bold size="md">
<FormattedMessage id="search.filters.publications.by-tag" />
</Text>
<Text className="fr-card__detail fr-mb-2w" size="sm">
<FormattedMessage id="search.filters.publications.by-tag-description" />
</Text>
<TagInput
key={key}
label=""
tags={currentFilters?.["tags.id"]?.values?.map((tag) => String(tag.value))}
onTagsChange={(tags) => tags.forEach((tag) => handleFilterChange({ field: "tags.id", value: tag }))}
/>
</>
)
}
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"search.filters.publications.by-organization-description": "Eine oder mehrere Zugehörigkeiten auswählen",
"search.filters.publications.by-country": "Nach Land filtern",
"search.filters.publications.by-country-description": "Wählen Sie ein oder mehrere Länder aus",
"search.filters.publications.by-tag": "Nach Tag filtern",
"search.filters.publications.by-tag-description": "Wählen Sie einen oder mehrere Tags aus",
"search.filters.organizations.by-project": "Nach Finanzierungstyp filtern",
"search.filters.organizations.by-project-description": "Einen oder mehrere Finanzierungstypen auswählen",
"search.filters.organizations.by-kind": "Nach Sektor filtern",
Expand Down Expand Up @@ -133,6 +135,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Standort eines Teilnehmers",
"search.filters.current.projects.participants.structure.id": "Teilnehmer",
"search.filters.current.publications.isOa": "Zugriffstyp",
"search.filters.current.publications.tags.id": "Tags",
"search.filters.current.patents.isInternational": "Ausgewählte Region",
"search.filters.current.patents.isOeb": "Ausgewählte Region",
"search.filters.current.patents.isGranted": "Ausgestellte Patente",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"search.filters.publications.by-organization-description": "Select one or more affiliations",
"search.filters.publications.by-country": "Filter by Country",
"search.filters.publications.by-country-description": "Select one or more countries",
"search.filters.publications.by-tag": "Filter by Tag",
"search.filters.publications.by-tag-description": "Select one or more tag",
"search.filters.organizations.by-project": "Filter by funding Type",
"search.filters.organizations.by-project-description": "Select one or more funding types",
"search.filters.organizations.by-kind": "Filter by sector",
Expand Down Expand Up @@ -130,6 +132,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Location of a participant",
"search.filters.current.projects.participants.structure.id": "Participants",
"search.filters.current.publications.isOa": "Access type",
"search.filters.current.publications.tags.id": "Tags",
"search.filters.current.patents.isInternational": "Selected region",
"search.filters.current.patents.isOeb": "Selected region",
"search.filters.current.patents.isGranted": "Granted patents",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"search.filters.publications.by-organization-description": "Selecciona una o más afiliaciones",
"search.filters.publications.by-country": "Filtrar por país",
"search.filters.publications.by-country-description": "Seleccione uno o más países",
"search.filters.publications.by-tag": "Filtrar por etiqueta",
"search.filters.publications.by-tag-description": "Seleccione una o más etiquetas",
"search.filters.organizations.by-project": "Filtrar por Tipo de Financiamiento",
"search.filters.organizations.by-project-description": "Selecciona uno o más tipos de financiamiento",
"search.filters.organizations.by-kind": "Filtrar por Sector",
Expand Down Expand Up @@ -133,6 +135,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Ubicación de un Participante",
"search.filters.current.projects.participants.structure.id": "Participantes",
"search.filters.current.publications.isOa": "Tipo de Acceso",
"search.filters.current.publications.tags.id": "Etiquetas",
"search.filters.current.patents.isInternational": "Región Seleccionada",
"search.filters.current.patents.isOeb": "Región Seleccionada",
"search.filters.current.patents.isGranted": "Patentes Concedidas",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"search.filters.publications.by-organization-description": "Sélectionnez une ou plusieurs affiliations",
"search.filters.publications.by-country": "Filtrer par pays",
"search.filters.publications.by-country-description": "Sélectionnez un ou plusieurs pays",
"search.filters.publications.by-tag": "Filter par tag",
"search.filters.publications.by-tag-description": "Sélectionnez un ou plusieurs tag",
"search.filters.organizations.by-project": "Filtrer par type de financement",
"search.filters.organizations.by-project-description": "Sélectionnez un ou plusieurs types de financement",
"search.filters.organizations.by-kind": "Filtrer par secteur",
Expand Down Expand Up @@ -134,6 +136,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Localisation d'un participant",
"search.filters.current.projects.participants.structure.id": "Participants",
"search.filters.current.publications.isOa": "Type d'accès",
"search.filters.current.publications.tags.id": "Tags",
"search.filters.current.patents.isInternational": "Région selectionnée",
"search.filters.current.patents.isOeb": "Région selectionnée",
"search.filters.current.patents.isGranted": "Les brevets délivrés",
Expand Down

0 comments on commit 3f1e0b6

Please sign in to comment.