This commit is contained in:
lesion
2022-06-18 01:10:52 +02:00
parent 0cbad08c03
commit 79da979f10

View File

@@ -12,6 +12,7 @@ v-row
@input.native='search'
persistent-hint
:items="places"
@focus='search'
@change='selectPlace')
template(v-slot:item="{ item, attrs, on }")
v-list-item(v-bind='attrs' v-on='on')
@@ -73,7 +74,7 @@ export default {
search: debounce(async function(ev) {
const search = ev.target.value.trim().toLowerCase()
this.places = await this.$axios.$get(`place?search=${search}`)
if (!search) { return this.places }
if (!search && this.places.length) { return this.places }
const matches = this.places.find(p => search === p.name.toLocaleLowerCase())
if (!matches) {
this.places.unshift({ create: true, name: ev.target.value.trim() })