Skip to content

Feat/ajout filtres indicateurs listes esp #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion atlas/configuration/config_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Utils pour lire le fichier de conf et le valider selon le schéma Marshmallow
Utils pour lire le fichier de conf et le valider selon le schéma Marshmallow
"""

from importlib.machinery import SourceFileLoader
Expand Down
20 changes: 16 additions & 4 deletions atlas/messages.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Translations template for PROJECT.
# Copyright (C) 2024 ORGANIZATION
# Copyright (C) 2025 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2025-02-06 22:17+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -196,10 +196,22 @@ msgstr ""
msgid "search.other.zones.type"
msgstr ""

#: templates/core/listTaxons.html:14
#: templates/core/listTaxons.html:15
msgid "filter.species"
msgstr ""

#: templates/core/listTaxons.html:24
msgid "autres.filtres"
msgstr ""

#: templates/core/listTaxons.html:33
msgid "espèces.protégées.uniquement"
msgstr ""

#: templates/core/listTaxons.html:39
msgid "espèces.patrimoniales.uniquement"
msgstr ""

#: templates/core/listTaxons.html:23
msgid "display.municipality.obs"
msgstr ""
Expand Down
62 changes: 62 additions & 0 deletions atlas/static/css/listEspeces.css
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,66 @@ tbody tr.current {
font-size: 0.8rem;
color: deeppink;
}
}

/* styles pour filtres sur liste taxons */

/* mobile-first styles : display flex en column avec collapsed section Autres filtres */

#filtresListeEspècesContainer {
container-type: inline-size;
}

#filtresListeEspèces {
margin: 0.5rem;
}

#filtresListeEspèces form {
display: flex;
flex-direction: column;
gap: 0.5rem 1.5rem;
align-items: start;
justify-content: center;
flex-wrap: wrap;
}

#filtresListeEspècesContainer button {
padding-top: 0;
padding-bottom: 0;
font-size: 0.8rem;
background-color: var(--main-color);
}

#filtresListeEspèces #autresFiltresListeEspèces > div {
display: flex;
flex-direction: column;
gap: 0.5rem 1.5rem;
align-items: start;
justify-content: center;
flex-wrap: wrap;
}

#filtresListeEspèces label {
margin-bottom: unset;
}

@container (min-width: 800px) {
/* Styles pour affichage large : row-flex et on cache le bouton "Autres filtres" */
#filtresListeEspèces form {
flex-direction: row;
align-items: center;
}

#filtresListeEspèces #autresFiltresListeEspèces > div {
flex-direction: row;
align-items: center;
}

#filtresListeEspècesContainer button {
display: none;
}

#autresFiltresListeEspèces.collapse {
display: block;
}
}
42 changes: 30 additions & 12 deletions atlas/static/listeEspeces.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
$(".lazy").lazy({
effect: "fadeIn",
effectTime: 2000,
threshold: 0,
appendScroll: $("#taxonList")
});
effect: "fadeIn",
effectTime: 2000,
threshold: 0,
appendScroll: $("#taxonList")
});
$('[data-toggle="tooltip"]').tooltip();


$(document).ready(function(){
$("#taxonInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#taxonList li").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});

var taxonDomElems = Array.from(document.querySelectorAll("#taxonList li"))

function filterListeEspèces() {
let name = document.querySelector("#taxonInput").value.toLowerCase();
let onlyProtégées = document.querySelector("#filtreProtégées").checked;
let onlyPatrimoniales = document.querySelector("#filtrePatrimoniales").checked;

const filteredTaxonDomElems = taxonDomElems.filter(elem => {
let matched = elem.innerText.toLowerCase().indexOf(name) > -1
&& (!onlyProtégées || "data-protégée" in elem.attributes)
&& (!onlyPatrimoniales || "data-patrimoniale" in elem.attributes);
if (matched) {
return true;
}
})
document.querySelectorAll("#taxonList li").forEach(e => e.remove());
document.querySelector("#taxonList ul").append(...filteredTaxonDomElems)
}
document.querySelectorAll("#filtresListeEspèces input").forEach(
(element) => element.addEventListener("input", filterListeEspèces)
)
});
59 changes: 51 additions & 8 deletions atlas/templates/core/listTaxons.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,62 @@

</style>
{% endif %}
<div class="bg-white border-right p-2">

<div class="col">
<input id="taxonInput" type="text" class="form-control form-control-sm" placeholder="{{ _('filter.species') }}" />
<div id="filtresListeEspècesContainer" class="bg-white border-right p-2 border-bottom">
<div id="filtresListeEspèces">
<form>
<div>
<input id="taxonInput" type="text" placeholder="{{ _('filter.species') }}" />
{% if config.PROTECTION or config.DISPLAY_PATRIMONIALITE %}
<button
class="btn btn-primary dropdown-toggle"
type="button"
data-toggle="collapse"
data-target="#autresFiltresListeEspèces"
aria-expanded="false"
aria-controls="filtresListeEspèces">
{{ _('autres.filtres') }}
</button>
{% endif %}
</div>
<div id="autresFiltresListeEspèces" class="collapse">
<div>
{% if config.PROTECTION %}
<div class="custom-control custom-switch">
<input id="filtreProtégées" name="filtreProtégées" type="checkbox" class="custom-control-input" />
<label for="filtreProtégées" class="custom-control-label">{{ _('espèces.protégées.uniquement') }}</label>
</div>
{% endif %}
{% if config.DISPLAY_PATRIMONIALITE %}
<div class="custom-control custom-switch">
<input id="filtrePatrimoniales" name="filtrePatrimoniales" type="checkbox" class="custom-control-input" />
<label for="filtrePatrimoniales" class="custom-control-label">{{ _("espèces.%(label_patrimonialite)s.uniquement", label_patrimonialite=config.PATRIMONIALITE.label_pluriel)|lower|capitalize }}</label>
</div>
{% endif %}
</div>
</div>
</form>
</div>

</div>
<div id="taxonList" class="d-flex align-content-stretch bg-white flex-grow-1">
<ul class="list-group w-100">
{% for taxon in listTaxons.taxons %}
<li id="taxonListItem" class="media border-bottom p-2" area-code="{{ insee }}"
cdRef="{{ taxon.cd_ref }}" {% if configuration.INTERACTIVE_MAP_LIST %}data-toggle="tooltip"
data-original-title="{{ _('display.municipality.obs') }}"{% endif %}>
<li
id="taxonListItem"
class="media border-bottom p-2"
area-code="{{ insee }}"
cdRef="{{ taxon.cd_ref }}"
{% if configuration.INTERACTIVE_MAP_LIST %}
data-toggle="tooltip"
data-original-title="{{ _('display.municipality.obs') }}"
{% endif %}
{% if configuration.PROTECTION and taxon.protection_stricte == 'oui' %}
data-protégée
{% endif %}
{% if
configuration.DISPLAY_PATRIMONIALITE
and taxon.patrimonial in configuration.PATRIMONIALITE.config %}
data-patrimoniale
{% endif %}>
<span class="d-none">{{ taxon.group2_inpn }}</span>
<div class="pictoImgList mr-2" data-toggle="tooltip" data-original-title="{{ taxon.group2_inpn }}"
data-placement="right">
Expand Down
Binary file modified atlas/translations/en/LC_MESSAGES/messages.mo
Binary file not shown.
14 changes: 13 additions & 1 deletion atlas/translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2025-02-06 22:17+0100\n"
"PO-Revision-Date: 2021-07-12 12:12+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down Expand Up @@ -210,6 +210,18 @@ msgstr "Search other area type"
msgid "filter.species"
msgstr "Filter species"

#: templates/core/listTaxons.html:24
msgid "autres.filtres"
msgstr "Other filters"

#: templates/core/listTaxons.html:33
msgid "espèces.protégées.uniquement"
msgstr "Protected species only"

#: templates/core/listTaxons.html:39
msgid "espèces.%(label_patrimonialite)s.uniquement"
msgstr "%(label_patrimonialite)s species only"

#: templates/core/listTaxons.html:23
msgid "display.municipality.obs"
msgstr "View observations on the territory"
Expand Down
Binary file modified atlas/translations/fr/LC_MESSAGES/messages.mo
Binary file not shown.
14 changes: 13 additions & 1 deletion atlas/translations/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2025-02-06 22:17+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
Expand Down Expand Up @@ -212,6 +212,18 @@ msgstr "Recherche par autre type de zones"
msgid "filter.species"
msgstr "Filtrer les espèces"

#: templates/core/listTaxons.html:24
msgid "autres.filtres"
msgstr "Autres filtres"

#: templates/core/listTaxons.html:33
msgid "espèces.protégées.uniquement"
msgstr "Espèces protégées uniquement"

#: templates/core/listTaxons.html:39
msgid "espèces.%(label_patrimonialite)s.uniquement"
msgstr "Espèces %(label_patrimonialite)s uniquement"

#: templates/core/listTaxons.html:23
msgid "display.municipality.obs"
msgstr "Voir les observations sur le territoire"
Expand Down
Binary file modified atlas/translations/it/LC_MESSAGES/messages.mo
Binary file not shown.
14 changes: 13 additions & 1 deletion atlas/translations/it/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2025-02-06 22:17+0100\n"
"PO-Revision-Date: 2021-07-19 09:53+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: it\n"
Expand Down Expand Up @@ -211,6 +211,18 @@ msgstr "Cerca per altro tipo di zone"
msgid "filter.species"
msgstr "Filtrare le species"

#: templates/core/listTaxons.html:24
msgid "autres.filtres"
msgstr "Altri filtri"

#: templates/core/listTaxons.html:33
msgid "espèces.protégées.uniquement"
msgstr "Solo specie protette"

#: templates/core/listTaxons.html:39
msgid "espèces.%(label_patrimonialite)s.uniquement"
msgstr "Solo specie %(label_patrimonialite)s"

#: templates/core/listTaxons.html:23
msgid "display.municipality.obs"
msgstr "Guarda le osservazioni sul territorio"
Expand Down