Commit 00ca3138 authored by David Foucher's avatar David Foucher

Merge branch 'fix-sonarQube-bugs' into 'master'

Fix sonar qube bugs

See merge request !77
parents 46329101 70dfca7a
Pipeline #3649 passed with stage
in 2 minutes and 1 second
...@@ -13,18 +13,10 @@ ...@@ -13,18 +13,10 @@
<div id="financement-create-financement" class="col-md-6 col-sm-12 col-xs-12 my-auto"> <div id="financement-create-financement" class="col-md-6 col-sm-12 col-xs-12 my-auto">
<div class="form-inline pull-right"> <div class="form-inline pull-right">
<div class="form-group mx-sm-3 mb-2"> <div class="form-group mx-sm-3 mb-2">
<!--<input type="button" href="#" class="btn main-button form-control" value="Créer un financement" disabled />-->
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!--
<div class="row">
<div id="financement-last-update" class="col-md-12">
Dernière mise à jour le __ à __
</div>
</div>
-->
</div> </div>
</div> </div>
<hr class="financement-horizontal-separator"> <hr class="financement-horizontal-separator">
...@@ -83,13 +75,6 @@ ...@@ -83,13 +75,6 @@
</span> </span>
</span> </span>
</span> </span>
<!--
<span class="col-md-1 col-sm-1 pull-right">
<button href="https://git.beta.pole-emploi.fr/open-source/trefle/edit/master/trefle/config/financements.yml" target="_blank" class="text-dark btn btn-outline-light" disabled>
<i class="icon" style="vertical-align: baseline;">edit</i>
</button>
</span>
-->
</li> </li>
</ul> </ul>
</div> </div>
...@@ -143,8 +128,7 @@ ...@@ -143,8 +128,7 @@
this.financements = response.body; this.financements = response.body;
this.filteredFinancements = response.body; this.filteredFinancements = response.body;
this.isLoading = false; this.isLoading = false;
}) });
.created;
}, },
setSearchTag: function (tag) { setSearchTag: function (tag) {
this.search = tag; this.search = tag;
...@@ -160,7 +144,7 @@ ...@@ -160,7 +144,7 @@
isCaseSensitive ? searchRegExp = new RegExp(searchWithoutAccents,"g") : searchRegExp = new RegExp(searchWithoutAccents,'ig') isCaseSensitive ? searchRegExp = new RegExp(searchWithoutAccents,"g") : searchRegExp = new RegExp(searchWithoutAccents,'ig')
return searchType != "input" ? this.filterable("", financement.tags).match(searchRegExp) : this.filterable(financement.intitule, financement.tags).match(searchRegExp) return searchType != "input" ? this.filterable("", financement.tags).match(searchRegExp) : this.filterable(financement.intitule, financement.tags).match(searchRegExp)
} }
return true return true;
}) })
}, },
filterable: function (intitule,tags) { filterable: function (intitule,tags) {
......
...@@ -43,8 +43,7 @@ ...@@ -43,8 +43,7 @@
this.resultsIsEmpty = this.isEmpty(this.results); this.resultsIsEmpty = this.isEmpty(this.results);
}, () => { }, () => {
this.resultsIsEmpty = this.isEmpty(this.results); this.resultsIsEmpty = this.isEmpty(this.results);
}) });
.created;
}, },
isEmpty: function (obj) { isEmpty: function (obj) {
for(var key in obj) { for(var key in obj) {
......
...@@ -43,8 +43,7 @@ ...@@ -43,8 +43,7 @@
.then(response => { .then(response => {
this.results = response.body; this.results = response.body;
this.resultsIsEmpty = this.isEmpty(this.results); this.resultsIsEmpty = this.isEmpty(this.results);
}) });
.created;
}, },
isEmpty: function (obj) { isEmpty: function (obj) {
for(var key in obj) { for(var key in obj) {
......
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
.then(response => { .then(response => {
this.results = response.body; this.results = response.body;
this.resultsIsEmpty = this.isEmpty(this.results); this.resultsIsEmpty = this.isEmpty(this.results);
}) });
.created;
}, },
isEmpty: function (obj) { isEmpty: function (obj) {
for(var key in obj) { for(var key in obj) {
......
...@@ -43,8 +43,7 @@ ...@@ -43,8 +43,7 @@
.then(response => { .then(response => {
this.results = response.body; this.results = response.body;
this.resultsIsEmpty = this.isEmpty(this.results); this.resultsIsEmpty = this.isEmpty(this.results);
}) });
.created;
}, },
isEmpty: function (obj) { isEmpty: function (obj) {
for(var key in obj) { for(var key in obj) {
......
...@@ -133,8 +133,7 @@ ...@@ -133,8 +133,7 @@
.then(response => { .then(response => {
this.rules = response.body; this.rules = response.body;
this.isLoading = false; this.isLoading = false;
}) });
.created;
}, },
forceRerender: function () { forceRerender: function () {
this.rerenderKey +=1; this.rerenderKey +=1;
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
email: '', email: '',
password: '', password: '',
file: this.path file: this.path
}, };
this.isEditMode=false; this.isEditMode=false;
if(this.modification_count!=0) this.viewModification = true; if(this.modification_count!=0) this.viewModification = true;
this.error_flags = { this.error_flags = {
......
<template> <template>
<div id="Simulateur"> <div id="Simulateur">
<div class="container form-group pt-5"> <div class="container form-group pt-5 pb-3">
<div v-if="!resultats"> <div v-if="!resultats">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<hr class="simulateur-horizontal-separator"> <hr class="simulateur-horizontal-separator">
<!---------------- STEP FORMATION ----------------> <!---------------- STEP FORMATION ---------------->
<div class="formation-step step" :class="{step_completed_class: formation_step_completed}"> <div class="formation-step step" :class="{step_completed_class: formation_step_completed}">
<SimulateurStepFormation :id_formation="formation.numero"/> <SimulateurStepFormation :id_formation_parent="formation.numero"/>
</div> </div>
<hr v-if="formation_step_completed" class="simulateur-horizontal-separator"> <hr v-if="formation_step_completed" class="simulateur-horizontal-separator">
<!---------------- STEP ONE ----------------> <!---------------- STEP ONE ---------------->
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<hr v-if="step_four_completed" class="simulateur-horizontal-separator"> <hr v-if="step_four_completed" class="simulateur-horizontal-separator">
<!---------------- STEP FIVE ----------------> <!---------------- STEP FIVE ---------------->
<div v-if="step_four_completed" class="form-step step-five" :class="{step_completed_class: step_five_completed}"> <div v-if="step_four_completed" class="form-step step-five" :class="{step_completed_class: step_five_completed}">
<SimulateurStepFive id="SimulateurStepFive"/> <SimulateurStepFive id="SimulateurStepFive" :id_naf_parent="naf" :id_idcc_parent="idcc"/>
</div> </div>
<!---------------- STEP FIVE ----------------> <!---------------- STEP FIVE ---------------->
<div v-if="step_five_completed" class="form-step"> <div v-if="step_five_completed" class="form-step">
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
a_travaille_six_mois: this.situation_6moissur12, a_travaille_six_mois: this.situation_6moissur12,
a_travaille_douze_mois: this.situation_6moissur12, a_travaille_douze_mois: this.situation_6moissur12,
entreprise : { entreprise : {
naf: this.naf.match(/^\d{2}\.?\d{2}[a-zA-Z]$/gi) == null ? null : this.naf.match(/^\d{2}\.?\d{2}[a-zA-Z]$/gi), naf: this.naf.match(/^\d{2}\.?\d{2}[a-zA-Z]$/gi) == null ? null : this.naf.match(/^\d{2}\.?\d{2}[a-zA-Z]$/gi).pop(),
idcc: this.idcc, idcc: this.idcc,
commune: this.commune_entreprise, commune: this.commune_entreprise,
opco: null, opco: null,
...@@ -306,24 +306,28 @@ ...@@ -306,24 +306,28 @@
}) })
}, },
simulateFromUrl: function() { simulateFromUrl: function() {
if(window.location.hash.substr(1).match(/^simulate/)) if(window.location.hash.substr(1).match(/^simulate/)) {
var simulate_link = window.location.hash.substr(9) var simulate_link = window.location.hash.substr(9);
if(simulate_link.includes('labonneformation')) if(simulate_link != undefined && simulate_link != null) {
this.$http.get('/explore/decode-lbf-url?url='+simulate_link) if(simulate_link.includes('labonneformation')) {
.then(response => { this.$http.get('/explore/decode-lbf-url?url='+simulate_link)
this.context = response.body .then(response => {
this.$http.get('/explore/catalog?id='+this.context['formation.numero']).then(response => { this.context = response.body
if(response.status == 200) { this.$http.get('/explore/catalog?id='+this.context['formation.numero']).then(response_catalog => {
this.simulate() if(response_catalog.status == 200) {
} this.simulate()
}) }
}) })
});
}
}
}
}, },
prepareRequest: function() { 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 = "";
this.allocation_dateend = null; this.allocation_dateend = "";
} }
this.salaire = null; this.salaire = null;
this.moistravailleencdd = null; this.moistravailleencdd = null;
...@@ -335,8 +339,8 @@ ...@@ -335,8 +339,8 @@
this.commune_entreprise_autocomplete = ''; this.commune_entreprise_autocomplete = '';
} else if (this.situation_inscrit == 2) { } else if (this.situation_inscrit == 2) {
this.allocation_type = null; this.allocation_type = "";
this.allocation_dateend = null; this.allocation_dateend = "";
this.situation_inscritcumuldureeinscriptionsur12mois = null; this.situation_inscritcumuldureeinscriptionsur12mois = null;
this.allocation_cost = null; this.allocation_cost = null;
this.commune_beneficiaire_autocomplete = ''; this.commune_beneficiaire_autocomplete = '';
...@@ -386,7 +390,7 @@ ...@@ -386,7 +390,7 @@
this.scenario = response.body.scenario; this.scenario = response.body.scenario;
this.context = response.body.context; this.context = response.body.context;
this.isLoading = false; this.isLoading = false;
}).created });
this.resultats = true; this.resultats = true;
}, },
objectIsEmpty: function (obj) { objectIsEmpty: function (obj) {
......
...@@ -9,16 +9,16 @@ ...@@ -9,16 +9,16 @@
<br> <br>
<input class="form-control" type="text" id="filterContext" name="filterContext" v-model="filterContext" placeholder="Filtre..."/> <input class="form-control" type="text" id="filterContext" name="filterContext" v-model="filterContext" placeholder="Filtre..."/>
<br> <br>
<table class="table-responsive table table-striped table-hover"> <table class="table-responsive table table-hover">
<caption> Contexte de simulation </caption> <caption> Contexte de simulation </caption>
<thead> <thead>
<tr> <tr>
<th>Nom</th> <th id="context_keys">Nom</th>
<th>Valeur</th> <th id="context_values">Valeur</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(value, key) in this.filteredContext" :key="key"> <tr v-for="(value, key) in this.filteredContext" :key="key" :class="{'non_specifiee':!(value != null && value != '')}">
<td> {{ renderLabel(key) }} </td> <td> {{ renderLabel(key) }} </td>
<td> {{ renderValue(key,value,schema[key]) }} </td> <td> {{ renderValue(key,value,schema[key]) }} </td>
</tr> </tr>
...@@ -38,14 +38,26 @@ ...@@ -38,14 +38,26 @@
methods: { methods: {
renderValue: function (key, value, schema_tmp) { renderValue: function (key, value, schema_tmp) {
schema_tmp = schema_tmp || this.schema[key] schema_tmp = schema_tmp || this.schema[key]
if (schema_tmp['type'] === 'array') return value.map(v => this.renderValue(key, v, schema_tmp['items'])).join(', ') if(value != null && value != "") {
if (schema_tmp['type'] === "boolean") return value ? 'oui' : 'non' if (schema_tmp['type'] === 'string' || schema_tmp['type'] === 'integer') return value;
if (schema_tmp['format'] === 'date') return (new Date(value * 1000)).toLocaleDateString() if (schema_tmp['type'] === 'array') return value.map(v => this.renderValue(key, v, schema_tmp['items'])).join(', ');
if (schema_tmp['enum']) return schema_tmp === undefined ? schema_tmp['enum'][value]+' ('+value+')' : '' if (schema_tmp['type'] === "boolean") return value ? 'oui' : 'non';
return value if (schema_tmp['format'] === 'date') {
if(key == "beneficiaire.naissance") {
if (value != null && value != undefined) {
var dateParts = value.split("/");
return (new Date(+dateParts[2], dateParts[1]-1, +dateParts[0])).toLocaleDateString("fr");
} else return "Non spécifiée";
}
if(value != null && value != "") return (new Date(value * 1000)).toLocaleDateString("fr");
else return "Non spécifiée";
}
if (schema_tmp['enum']) return schema_tmp == undefined ? schema_tmp['enum'][value]+' ('+value+')' : '';
return value;
} else return "Non spécifiée";
}, },
renderLabel: function (key) { renderLabel: function (key) {
return this.schema[key]['label'].charAt(0).toUpperCase() + this.schema[key]['label'].slice(1) return this.schema[key]['label'].charAt(0).toUpperCase() + this.schema[key]['label'].slice(1);
}, },
}, },
computed: { computed: {
...@@ -75,4 +87,9 @@ ...@@ -75,4 +87,9 @@
width:100%; width:100%;
table-layout:fixed; table-layout:fixed;
} }
.non_specifiee {
background-color: #ececec;
color: #b9b9b9;
}
</style> </style>
...@@ -16,30 +16,31 @@ ...@@ -16,30 +16,31 @@
<ul> <ul>
<li v-for="(financement, financement_id) in this.financements" :key="financement_id" class="result" :class="{hide:showFinancement(financement)}"> <li v-for="(financement, financement_id) in this.financements" :key="financement_id" class="result" :class="{hide:showFinancement(financement)}">
<br> <br>
<h5 :class="{passed: financement.eligible, failed: !financement.eligible}" data-toggle="collapse" :data-target="'#details_'+financement_id" aria-expanded="false" aria-controls="explain" style="cursor:pointer;" >{{ financement.intitule }} <h5 :class="{passed: financement.eligible, failed: !financement.eligible}" data-toggle="collapse" :data-target="'#details_'+financement_id" aria-expanded="false" aria-controls="explain" style="cursor:pointer;" >
{{ financement.intitule }}
<div class="pull-right"> <div class="pull-right">
<label v-for="(tag, tag_id) in financement.tags" :key="tag_id" class="label">{{ tag }}</label> <label v-for="(tag, tag_id) in financement.tags" :key="tag_id" class="label">{{ tag }}</label>
</div> </div>
</h5> </h5>
<div :id="'details_'+financement_id" class="collapse"> <div :id="'details_'+financement_id" class="collapse">
<p><strong>Description</strong> {{ financement.description }}</p> <p v-if="financement.description"><strong>Description :</strong> {{ financement.description }}</p>
<p><strong>Démarches</strong> {{ financement.demarches }}</p> <p v-if="financement.demarches"><strong>Démarches :</strong> {{ financement.demarches }}</p>
<div v-if="financement.eligible"> <div v-if="financement.eligible">
<p><strong>Prise en charge</strong> {{ financement.prise_en_charge }}</p> <p v-if="financement.prise_en_charge"><strong>Prise en charge :</strong> {{ financement.prise_en_charge }}</p>
<p v-if="financement.prise_en_charge_texte"><strong>Prise en charge</strong> {{ financement.prise_en_charge_texte }}</p> <p v-if="financement.prise_en_charge_texte"><strong>Prise en charge :</strong> {{ financement.prise_en_charge_texte }}</p>
<p><strong>Plafond de prise en charge</strong> {{ financement.plafond_prise_en_charge }}</p> <p v-if="financement.plafond_prise_en_charge"><strong>Plafond de prise en charge :</strong> {{ financement.plafond_prise_en_charge }}</p>
<p><strong>Plafond de prix horaire</strong> {{ financement.plafond_prix_horaire }}</p> <p v-if="financement.plafond_prix_horaire"><strong>Plafond de prix horaire :</strong> {{ financement.plafond_prix_horaire }}</p>
<p><strong>Nombre d'heures prises en charge</strong> {{ financement.heures }}</p> <p v-if="financement.heures"><strong>Nombre d'heures prises en charge :</strong> {{ financement.heures }}</p>
<p><strong>Rémunération</strong> {{ financement.remuneration }}</p> <p v-if="financement.remuneration"><strong>Rémunération :</strong> {{ financement.remuneration }}</p>
<p v-if="financement.remuneration_texte"><strong>Rémunération</strong> {{ financement.remuneration_texte }}</p> <p v-if="financement.remuneration_texte"><strong>Rémunération :</strong> {{ financement.remuneration_texte }}</p>
<p v-if="financement.fin_remuneration"><strong>Fin de la rémunération</strong> {{ renderValue('financement.fin_remuneration', financement.fin_remuneration,schema) }}</p> <p v-if="financement.fin_remuneration"><strong>Fin de la rémunération :</strong> {{ renderValue('financement.fin_remuneration', financement.fin_remuneration,schema) }}</p>
<p v-if="financement.rff"><strong>RFF</strong> {{ financement.rff }}</p> <p v-if="financement.rff"><strong>RFF :</strong> {{ financement.rff }}</p>
<p v-if="financement.debut_rff"><strong>Début de la RFF</strong> {{ renderValue('financement.debut_rff', financement.debut_rff,schema) }}</p> <p v-if="financement.debut_rff"><strong>Début de la RFF :</strong> {{ renderValue('financement.debut_rff', financement.debut_rff,schema) }}</p>
<p v-if="financement.fin_rff"><strong>Fin de la RFF</strong> {{ renderValue('financement.fin_rff', financement.fin_rff,schema) }}</p> <p v-if="financement.fin_rff"><strong>Fin de la RFF :</strong> {{ renderValue('financement.fin_rff', financement.fin_rff,schema) }}</p>
<p v-if="financement.organisme"><strong>Organisme</strong> {{ financement.organisme.nom }}</p> <p v-if="financement.organisme"><strong>Organisme :</strong> {{ financement.organisme.nom }}</p>
</div> </div>
<p> <p>
<strong>Règles de gestion</strong><br><br> <strong>Règles de gestion :</strong><br><br>
<eligibilite :conditions="financement.explain" :schema="schema"/> <eligibilite :conditions="financement.explain" :schema="schema"/>
</p> </p>
</div> </div>
...@@ -116,8 +117,8 @@ ...@@ -116,8 +117,8 @@
schema_tmp = schema_tmp || this.schema[key] schema_tmp = schema_tmp || this.schema[key]
if (schema_tmp['type'] === 'array') return value.map(v => this.renderValue(key, v, schema_tmp['items'])).join(', ') if (schema_tmp['type'] === 'array') return value.map(v => this.renderValue(key, v, schema_tmp['items'])).join(', ')
if (schema_tmp['type'] === "boolean") return value ? 'oui' : 'non' if (schema_tmp['type'] === "boolean") return value ? 'oui' : 'non'
if (schema_tmp['format'] === 'date') return (new Date(value * 1000)).toLocaleDateString() if (schema_tmp['format'] === 'date' && value != null && value != "") return (new Date(value * 1000)).toLocaleDateString("fr")
if (schema_tmp['enum']) return schema_tmp === undefined ? schema_tmp['enum'][value]+' ('+value+')' : '' if (schema_tmp['enum']) return schema_tmp == undefined ? schema_tmp['enum'][value]+' ('+value+')' : ''
return value return value
}, },
renderLabel: function (key) { renderLabel: function (key) {
......
...@@ -94,47 +94,45 @@ ...@@ -94,47 +94,45 @@
<hr class="simulateur-horizontal-separator"> <hr class="simulateur-horizontal-separator">
</div> </div>
</div> </div>
<div id="explainCollapseGroup"> <div id="explainCollapseGroup" class="container">
<div class="row" id="explainButtonsGroup"> <div class="row" id="explainButtonsGroup">
<div class="col-md-4"> <div class="col-md-4">
<span class="ml-5" data-toggle="collapse" data-target="#scenario" aria-expanded="false" aria-controls="scenario" style="cursor:pointer;" v-on:click="scenarioToggled=!scenarioToggled"> <span class="ml-5" data-toggle="collapse" data-target="#scenario" aria-expanded="false" aria-controls="scenario" style="cursor:pointer;" v-on:click="toggle('scenario');">
<button v-if="!scenarioToggled" class="btn main-button-primary">Voir le scénario de simulation</button> <button v-if="!scenarioToggled" class="btn main-button-primary">Voir le scénario de simulation</button>
<button v-else class="btn main-button-primary">Masquer le scénario de simulation</button> <button v-else class="btn main-button">Masquer le scénario de simulation</button>
</span> </span>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<span class="ml-5" data-toggle="collapse" data-target="#context" aria-expanded="false" aria-controls="context" style="cursor:pointer;" v-on:click="contextToggled=!contextToggled"> <span class="ml-5" data-toggle="collapse" data-target="#context" aria-expanded="false" aria-controls="context" style="cursor:pointer;" v-on:click="toggle('context');">
<button v-if="!contextToggled" class="btn main-button-primary">Voir le contexte de simulation</button> <button v-if="!contextToggled" class="btn main-button-primary">Voir le contexte de simulation</button>
<button v-else class="btn main-button-primary">Masquer le contexte de simulation</button> <button v-else class="btn main-button">Masquer le contexte de simulation</button>
</span> </span>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<span class="ml-5" data-toggle="collapse" data-target="#explain" aria-expanded="false" aria-controls="explain" style="cursor:pointer;" v-on:click="explainToggled=!explainToggled"> <span class="ml-5" data-toggle="collapse" data-target="#explain" aria-expanded="false" aria-controls="explain" style="cursor:pointer;" v-on:click="toggle('explain');">
<button v-if="!explainToggled" class="btn main-button-primary">Voir l'explication de simulation</button> <button v-if="!explainToggled" class="btn main-button-primary">Voir l'explication de simulation</button>
<button v-else class="btn main-button-primary">Masquer l'explication de simulation</button> <button v-else class="btn main-button">Masquer l'explication de simulation</button>
</span> </span>
</div> </div>
</div> </div>
<div class="container"> <div class="row">
<div class="row"> <div class="col-md-12">
<div class="col-md-12"> <div id="scenario" data-parent="#explainCollapseGroup" class="collapse">
<div id="scenario" data-parent="#explainCollapseGroup" class="collapse"> <SimulateurScenario :scenario="scenario"></SimulateurScenario>
<SimulateurScenario :scenario="scenario"></SimulateurScenario>
</div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col-md-12"> <div class="row">
<div id="context" data-parent="#explainCollapseGroup" class="collapse"> <div class="col-md-12">
<SimulateurContext :schema="schema" :context="context"></SimulateurContext> <div id="context" data-parent="#explainCollapseGroup" class="collapse">
</div> <SimulateurContext :schema="schema" :context="context"></SimulateurContext>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col-md-12"> <div class="row">
<div id="explain" data-parent="#explainCollapseGroup" class="collapse"> <div class="col-md-12">
<SimulateurExplain :schema="schema" :financements="financements"></SimulateurExplain> <div id="explain" data-parent="#explainCollapseGroup" class="collapse">