Add ICAO even if one find

This commit is contained in:
Keith Paterson 2021-01-27 15:35:10 +01:00
parent bf56736ab9
commit 9f6a9a0943

View File

@ -36,7 +36,7 @@
}, },
methods: { methods: {
goto (icao) { goto (icao) {
console.log(icao) console.debug('Goto : ' + icao)
let airports = this.$store.state.Airports.airports let airports = this.$store.state.Airports.airports
.filter(a => a.properties.icao.match(icao)) .filter(a => a.properties.icao.match(icao))
if (airports.length > 0) { if (airports.length > 0) {
@ -126,7 +126,7 @@
}, },
computed: { computed: {
searched: function () { searched: function () {
console.log(this.searchterm) console.debug('Search : ' + this.searchterm)
if (this.searchterm !== this.lastSearchTerm) { if (this.searchterm !== this.lastSearchTerm) {
let searchRegex = new RegExp(this.searchterm, 'i') let searchRegex = new RegExp(this.searchterm, 'i')
let result = this.$store.state.Airports.airports let result = this.$store.state.Airports.airports
@ -136,10 +136,12 @@
.filter(a => searchRegex.test(a.properties.icao) || searchRegex.test(a.properties.name)) .filter(a => searchRegex.test(a.properties.icao) || searchRegex.test(a.properties.name))
// .map(a => console.log(a.properties)) // .map(a => console.log(a.properties))
.map(a => ({ icao: a.properties.icao, name: a.properties.name })) .map(a => ({ icao: a.properties.icao, name: a.properties.name }))
let icaoResult = result.filter(a => a.icao === this.searchterm)
if (result !== undefined && if (result !== undefined &&
result.length === 0 && icaoResult.length === 0 &&
this.searchterm !== undefined && this.searchterm !== undefined &&
this.searchterm.length >= 3) { this.searchterm.length >= 3 &&
this.searchterm.length <= 4) {
this.$store.dispatch('getAirport', this.searchterm) this.$store.dispatch('getAirport', this.searchterm)
} }
this.lastResult = result this.lastResult = result