Skip to content

Commit 43f8fca

Browse files
committed
feat(identityCard): improve subtaxa modal
Resolve #558.
1 parent 3978263 commit 43f8fca

File tree

4 files changed

+68
-63
lines changed

4 files changed

+68
-63
lines changed

atlas/modeles/repositories/vmTaxrefRepository.py

+29-23
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,34 @@ def searchEspece(connection, cd_ref):
1111
"""
1212
recherche l espece corespondant au cd_nom et tout ces fils
1313
"""
14-
sql = """
14+
query = """
1515
WITH limit_obs AS (
1616
SELECT
17-
:thiscdref AS cd_ref, min(yearmin) AS yearmin,
18-
max(yearmax) AS yearmax, SUM(nb_obs) AS nb_obs
17+
:cdRef AS cd_ref,
18+
MIN(yearmin) AS yearmin,
19+
MAX(yearmax) AS yearmax,
20+
SUM(nb_obs) AS nb_obs
1921
FROM atlas.vm_taxons
20-
WHERE
21-
cd_ref IN (SELECT * FROM atlas.find_all_taxons_childs(:thiscdref))
22-
OR cd_ref = :thiscdref
22+
WHERE cd_ref IN (SELECT * FROM atlas.find_all_taxons_childs(:cdRef))
23+
OR cd_ref = :cdRef
2324
)
2425
SELECT taxref.*,
25-
l.cd_ref, l.yearmin, l.yearmax, COALESCE(l.nb_obs, 0) AS nb_obs,
26-
t2.patrimonial, t2.protection_stricte
27-
FROM atlas.vm_taxref taxref
28-
JOIN limit_obs l
29-
ON l.cd_ref = taxref.cd_nom
30-
LEFT JOIN atlas.vm_taxons t2
31-
ON t2.cd_ref = taxref.cd_ref
32-
WHERE taxref.cd_nom = :thiscdref
26+
l.cd_ref,
27+
l.yearmin,
28+
l.yearmax,
29+
COALESCE(l.nb_obs, 0) AS nb_obs,
30+
t2.patrimonial,
31+
t2.protection_stricte
32+
FROM atlas.vm_taxref AS taxref
33+
JOIN limit_obs AS l
34+
ON l.cd_ref = taxref.cd_nom
35+
LEFT JOIN atlas.vm_taxons AS t2
36+
ON t2.cd_ref = taxref.cd_ref
37+
WHERE taxref.cd_nom = :cdRef
3338
"""
34-
req = connection.execute(text(sql), thiscdref=cd_ref)
39+
results = connection.execute(text(query), cdRef=cd_ref)
3540
taxonSearch = dict()
36-
for r in req:
41+
for r in results:
3742
nom_vern = None
3843
if r.nom_vern:
3944
nom_vern = (
@@ -54,7 +59,7 @@ def searchEspece(connection, cd_ref):
5459
"protection": r.protection_stricte,
5560
}
5661

57-
sql = """
62+
query = """
5863
SELECT
5964
tax.lb_nom,
6065
tax.nom_vern,
@@ -64,16 +69,17 @@ def searchEspece(connection, cd_ref):
6469
tax.patrimonial,
6570
tax.protection_stricte,
6671
tax.nb_obs
67-
FROM atlas.vm_taxons tax
68-
JOIN atlas.bib_taxref_rangs br
69-
ON br.id_rang = tax.id_rang
72+
FROM atlas.vm_taxons AS tax
73+
JOIN atlas.bib_taxref_rangs AS br
74+
ON br.id_rang = tax.id_rang
7075
WHERE tax.cd_ref IN (
71-
SELECT * FROM atlas.find_all_taxons_childs(:thiscdref)
76+
SELECT * FROM atlas.find_all_taxons_childs(:cdRef)
7277
)
78+
ORDER BY tax.lb_nom ASC, tax.nb_obs DESC
7379
"""
74-
req = connection.execute(text(sql), thiscdref=cd_ref)
80+
results = connection.execute(text(query), cdRef=cd_ref)
7581
listTaxonsChild = list()
76-
for r in req:
82+
for r in results:
7783
temp = {
7884
"lb_nom": r.lb_nom,
7985
"nom_vern": r.nom_vern,

atlas/static/mapAreas.js

-5
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ function displayObsTaxonMaille(areaCode, cd_ref) {
148148
dataType: "json",
149149
beforeSend: function () {
150150
$("#loaderSpinner").show();
151-
// $("#loadingGif").show();
152-
// $("#loadingGif").attr(
153-
// "src",
154-
// configuration.URL_APPLICATION + "/static/images/loading.svg"
155-
// );
156151
}
157152
}).done(function (observations) {
158153
$("#loaderSpinner").hide();

atlas/static/mapGenerator.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ function displayGridLayerArea(observations) {
340340
style: styleMaille,
341341
});
342342
currentLayer.addTo(map);
343-
map.fitBounds(currentLayer.getBounds());
343+
if (currentLayer.getBounds().isValid()) {
344+
map.fitBounds(currentLayer.getBounds());
345+
}
344346

345347
// ajout de la légende
346348
generateLegendMaille();

atlas/templates/speciesSheet/identityCard.html

+36-34
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,16 @@ <h4 class="strong"><i>{{ taxon.taxonSearch.nom_complet_html|safe }} </i></h4>
109109

110110
<!-- Modal -->
111111
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
112-
<div class="modal-dialog" role="document">
112+
<div class="modal-dialog modal-lg" role="document">
113113
<div class="modal-content">
114114
<div class="modal-header">
115+
<h3 class="modal-title" id="myModalLabel">
116+
Taxon(s) agrégé(s) sur cette fiche
117+
</h3>
115118
<button type="button" class="close" data-dismiss="modal"
116-
aria-label="Close"><span
117-
aria-hidden="true">&times;</span></button>
118-
<h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
119-
fiche</h3>
119+
aria-label="Close">
120+
<span aria-hidden="true">&times;</span>
121+
</button>
120122
</div>
121123
<div class="modal-body">
122124
<table class="table table-hover">
@@ -136,29 +138,31 @@ <h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
136138
</thead>
137139
<tbody>
138140
{% for child in taxon.listTaxonsChild %}
139-
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
140-
<tr>
141-
<td>
142-
{% if child.nom_vern != None %}
143-
{{ child.nom_vern }}
144-
{% else %}
145-
-
146-
</td>
147-
{% endif %}
148-
<td><i>{{ child.lb_nom }}</i></td>
141+
<tr>
142+
<td>
143+
{% if child.nom_vern != None %}
144+
{{ child.nom_vern }}
145+
{% else %}
146+
-
147+
{% endif %}
148+
</td>
149+
<td> {{ child.lb_nom }} </td>
150+
{% if configuration.PROTECTION %}
149151
<td>
150152
{% if child.protection != None %}
151153
<a href="https://inpn.mnhn.fr/espece/cd_nom/{{ taxon.taxonSearch.cd_ref }}/tab/statut"
152-
target="_blank">
154+
target="_blank">
153155
<img class="caractEspece" width="130px"
154-
src="{{ url_for('static', filename='images/logo_protection.png') }}"
155-
data-toggle="tooltip"
156-
data-original-title="{{ _('this.taxon.has.a.protected.status') }}"
157-
data-placement="right"></a>
156+
src="{{ url_for('static', filename='images/logo_protection.png') }}"
157+
data-toggle="tooltip"
158+
data-original-title="{{ _('this.taxon.has.a.protected.status') }}"
159+
data-placement="right"></a>
158160
{% endif %}
159161
</td>
162+
{% endif %}
163+
{% if config.DISPLAY_PATRIMONIALITE %}
160164
<td>
161-
{% if config.DISPLAY_PATRIMONIALITE and child.patrimonial in configuration.PATRIMONIALITE.config %}
165+
{% if child.patrimonial in configuration.PATRIMONIALITE.config %}
162166
<img
163167
class="caractEspece" width="130px"
164168
src="{{ url_for('static', filename=configuration.PATRIMONIALITE.config[child.patrimonial].icon) }}"
@@ -168,24 +172,22 @@ <h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
168172
>
169173
{% endif %}
170174
</td>
171-
<td> {{ child.nb_obs | pretty }} </td>
172-
<td>
173-
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
174-
<span id="ficheGlyficon" data-toggle="tooltip"
175-
data-original-title="{{ _('check.species.sheet')}}"
176-
data-placement="right"
177-
class="fas fa-list"></span>
178-
</a>
179-
</td>
180-
181-
</tr>
182-
</a>
175+
{% endif %}
176+
<td> {{ child.nb_obs | pretty }} </td>
177+
<td>
178+
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
179+
<span id="ficheGlyficon" data-toggle="tooltip"
180+
data-original-title="{{ _('check.species.sheet')}}"
181+
data-placement="right"
182+
class="fas fa-list"></span>
183+
</a>
184+
</td>
185+
</tr>
183186
{% endfor %}
184187
</tbody>
185188
</table>
186189
</div>
187190
</div>
188-
189191
</div>
190192
</div>
191193

0 commit comments

Comments
 (0)