Commit 5c3939ca authored by David Foucher's avatar David Foucher

add possibility to make a simulatio from Labonneforamtion

parent 2d75e12f
Pipeline #3412 passed with stage
in 1 minute and 25 seconds
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</div> </div>
</div> </div>
</div> </div>
<!------------------- RESULTATS ---------------> <!------------------- RESULTATS -------------->
<div v-if="resultats" id="simulate-results"> <div v-if="resultats" id="simulate-results">
<div v-if="!isLoading" class="mt-5"> <div v-if="!isLoading" class="mt-5">
<SimulateurResultats :schema="schema" :financements="financements" :financements_eligibles="financements_eligibles" :scenario="scenario" :context="context"></SimulateurResultats> <SimulateurResultats :schema="schema" :financements="financements" :financements_eligibles="financements_eligibles" :scenario="scenario" :context="context"></SimulateurResultats>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
import SimulateurStepFive from './SimulateurStepFive'; import SimulateurStepFive from './SimulateurStepFive';
import SimulateurResultats from './SimulateurResultats.vue'; import SimulateurResultats from './SimulateurResultats.vue';
export default { export default {
name: 'Simulateur', name: 'Simulateur',
components: { components: {
SimulateurResultats, SimulateurResultats,
...@@ -74,8 +74,8 @@ ...@@ -74,8 +74,8 @@
SimulateurStepFour, SimulateurStepFour,
SimulateurStepFive, SimulateurStepFive,
}, },
data: function () { data: function () {
return { return {
// champs de formulaire // champs de formulaire
// step formation // step formation
id_formation : null, id_formation : null,
...@@ -152,7 +152,8 @@ ...@@ -152,7 +152,8 @@
isLoading: true, isLoading: true,
test: [], test: [],
schema: {}, schema: {},
} context: {},
}
}, },
computed: { computed: {
formation_step_completed: function () { formation_step_completed: function () {
...@@ -294,8 +295,9 @@ ...@@ -294,8 +295,9 @@
}, },
mounted: function () { mounted: function () {
this.loadSchema(); this.loadSchema();
this.simulateFromUrl();
}, },
methods: { methods: {
loadSchema: function () { loadSchema: function () {
fetch('/explore/schema') fetch('/explore/schema')
.then((response) => response.json()) .then((response) => response.json())
...@@ -303,8 +305,21 @@ ...@@ -303,8 +305,21 @@
this.schema = data this.schema = data
}) })
}, },
simulate: function () { simulateFromUrl: function() {
this.isLoading = true; if(window.location.hash.substr(1).match(/^simulate/))
var simulate_link = window.location.hash.substr(9)
if(simulate_link.includes('labonneformation'))
this.$http.get('/explore/decode-lbf-url?url='+simulate_link)
.then(response => {
this.context = response.body
this.$http.get('/explore/catalog?id='+this.context['formation.numero']).then(response => {
if(response.status == 200) {
this.simulate()
}
})
})
},
prepareRequest: function() {
if (this.situation_inscrit == 1) { if (this.situation_inscrit == 1) {
if (this.allocation_type == 'non') { if (this.allocation_type == 'non') {
this.allocation_type = null; this.allocation_type = null;
...@@ -346,8 +361,19 @@ ...@@ -346,8 +361,19 @@
} }
if (this.situation_cpfconnu != 'cpfconnu') this.situation_creditheurescpf = null; if (this.situation_cpfconnu != 'cpfconnu') this.situation_creditheurescpf = null;
},
simulate: function () {
this.isLoading = true;
this.$http.post('/financement?context=1&explain=true&scenario=1', this.request).then(response => { var context = null;
if(this.context) {
context=this.context
} else {
this.prepareRequest()
context=this.request
}
this.$http.post('/financement?context=1&explain=true&scenario=1', context).then(response => {
if(this.objectIsEmpty(response.body) == false) { if(this.objectIsEmpty(response.body) == false) {
for(var i=0; i<response.body.financements.length-1; i++) { for(var i=0; i<response.body.financements.length-1; i++) {
if(this.situation_cpfconnu=='cpfempty') { if(this.situation_cpfconnu=='cpfempty') {
...@@ -374,8 +400,8 @@ ...@@ -374,8 +400,8 @@
} }
return true; return true;
}, },
} }
} }
</script> </script>
<style> <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