From e2fc6e72b6029bb7856eeb2bb33e144f177c6c06 Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 3 May 2022 18:33:20 +0200 Subject: [PATCH] avoid duplicate places --- pages/add/WhereInput.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pages/add/WhereInput.vue b/pages/add/WhereInput.vue index 84bb3fe0..7b0e7c8f 100644 --- a/pages/add/WhereInput.vue +++ b/pages/add/WhereInput.vue @@ -52,7 +52,7 @@ export default { ...mapState(['places']), filteredPlaces () { if (!this.placeName) { return this.places } - const placeName = this.placeName.toLowerCase() + const placeName = this.placeName.trim().toLowerCase() let nameMatch = false const matches = this.places.filter(p => { const tmpName = p.name.toLowerCase() @@ -73,14 +73,16 @@ export default { selectPlace (p) { if (!p) { return } if (typeof p === 'object' && !p.create) { - this.place.name = p.name + this.place.name = p.name.trim() this.place.address = p.address this.disableAddress = true } else { // this is a new place this.place.name = p.name || p + const tmpPlace = this.place.name.trim().toLowerCase() // search for a place with the same name - const place = this.places.find(p => p.name === this.place.name) + const place = this.places.find(p => p.name.toLowerCase() === tmpPlace) if (place) { + this.place.name = place.name this.place.address = place.address this.disableAddress = true } else {