Skip to content

Commit 81b4705

Browse files
committed
feat(identityCard): improve subtaxa modal
Resolve #558.
1 parent 5eff19a commit 81b4705

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 = (
@@ -56,7 +61,7 @@ def searchEspece(connection, cd_ref):
5661
"protection": r.protection_stricte,
5762
}
5863

59-
sql = """
64+
query = """
6065
SELECT
6166
tax.lb_nom,
6267
tax.nom_vern,
@@ -66,16 +71,17 @@ def searchEspece(connection, cd_ref):
6671
tax.patrimonial,
6772
tax.protection_stricte,
6873
tax.nb_obs
69-
FROM atlas.vm_taxons tax
70-
JOIN atlas.bib_taxref_rangs br
71-
ON br.id_rang = tax.id_rang
74+
FROM atlas.vm_taxons AS tax
75+
JOIN atlas.bib_taxref_rangs AS br
76+
ON br.id_rang = tax.id_rang
7277
WHERE tax.cd_ref IN (
73-
SELECT * FROM atlas.find_all_taxons_childs(:thiscdref)
78+
SELECT * FROM atlas.find_all_taxons_childs(:cdRef)
7479
)
80+
ORDER BY tax.lb_nom ASC, tax.nb_obs DESC
7581
"""
76-
req = connection.execute(text(sql), thiscdref=cd_ref)
82+
results = connection.execute(text(query), cdRef=cd_ref)
7783
listTaxonsChild = list()
78-
for r in req:
84+
for r in results:
7985
temp = {
8086
"lb_nom": r.lb_nom,
8187
"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
@@ -330,7 +330,9 @@ function displayGridLayerArea(observations) {
330330
style: styleMaille,
331331
});
332332
currentLayer.addTo(map);
333-
map.fitBounds(currentLayer.getBounds());
333+
if (currentLayer.getBounds().isValid()) {
334+
map.fitBounds(currentLayer.getBounds());
335+
}
334336

335337
// ajout de la légende
336338
generateLegendMaille();

atlas/templates/speciesSheet/identityCard.html

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

108108
<!-- Modal -->
109109
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
110-
<div class="modal-dialog" role="document">
110+
<div class="modal-dialog modal-lg" role="document">
111111
<div class="modal-content">
112112
<div class="modal-header">
113+
<h3 class="modal-title" id="myModalLabel">
114+
Taxon(s) agrégé(s) sur cette fiche
115+
</h3>
113116
<button type="button" class="close" data-dismiss="modal"
114-
aria-label="Close"><span
115-
aria-hidden="true">&times;</span></button>
116-
<h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
117-
fiche</h3>
117+
aria-label="Close">
118+
<span aria-hidden="true">&times;</span>
119+
</button>
118120
</div>
119121
<div class="modal-body">
120122
<table class="table table-hover">
@@ -134,29 +136,31 @@ <h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
134136
</thead>
135137
<tbody>
136138
{% for child in taxon.listTaxonsChild %}
137-
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
138-
<tr>
139-
<td>
140-
{% if child.nom_vern != None %}
141-
{{ child.nom_vern }}
142-
{% else %}
143-
-
144-
</td>
145-
{% endif %}
146-
<td> {{ child.lb_nom }} </td>
139+
<tr>
140+
<td>
141+
{% if child.nom_vern != None %}
142+
{{ child.nom_vern }}
143+
{% else %}
144+
-
145+
{% endif %}
146+
</td>
147+
<td> {{ child.lb_nom }} </td>
148+
{% if configuration.PROTECTION %}
147149
<td>
148150
{% if child.protection != None %}
149151
<a href="https://inpn.mnhn.fr/espece/cd_nom/{{ taxon.taxonSearch.cd_ref }}/tab/statut"
150-
target="_blank">
152+
target="_blank">
151153
<img class="caractEspece" width="130px"
152-
src="{{ url_for('static', filename='images/logo_protection.png') }}"
153-
data-toggle="tooltip"
154-
data-original-title="{{ _('this.taxon.has.a.protected.status') }}"
155-
data-placement="right"></a>
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>
156158
{% endif %}
157159
</td>
160+
{% endif %}
161+
{% if config.DISPLAY_PATRIMONIALITE %}
158162
<td>
159-
{% if config.DISPLAY_PATRIMONIALITE and child.patrimonial in configuration.PATRIMONIALITE.config %}
163+
{% if child.patrimonial in configuration.PATRIMONIALITE.config %}
160164
<img
161165
class="caractEspece" width="130px"
162166
src="{{ url_for('static', filename=configuration.PATRIMONIALITE.config[child.patrimonial].icon) }}"
@@ -166,24 +170,22 @@ <h3 class="modal-title" id="myModalLabel">Taxon(s) agrégé(s) sur cette
166170
>
167171
{% endif %}
168172
</td>
169-
<td> {{ child.nb_obs | pretty }} </td>
170-
<td>
171-
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
172-
<span id="ficheGlyficon" data-toggle="tooltip"
173-
data-original-title="{{ _('check.species.sheet')}}"
174-
data-placement="right"
175-
class="fas fa-list"></span>
176-
</a>
177-
</td>
178-
179-
</tr>
180-
</a>
173+
{% endif %}
174+
<td> {{ child.nb_obs | pretty }} </td>
175+
<td>
176+
<a href="{{ url_for('main.ficheEspece', cd_nom=child.cd_ref) }}">
177+
<span id="ficheGlyficon" data-toggle="tooltip"
178+
data-original-title="{{ _('check.species.sheet')}}"
179+
data-placement="right"
180+
class="fas fa-list"></span>
181+
</a>
182+
</td>
183+
</tr>
181184
{% endfor %}
182185
</tbody>
183186
</table>
184187
</div>
185188
</div>
186-
187189
</div>
188190
</div>
189191

0 commit comments

Comments
 (0)