Skip to content

Commit

Permalink
ajout des prix au m2 pour les mutations concernant un seul bâtiment
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichelin committed Sep 3, 2020
1 parent d903940 commit 6d5d025
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions static/js/component.boite-accordeon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Vue.component('boite-accordeon', {
<boite
v-for="batiment in mutation.batiments"
:valeur="(batiment['code_type_local'] != 3) ? (formatterNombre(batiment['surface_reelle_bati']) + ' m²') : ''"
:prix_m2="prixMetreCarre"
:icone="['', 'fa fa-home', 'fas fa-building', 'fas fa-warehouse', 'fas fa-store'][batiment['code_type_local']]"
:texte="batiment['type_local'] + ((batiment['code_type_local'] < 3) ? (' / ' + formatterNombre(batiment['nombre_pieces_principales']) + ' p') : '')">
</boite>
Expand All @@ -41,6 +42,14 @@ Vue.component('boite-accordeon', {
selectionnerMutation() {
entrerDansMutation(this.index);
}
},
computed: {
prixMetreCarre() {
if (this.mutation.batiments.length !== 1) return '';
var prixM2 = this.mutation.batiments[0]['valeur_fonciere'] / this.mutation.batiments[0]['surface_reelle_bati'];
if (isNaN(prixM2)) return '';
return formatterNombre(prixM2.toString());
}
}
});

Expand Down
3 changes: 2 additions & 1 deletion static/js/component.boite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Vue.component('boite', {
// Les paramètres sont là
props: ['couleur', 'valeur', 'icone', 'texte'],
props: ['prix_m2', 'valeur', 'icone', 'texte'],
// La on donne le code source HTML du composant qui peut utiliser des données
template:
`<div class="media d-flex">
Expand All @@ -9,6 +9,7 @@ Vue.component('boite', {
</div>
<div class="media-body text-left ml-1">
<b>{{valeur}}</b><br>
<span v-if="prix_m2">{{prix_m2}} € / m²<br></span>
<span>{{texte}}</span>
</div>
</div>`
Expand Down

0 comments on commit 6d5d025

Please sign in to comment.