Open abrahamYG opened 5 years ago
Ok, i think this could add more filtering options
const filters = "Korhal,Tarsonis,+City,-Man".split(",")
const inclusionFilters = filters.filter(f=>f.startsWith("+"));
const exclusionFilters = filters.filter(f=>f.startsWith("-"));
const regularFilters = filters.filter(f=>!exclusionFilters.includes(f)&&!inclusionFilters.includes(f))
images.filter(({name})=>{
return regularFilters.reduce((acc,filter)=>{return acc||name.toLowerCase().includes(filter.toLowerCase())},false) &&
exclusionFilters.reduce((acc,filter)=>{return acc&&!name.toLowerCase().includes(filter.toLowerCase().replace("-",""))},true) &&
inclusionFilters.reduce((acc,filter)=>{return acc&&name.toLowerCase().includes(filter.toLowerCase().replace("+",""))},true);
})
/*
returns in cliffs
[
{
"name": "Korhal City Ex2",
"url": "Korhal_City_Ex2.jpg",
"tags": ""
},
{
"name": "TarsonisCityCliff0",
"url": "TarsonisCityCliff0.jpg",
"tags": ""
},
{
"name": "TarsonisCityCliff1",
"url": "TarsonisCityCliff1.jpg",
"tags": ""
}
]
excludes
{name: "Korhal City Manmade", url: "Korhal_City_Manmade.jpg", tags: ""}
*/
https://github.com/TeamAntioch/screference/blob/85b7f8e2c1b0021bbe29069cea398fd5f1372f94/src/components/ImageGallery.vue#L66
Maybe this could be condensed to