Skip to content
Snippets Groups Projects
Commit 62adee25 authored by Jonathan Foucher's avatar Jonathan Foucher
Browse files

Update graph when saving draft

parent 77396eb2
No related branches found
No related tags found
No related merge requests found
Pipeline #30396 failed
...@@ -96,8 +96,12 @@ export default { ...@@ -96,8 +96,12 @@ export default {
this.toaster(this, 'Impossible de sauvegarder l\'évaluation', 'bg-warning') this.toaster(this, 'Impossible de sauvegarder l\'évaluation', 'bg-warning')
} }
this.$store.commit('removeGraphData', {id: this.evaluation.id})
this.$store.dispatch('getAllGraphsForEvaluation', this.evaluation.id)
this.drafting = false this.drafting = false
this.$router.push('/evaluations') //this.$router.push('/evaluations')
}, },
async next () { async next () {
this.saving = true this.saving = true
...@@ -132,6 +136,7 @@ export default { ...@@ -132,6 +136,7 @@ export default {
} }
this.saving = false this.saving = false
this.$store.dispatch('getAllGraphsForEvaluation', this.evaluation.id)
} }
}, },
async edit () { async edit () {
......
<template> <template>
<div class="graph-element row"> <div class="graph-element row" v-if="singleData.labels.length">
<div class="graph-legend col-3 mr-0 pr-0 text-muted"> <div class="graph-legend col-3 mr-0 pr-0 text-muted">
<span :title="fullLabel">{{singleData.labels[0]}}</span> <span :title="fullLabel">{{singleData.labels[0]}}</span>
</div> </div>
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
] ]
} }
} }
} },
} }
</script> </script>
<style scoped> <style scoped>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
:expected-level="measureLevel.expected_level" :expected-level="measureLevel.expected_level"
/> />
<!-- EN ATTENTE RETOUR CLIENT --> <!-- EN ATTENTE RETOUR CLIENT -->
<p class="text-center my-4">Efficacité <i class="fas fa-angle-double-right px-2"></i> Efficacité</p> <!-- <p class="text-center my-4">Efficacité <i class="fas fa-angle-double-right px-2"></i> Efficacité</p>-->
<MeasureActionForm <MeasureActionForm
ref="MeasureActionForm" ref="MeasureActionForm"
......
...@@ -57,7 +57,6 @@ export default { ...@@ -57,7 +57,6 @@ export default {
const measure = this.$store.state.measures.all.find(m => m.id === parseInt(this.$route.params.id, 10)) const measure = this.$store.state.measures.all.find(m => m.id === parseInt(this.$route.params.id, 10))
const evaluation = this.$store.state.evaluations.all.find(e => e.id === parseInt(this.$route.params.id, 10)) const evaluation = this.$store.state.evaluations.all.find(e => e.id === parseInt(this.$route.params.id, 10))
const ter = this.$store.state.territories.all.find(v => v.id === parseInt(this.$route.params.id, 10)) const ter = this.$store.state.territories.all.find(v => v.id === parseInt(this.$route.params.id, 10))
console.log('bb',ter, org)
switch (this.$route.meta.type) { switch (this.$route.meta.type) {
case 'user': case 'user':
......
import axios from 'axios' import axios from 'axios'
import Vue from "vue";
export default { export default {
state: { }, state: { },
mutations: { mutations: {
setGraphData (state, {name, data, id}) { setGraphData (state, {name, data, id}) {
if (typeof state[id] === 'undefined') { if (typeof state[id] === 'undefined') {
state[id] = {}; Vue.set(state, id, {})
} }
state[id] = {...state[id], [name]: data} const newData = {...state[id], [name]: data}
Vue.set(state, id, newData)
state[id] = newData
}, },
removeGraphData (state, {id}) { removeGraphData (state, {id}) {
if (typeof state[id] !== 'undefined') { state[id] = {}
delete state[id]; Vue.delete(state, id)
}
} }
}, },
actions: { actions: {
...@@ -21,6 +23,20 @@ export default { ...@@ -21,6 +23,20 @@ export default {
const req = await axios.get(`/api/evaluations/${id}/graphs/${name}`) const req = await axios.get(`/api/evaluations/${id}/graphs/${name}`)
commit('setGraphData', { name, data: req.data, id }) commit('setGraphData', { name, data: req.data, id })
return req.data return req.data
},
async getAllGraphsForEvaluation ({ commit }, id) {
const graphs = [
'risks',
'measures',
'futurerisks',
'exposition',
'attack',
]
graphs.forEach((name) => {
axios.get(`/api/evaluations/${id}/graphs/${name}`).then(res => {
commit('setGraphData', { name, data: res.data, id })
})
})
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment