Commit 8c24ca28 authored by Matt Glorion's avatar Matt Glorion

[ADD] impact equivalents feature (front)

parent d3c02d60
......@@ -79,6 +79,11 @@ export default {
main {
height: 100%;
}
#app {
height: 93vh;
}
.results {
flex-basis: 25%;
/* background-color: #BCBCBC; */
......
......@@ -16,6 +16,10 @@
<p>
{{ detailled_results_text }}
</p>
<br/>
<p v-for="eq of equivalents" :key="eq.message">
{{ eq.text }}
</p>
</div>
</div>
</template>
......@@ -63,6 +67,22 @@ export default {
detailled_results_text: function () {
return detailled_results_text[this.selectedView];
},
equivalents: function () {
if(store.state.equivalents.hasOwnProperty(this.selectedView)){
const ret = [];
console.log(this.selectedView)
const eqs = store.state.equivalents[this.selectedView]["ONE_KM_CAR"]
for (const equivalent in eqs) {
if (eqs[equivalent] !== null) {
ret.push({ text: "Le "+equivalent+" équivaut à "+eqs[equivalent]+"km en voiture thermique."});
}
}
console.log(eqs);
console.log(ret);
return ret
}
}
},
mounted() {
this.$root.$on("re_render_results_detailled", () => {
......
......@@ -165,20 +165,22 @@ let store = new Vuex.Store({
state.impact_on_spheres_detailled[sphere].datasets[1].data = software;
state.impact_on_spheres_detailled[sphere].datasets[2].data = journey;
},
async updateEquivalents(state, { equivalents }) {
state.equivalents = equivalents;
}
},
actions: {
async callAPI(context) {
if (state.scenarios_json.length) {
return Vue.http.post("meeting", state.scenarios_json).then(
(response) =>
(response) => {
context.dispatch("processComparisonResponse", {
comparison: response.body.comparison,
}),
(response) =>
});
context.dispatch("processEquivalentResponse", {
comparison: response.body.equivalents,
}),
(error) => console.log(error)
equivalents: response.body.equivalents,
});
}
);
}
},
......@@ -240,9 +242,11 @@ let store = new Vuex.Store({
});
}
},
processEquivalentResponse(response) {
console.log("todo process equivalent response");
console.log(response);
processEquivalentResponse: function(context, { equivalents }) {
console.log('b', equivalents);
store.commit("updateEquivalents", {
equivalents
});
},
},
});
......
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