So, basically i use an HTML select filled with the arrays of registered users
<label >
<b>
<i style="opacity:0.8">Users:</i>
</b>
</label>
<select
class="form-control w-50 mb-5"
style="display:inline;"
v-model="filter"
@change="userfilter"
>
<option id="userbox" v-for="user in userlist" :key="user.userlist">{{user}}</option>
<option>All</option>
</select>
than with v-model="filter" i set the filter value that initially is empty
export default {
name: "completed",
data() {
return {
filter: "",
userlist: "",
archive: [],
supportarchive: [],
selecteduser: ""
};
},
I have also created a suppor-tarray supportarchive:[] which function is to fill the original array when this condition result true:
methods: {
userfilter: function() {
this.selecteduser = this.filter;
if (this.filter == "All") {
this.supportarchive=[];
this.archive = JSON.parse(localStorage.getItem("completedtasks"));
} else {
this.supportarchive = this.archive;
this.archive = [];
for (let i = 0; i < this.supportarchive.length; i++) {
if (this.supportarchive.taskuserID == this.selecteduser) {
this.archive.push(this.supportarchive[i]);
}
}
}
}
}
Ok so if the filter is all then i fill my array from the localStorage but if the filter has another value then i do a backup of my original array archive in supportarchive, then i empty the original one and if the condition is meeted i push the element of my supportarchive into my original one archive but it doesn't work and i don't know why