refactoring search, filtering, selection, fix #225 #227 #224

This commit is contained in:
lesion
2023-01-09 17:02:15 +01:00
parent 901c11e6cc
commit 0891acce1d
9 changed files with 187 additions and 102 deletions

View File

@@ -125,9 +125,14 @@ export default {
return matches
}
},
mounted () {
this.$nextTick( () => {
this.search()
})
},
methods: {
search: debounce(async function(ev) {
const search = ev.target.value.trim().toLowerCase()
const search = ev ? ev.target.value.trim().toLowerCase() : ''
this.places = await this.$axios.$get(`place?search=${search}`)
if (!search && this.places.length) { return this.places }
const matches = this.places.find(p => search === p.name.toLocaleLowerCase())