Commit 8fa9c499 authored by David Foucher's avatar David Foucher

Merge branch '21-ajout-d-un-filtre-dans-le-context-de-simulation' into 'master'

Resolve "Ajout d'un filtre dans le context de simulation"

Closes #21

See merge request !57
parents cd11562b 8597c76c
Pipeline #3214 passed with stage
in 1 minute and 30 seconds
<template> <template>
<div id="SimulateurContext"> <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> <br>
<table class="table-responsive table table-striped table-hover"> <table class="table-responsive table table-striped table-hover">
<caption> Contexte de simulation </caption> <caption> Contexte de simulation </caption>
...@@ -10,7 +18,7 @@ ...@@ -10,7 +18,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <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> {{ renderLabel(key) }} </td>
<td> {{ renderValue(key,value,schema[key]) }} </td> <td> {{ renderValue(key,value,schema[key]) }} </td>
</tr> </tr>
...@@ -20,11 +28,11 @@ ...@@ -20,11 +28,11 @@
</template> </template>
<script> <script>
export default { export default {
name: 'SimulateurContext', name: 'SimulateurContext',
props: ['schema', 'context',], props: ['schema', 'context',],
data: function () { data: function () {
return { return {
test: [], filterContext: "",
} }
}, },
methods: { methods: {
...@@ -38,9 +46,21 @@ ...@@ -38,9 +46,21 @@
}, },
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: {
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> </script>
......
...@@ -104,7 +104,6 @@ ...@@ -104,7 +104,6 @@
}, },
showFinancement: function (financement) { showFinancement: function (financement) {
if (this.selectedTags != this.tags) { if (this.selectedTags != this.tags) {
console.log("hello");
for(var i = 0; i< financement.tags.length; i++) { for(var i = 0; i< financement.tags.length; i++) {
if (this.selectedTags.includes(financement.tags[i])) return false; 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