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 @@ ...@@ -266,7 +266,7 @@
password: '', password: '',
file: this.path file: this.path
}, },
this.isEditMode=!this.isEditMode; 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 = {
badUser: false, badUser: false,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<h2 class="mb-5">Scénarios</h2> <h2 class="mb-5">Scénarios</h2>
<ul> <ul>
<li v-for="(filter, id) in filterList" :key="id"> <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) }} {{ filter.charAt(0).toUpperCase() + filter.slice(1) }}
</a> </a>
</li> </li>
...@@ -27,18 +27,23 @@ ...@@ -27,18 +27,23 @@
</div> </div>
<div :class="classCollapsedContent"> <div :class="classCollapsedContent">
<div v-if="this.show"> <div v-if="this.show">
<ul> <div v-if="this.activeScenarios.length > 0">
<li v-for="(scenario, id) in this.activeScenarios" :key="id"> <ul>
<h4> <li v-for="(scenario, id) in this.activeScenarios" :key="id">
{{ scenario.name.toUpperCase() }} <h4>
<!--<a :href="'https://framagit.org/ybon/trefle/tree/master/'+scenario.filename+'#L'+scenario.line" target=_blank> {{ scenario.name.toUpperCase() }}
<i class=icon>edit</i> <!--<a :href="'https://framagit.org/ybon/trefle/tree/master/'+scenario.filename+'#L'+scenario.line" target=_blank>
</a>--> <i class=icon>edit</i>
</h4> </a>-->
<pre v-html="transform(scenario.raw)"/> </h4>
<br><br> <pre v-html="transform(scenario.raw)"/>
</li> <br><br>
</ul> </li>
</ul>
</div>
<div v-else>
<h4 class="mt-5">Veuillez sélectionner au moins une catégorie</h4>
</div>
</div> </div>
<div v-else> <div v-else>
<h2>Sélectionnez une catégorie dans le menu.</h2> <h2>Sélectionnez une catégorie dans le menu.</h2>
...@@ -71,17 +76,18 @@ ...@@ -71,17 +76,18 @@
show: function () { show: function () {
return (this.nbSelected !== '') return (this.nbSelected !== '')
}, },
activeScenarios: function(){ activeScenarios: function () {
var activeScenarios = [] var activeScenarios = [];
var scenarios = this.scenarios var scenarios = this.scenarios;
for (var i=0; i< this.selected_filters.length; i++) { if(this.selected_filters.length > 0) {
var tag = this.selected_filters[i].tag for (var i=0; i < scenarios.length; i++) {
scenarios.forEach(function(scenario){ var scenario = scenarios[i];
if (scenario.tags.find(scenario_tag => scenario_tag == tag) != undefined) if(this.selected_filters.every(function(current_filter) {
activeScenarios.push(scenario); return (scenario.tags.find(scenario_tag => scenario_tag == current_filter) != undefined)
}) })) activeScenarios.push(scenario);
}
} }
return activeScenarios return activeScenarios;
}, },
filterList: function(){ filterList: function(){
var filterList = [] var filterList = []
...@@ -127,6 +133,7 @@ ...@@ -127,6 +133,7 @@
}, },
created: function () { created: function () {
this.load(); this.load();
if(decodeURI(window.location.hash) != "") this.selected_filters = decodeURI(window.location.hash).split('#')[1].split(',');
}, },
methods: { methods: {
load: function () { load: function () {
...@@ -155,12 +162,11 @@ ...@@ -155,12 +162,11 @@
}).created; }).created;
}, },
setFilter: function (filter) { setFilter: function (filter) {
var index = this.selected_filters.indexOf(filter) var index = this.selected_filters.indexOf(filter)
if (index > -1) this.selected_filters.splice(index, 1) if (index > -1) this.selected_filters.splice(index, 1)
else this.selected_filters.push(filter) else this.selected_filters.push(filter)
filter.selected = !filter.selected this.filters[filter].selected = !this.filters[filter].selected
}, },
transform: function(data) { transform: function(data) {
return 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