Skip to content

Commit

Permalink
startups: allow filtering out investigations
Browse files Browse the repository at this point in the history
Closes #21046.
  • Loading branch information
freesteph committed Feb 19, 2025
1 parent 9df9126 commit dac3bfd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _includes/startups-filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,11 @@
<p class="fr-hint-text" id="{{include.prefix}}toggle-hint-text">Ces services sont déployés à l'ensemble du territoire national et ont atteint un seuil d'impact significatif.</p>
</div>
</div>
<div class="fr-grid-row">
<div class="fr-col fr-toggle">
<input type="checkbox" class="fr-toggle__input exclude-investigations" aria-describedby="exclude-investigations-toggle-hint-text" id="exclude-investigations-toggle" />
<label class="fr-toggle__label" for="exclude-investigations-toggle" data-fr-checked-label="Activé" data-fr-unchecked-label="Désactivé">Exclure les investigations</label>
<p class="fr-hint-text" id="exclude-investigations-toggle-hint-text">Les investigations sont des services numériques en devenir. À ce stade, l'équipe est souvent réduite.</p>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions _layouts/startups.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,9 @@ <h3><span class="phase-counter">{{ counter }}</span> <span class="phase-label">{
document.querySelectorAll(".select-impact").forEach((selectElement) => {
createNationalImpactSelect(selectElement, data, nationalImpactValue);
});

filters.excludeInvestigations = urlParams.get("exclude-investigations") == "true";

setupExcludeInvestigations();

</script>
21 changes: 21 additions & 0 deletions assets/additional/js/search-startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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);
};

0 comments on commit dac3bfd

Please sign in to comment.