|
|
|
|
@ -48,34 +48,18 @@ export default {
|
|
|
|
|
.then(data => this.items = data)
|
|
|
|
|
.catch((e) => console.log(e))
|
|
|
|
|
},
|
|
|
|
|
fetchFiltered(filter) {
|
|
|
|
|
const baseURL = "http://localhost:8080/api/v1";
|
|
|
|
|
|
|
|
|
|
// request options
|
|
|
|
|
const options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: JSON.stringify(filter),
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fetch(`${baseURL}/detailed_search/?limit=10000`, options)
|
|
|
|
|
.then(res => res.json())
|
|
|
|
|
.then(data => this.items = data)
|
|
|
|
|
.catch((e) => console.log(e))
|
|
|
|
|
},
|
|
|
|
|
applyFilters(filter) {
|
|
|
|
|
let key;
|
|
|
|
|
for (key in filter) {
|
|
|
|
|
for (let key in filter) {
|
|
|
|
|
if (filter[key] != "Any") {
|
|
|
|
|
this.currentFilters[key] = filter[key]
|
|
|
|
|
if (key in this.currentFilters)
|
|
|
|
|
this.currentFilters[key].push(filter[key]);
|
|
|
|
|
else
|
|
|
|
|
this.currentFilters[key] = [filter[key]];
|
|
|
|
|
} else {
|
|
|
|
|
delete this.currentFilters[key]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.fetchFiltered(this.currentFilters);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
|
|
|
|
@ -83,7 +67,14 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
filteredItems() {
|
|
|
|
|
return [...this.items].filter(item => true)
|
|
|
|
|
return [...this.items].filter(item => {
|
|
|
|
|
for (let [filterParam, filterValues] of Object.entries(this.currentFilters)) {
|
|
|
|
|
if (!filterValues.includes(item[filterParam])){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
filteredAndSearchedItems(){
|
|
|
|
|
return this.filteredItems.filter(item => {
|
|
|
|
|
|