Commit f01d80ac authored by David Foucher's avatar David Foucher

Merge branch 'improve-scenario' into 'master'

Improve scenario

See merge request !53
parents 6a52852c 453ea24a
Pipeline #3201 passed with stage
in 2 minutes and 2 seconds
......@@ -266,7 +266,7 @@
password: '',
file: this.path
},
this.isEditMode=!this.isEditMode;
this.isEditMode=false;
if(this.modification_count!=0) this.viewModification = true;
this.error_flags = {
badUser: false,
......
......@@ -15,7 +15,7 @@
<h2 class="mb-5">Scénarios</h2>
<ul>
<li v-for="(filter, id) in filterList" :key="id">
<a href="#" :class="{selected: filters[filter].selected}" @click="setFilter(filters[filter]);">
<a :href="'#'+selected_filters.join(',')" :class="{selected: filters[filter].selected}" @click="setFilter(filter);">
{{ filter.charAt(0).toUpperCase() + filter.slice(1) }}
</a>
</li>
......@@ -27,6 +27,7 @@
</div>
<div :class="classCollapsedContent">
<div v-if="this.show">
<div v-if="this.activeScenarios.length > 0">
<ul>
<li v-for="(scenario, id) in this.activeScenarios" :key="id">
<h4>
......@@ -40,6 +41,10 @@
</li>
</ul>
</div>
<div v-else>
<h4 class="mt-5">Veuillez sélectionner au moins une catégorie</h4>
</div>
</div>
<div v-else>
<h2>Sélectionnez une catégorie dans le menu.</h2>
</div>
......@@ -71,17 +76,18 @@
show: function () {
return (this.nbSelected !== '')
},
activeScenarios: function(){
var activeScenarios = []
var scenarios = this.scenarios
for (var i=0; i< this.selected_filters.length; i++) {
var tag = this.selected_filters[i].tag
scenarios.forEach(function(scenario){
if (scenario.tags.find(scenario_tag => scenario_tag == tag) != undefined)
activeScenarios.push(scenario);
})
activeScenarios: function () {
var activeScenarios = [];
var scenarios = this.scenarios;
if(this.selected_filters.length > 0) {
for (var i=0; i < scenarios.length; i++) {
var scenario = scenarios[i];
if(this.selected_filters.every(function(current_filter) {
return (scenario.tags.find(scenario_tag => scenario_tag == current_filter) != undefined)
})) activeScenarios.push(scenario);
}
}
return activeScenarios
return activeScenarios;
},
filterList: function(){
var filterList = []
......@@ -127,6 +133,7 @@
},
created: function () {
this.load();
if(decodeURI(window.location.hash) != "") this.selected_filters = decodeURI(window.location.hash).split('#')[1].split(',');
},
methods: {
load: function () {
......@@ -155,12 +162,11 @@
}).created;
},
setFilter: function (filter) {
var index = this.selected_filters.indexOf(filter)
if (index > -1) this.selected_filters.splice(index, 1)
else this.selected_filters.push(filter)
filter.selected = !filter.selected
this.filters[filter].selected = !this.filters[filter].selected
},
transform: function(data) {
return data
......
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