Commit 440d424c authored by Nicolas Joyard's avatar Nicolas Joyard

Ajout switch carte

parent c783043d
......@@ -6,7 +6,7 @@ from sqlalchemy.sql.expression import case, func
from ..models import Parlementaire, db
from ..models.constants import (ETAPES, ETAPES_BY_ORDRE, ETAPE_A_CONFIRMER,
ETAPE_A_ENVOYER, ETAPE_NA)
ETAPE_A_ENVOYER, ETAPE_ENVOYE, ETAPE_NA)
def setup_routes(app):
......@@ -43,8 +43,9 @@ def setup_routes(app):
# ...et qui sont dans une étape >= pris en charge
dept_qs = dept_qs.add_columns(
func.sum(case([(Parlementaire.etape >= ETAPE_A_CONFIRMER, 1)],
else_=0))
.label('nb_prisencharge')
else_=0)).label('nb_prisencharge'),
func.sum(case([(Parlementaire.etape >= ETAPE_ENVOYE, 1)],
else_=0)).label('nb_envoyes')
)
dept_qs = dept_qs.group_by(Parlementaire.num_deptmt) \
......
......@@ -157,20 +157,24 @@ th.col-nobreak {
margin-bottom: 1em;
}
#carte-legend-title {
#carte-legend-buttons {
flex-basis: 100%;
font-weight: bold;
margin-bottom: 1em;
}
#carte-legend-gradient {
border: 1px solid #aaa;
height: .7em;
flex-basis: 100%;
}
.carte-mode-prisencharge #carte-legend-gradient {
background: linear-gradient(to right, #fff, #4444bb);
}
#carte-legend small {
.carte-mode-envoye #carte-legend-gradient {
background: linear-gradient(to right, #fff, #8844bb);
}
#carte .land {
......
......@@ -85,9 +85,12 @@
<header class="panel-heading">
<b>Avancement par département</b>
</header>
<article class="panel-body" id="carte-container">
<article class="panel-body carte-mode-prisencharge" id="carte-container">
<div id="carte-legend">
<div id="carte-legend-title"><small>Taux de prise en charge des envois aux parlementaires</small></div>
<div id="carte-legend-buttons">
<button id="btn-mode-prisencharge" class="btn btn-xs btn-primary">Pris en charge</button>
<button id="btn-mode-envoye" class="btn btn-xs btn-default">Courriers envoyés</button>
</div>
<div id="carte-legend-gradient">
</div>
<small>Aucun</small>
......@@ -138,6 +141,20 @@
/* Carte */
var modesCarte = ['prisencharge', 'envoye'];
modesCarte.forEach(function(mode) {
$('#btn-mode-' + mode).click(function(e) {
$('#carte-container .btn').removeClass('btn-primary').addClass('btn-default');
$(this).removeClass('btn-default').addClass('btn-primary');
var ctn = $('#carte-container');
modesCarte.forEach(function(m) { ctn.removeClass('carte-mode-' + m); });
ctn.addClass('carte-mode-' + mode);
e.preventDefault();
});
});
{% for dep in departements %}
$('.departement{{ dep.num_deptmt }}')
.attr('data-content',
......
......@@ -5,10 +5,14 @@
.idfbig { opacity:1; }
{% for dep in departements %}
#carte .departement{{ dep.num_deptmt }} {
.carte-mode-prisencharge #carte .departement{{ dep.num_deptmt }} {
fill: #4444bb;
fill-opacity: {{ dep.nb_prisencharge / dep.total }};
}
.carte-mode-envoye #carte .departement{{ dep.num_deptmt }} {
fill: #8844bb;
fill-opacity: {{ dep.nb_envoyes / dep.total }};
}
{% endfor %}
</style>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment