From dac3bfd38ae7a7ef4edc23cc32a9c21daffde049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Maniaci?= Date: Wed, 19 Feb 2025 15:12:49 +0100 Subject: [PATCH] startups: allow filtering out investigations Closes #21046. --- _includes/startups-filters.html | 7 +++++++ _layouts/startups.html | 5 +++++ assets/additional/js/search-startup.js | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/_includes/startups-filters.html b/_includes/startups-filters.html index fe718d0b039b..ea3da57d96b5 100644 --- a/_includes/startups-filters.html +++ b/_includes/startups-filters.html @@ -37,4 +37,11 @@

Ces services sont déployés à l'ensemble du territoire national et ont atteint un seuil d'impact significatif.

+
+
+ + +

Les investigations sont des services numériques en devenir. À ce stade, l'équipe est souvent réduite.

+
+
diff --git a/_layouts/startups.html b/_layouts/startups.html index bdeb64749da3..da4dc5f9339d 100644 --- a/_layouts/startups.html +++ b/_layouts/startups.html @@ -192,4 +192,9 @@

{{ counter }} { document.querySelectorAll(".select-impact").forEach((selectElement) => { createNationalImpactSelect(selectElement, data, nationalImpactValue); }); + + filters.excludeInvestigations = urlParams.get("exclude-investigations") == "true"; + + setupExcludeInvestigations(); + diff --git a/assets/additional/js/search-startup.js b/assets/additional/js/search-startup.js index 1a972e4e8968..42679dacb80b 100644 --- a/assets/additional/js/search-startup.js +++ b/assets/additional/js/search-startup.js @@ -116,9 +116,15 @@ const filterCards = (startups) => { ) .filter((startup) => filters.is_national_impact ? startupHasNationalImpact(startup) : true, + ) + .filter((startup) => + filters.excludeInvestigations ? startupIsNotInvestigation(startup) : true, ); }; +const startupIsNotInvestigation = (startup) => + startup.phase !== "investigation"; + const startupHasNationalImpact = (startup) => startup.events.find((event) => event.name === "national_impact"); @@ -339,3 +345,18 @@ const createNationalImpactSelect = (selectElement, data, initValue) => { ); }); }; + +const setupExcludeInvestigations = () => { + toggle = document.getElementById("exclude-investigations-toggle"); + + toggle.checked = filters.excludeInvestigations; + + toggle.addEventListener("change", () => { + url = new URL(window.location); + url.searchParams.set("exclude-investigations", toggle.checked); + + window.location = url; + }); + + updateCards(data); +};