Commit 8597c76c authored by Lucas Détré's avatar Lucas Détré

adding a filter on simulator context

parent 37ad6563
Pipeline #3207 passed with stage
in 1 minute and 33 seconds
<template>
<div id="SimulateurContext">
<br>
<label for="filterContext">
<strong>
Filtrer les entrées du tableau :
</strong>
</label>
<br>
<input class="form-control" type="text" id="filterContext" name="filterContext" v-model="filterContext" placeholder="Filtre..."/>
<br>
<table class="table-responsive table table-striped table-hover">
<caption> Contexte de simulation </caption>
......@@ -10,7 +18,7 @@
</tr>
</thead>
<tbody>
<tr v-for="(value, key) in this.context" :key="key">
<tr v-for="(value, key) in this.filteredContext" :key="key">
<td> {{ renderLabel(key) }} </td>
<td> {{ renderValue(key,value,schema[key]) }} </td>
</tr>
......@@ -20,11 +28,11 @@
</template>
<script>
export default {
name: 'SimulateurContext',
name: 'SimulateurContext',
props: ['schema', 'context',],
data: function () {
return {
test: [],
filterContext: "",
}
},
methods: {
......@@ -38,9 +46,21 @@
},
renderLabel: function (key) {
return this.schema[key]['label'].charAt(0).toUpperCase() + this.schema[key]['label'].slice(1)
},
},
computed: {
filteredContext : function () {
if (this.filterContext == "") return this.context;
else {
return Object.keys(this.context)
.filter(key => this.renderLabel(key).toLowerCase().includes(this.filterContext.toLowerCase()))
.reduce((obj, key) => {
obj[key] = this.context[key];
return obj;
}, {});
}
}
}
}
</script>
......
......@@ -104,7 +104,6 @@
},
showFinancement: function (financement) {
if (this.selectedTags != this.tags) {
console.log("hello");
for(var i = 0; i< financement.tags.length; i++) {
if (this.selectedTags.includes(financement.tags[i])) return false;
}
......
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