Single ICAO search

This commit is contained in:
portree_kid
2020-03-06 15:29:46 +01:00
parent ae680eb994
commit 9eb92fb13d
2 changed files with 24 additions and 2 deletions
+11 -1
View File
@@ -128,10 +128,20 @@
searched: function () {
console.log(this.searchterm)
let searchRegex = new RegExp(this.searchterm, 'i')
return this.$store.state.Airports.airports
let result = this.$store.state.Airports.airports
.filter(point => point.geometry !== undefined)
.filter(point => point.geometry.coordinates !== undefined)
.filter(a => a.properties !== undefined)
.filter(a => searchRegex.test(a.properties.icao) || searchRegex.test(a.properties.name))
// .map(a => console.log(a.properties))
.map(a => ({ icao: a.properties.icao, name: a.properties.name }))
if (result !== undefined &&
result.length === 0 &&
this.searchterm !== undefined &&
this.searchterm.length >= 3) {
this.$store.dispatch('getAirport', this.searchterm)
}
return result
}
}
}