From a987fd16f637d2291cd2c82f3926fa4baf778821 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Fri, 22 Dec 2023 18:57:55 +0100 Subject: [PATCH 1/4] Price form: show recent locations as chips --- src/views/AddPriceSingle.vue | 73 +++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/views/AddPriceSingle.vue b/src/views/AddPriceSingle.vue index d491ef85ae..5cd8762e6c 100644 --- a/src/views/AddPriceSingle.vue +++ b/src/views/AddPriceSingle.vue @@ -25,8 +25,8 @@ @click:clear="clearProof" :loading="createProofLoading"> - Proof uploaded! - Proof missing... +

Proof uploaded!

+

Upload a proof

@@ -45,7 +45,7 @@ :style="productPriceFormFilled ? 'border: 1px solid #4CAF50' : 'border: 1px solid transparent'"> -

+

🏷 Product Scan a barcode 🔎

@@ -62,7 +62,7 @@
-

💲 Price

+

💲 Price

-

- 🌍 Location - Find 🔎 -

+

🌍 Location

{{ locationSelectedDisplayName }}

- - - - - - - - +
+ + {{ location.display_name.slice(0, 15) + '...' }} + + + + Find + +
+

Select your location

-

📅 Date

+

📅 Date

keys.includes(k)).every(k => !!this.addPriceSingleForm[k]) }, + locationFormFilled() { + let keys = ['location_osm_id', 'location_osm_type'] + return Object.keys(this.addPriceSingleForm).filter(k => keys.includes(k)).every(k => !!this.addPriceSingleForm[k]) + }, locationDateFormFilled() { let keys = ['location_osm_id', 'location_osm_type', 'date'] return Object.keys(this.addPriceSingleForm).filter(k => keys.includes(k)).every(k => !!this.addPriceSingleForm[k]) @@ -298,7 +297,11 @@ export default { this.locationSelectedDisplayName = event.display_name this.addPriceSingleForm.location_osm_id = event.osm_id this.addPriceSingleForm.location_osm_type = event.osm_type.toUpperCase() - } + }, + selectLocation(location) { + api.addRecentLocation(location) + this.setLocationData(location) + }, } } From ab09947cf24492cd83f6cf56003d25b3cd08b36d Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Fri, 22 Dec 2023 23:04:03 +0100 Subject: [PATCH 2/4] Make recent locations reactive --- src/components/LocationSelector.vue | 16 ++++++++-------- src/services/api.js | 1 - src/views/AddPriceSingle.vue | 23 +++++++++++++++-------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/components/LocationSelector.vue b/src/components/LocationSelector.vue index ef5b0a867c..45a032effa 100644 --- a/src/components/LocationSelector.vue +++ b/src/components/LocationSelector.vue @@ -46,19 +46,19 @@ -

+

+ Recent locations {{ recentLocations.length }} - Clear

-
- + - 📍 {{ location.display_name }} - + @click="selectLocation(location)"> + {{ location.display_name }} +
+ Clear
diff --git a/src/services/api.js b/src/services/api.js index 137ec6dc38..840cb14920 100644 --- a/src/services/api.js +++ b/src/services/api.js @@ -42,7 +42,6 @@ function addObjectToLocalStorageItemArray(itemKey, obj, unshift=false, avoidDupl } - export default { signIn(username, password) { let formData = new FormData() diff --git a/src/views/AddPriceSingle.vue b/src/views/AddPriceSingle.vue index 5cd8762e6c..f5bfe23cc9 100644 --- a/src/views/AddPriceSingle.vue +++ b/src/views/AddPriceSingle.vue @@ -93,12 +93,13 @@

🌍 Location

-

{{ locationSelectedDisplayName }}

- {{ location.display_name.slice(0, 15) + '...' }} + :style="isSelectedLocation(location) ? 'border: 1px solid #4CAF50' : 'border: 1px solid transparent'" + @click="setLocationData(location)"> + + {{ location.display_name }} @@ -146,7 +147,7 @@ v-if="locationSelector" v-model="locationSelector" @location="setLocationData($event)" - @close="locationSelector = false" + @close="closeLocationSelector($event)" > @@ -193,7 +194,7 @@ export default { // price data currencyList: constants.CURRENCY_LIST, // location data - recentLocations: api.getRecentLocations(), + recentLocations: api.getRecentLocations(3), locationSelector: false, locationSelectedDisplayName: '' }; @@ -293,14 +294,20 @@ export default { showLocationSelector() { this.locationSelector = true }, + closeLocationSelector(event) { + this.locationSelector = false + setTimeout(() => { // TODO: replace with store (make recentLocations reactive) + this.recentLocations = api.getRecentLocations(3) + }, 50) + }, setLocationData(event) { + api.addRecentLocation(event) this.locationSelectedDisplayName = event.display_name this.addPriceSingleForm.location_osm_id = event.osm_id this.addPriceSingleForm.location_osm_type = event.osm_type.toUpperCase() }, - selectLocation(location) { - api.addRecentLocation(location) - this.setLocationData(location) + isSelectedLocation(location) { + return this.locationSelectedDisplayName && this.locationSelectedDisplayName == location.display_name }, } } From fa0023fab272d23d0941e675ff74532fad8c586d Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Fri, 22 Dec 2023 23:11:24 +0100 Subject: [PATCH 3/4] Smaller chip for find button --- src/views/AddPriceSingle.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/AddPriceSingle.vue b/src/views/AddPriceSingle.vue index f5bfe23cc9..f90cfeec3e 100644 --- a/src/views/AddPriceSingle.vue +++ b/src/views/AddPriceSingle.vue @@ -101,7 +101,7 @@ {{ location.display_name }} - + Find From d6c5451eb97a234f37eb4e1dbe6f11b551a22a4c Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Fri, 22 Dec 2023 23:48:33 +0100 Subject: [PATCH 4/4] Last changes --- src/components/LocationSelector.vue | 32 ++++++++++++++--------------- src/views/AddPriceSingle.vue | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/components/LocationSelector.vue b/src/components/LocationSelector.vue index 45a032effa..3e23090dd3 100644 --- a/src/components/LocationSelector.vue +++ b/src/components/LocationSelector.vue @@ -10,20 +10,16 @@ - - - - - + + + @@ -31,13 +27,13 @@

Results {{ results.length }}

-
+
- 📍 {{ location.display_name }} + {{ location.display_name }}
@@ -47,7 +43,6 @@

- Recent locations {{ recentLocations.length }}

@@ -55,10 +50,13 @@ v-for="location in recentLocations" elevation="1" @click="selectLocation(location)"> + {{ location.display_name }} + + Clear +
- Clear
diff --git a/src/views/AddPriceSingle.vue b/src/views/AddPriceSingle.vue index f90cfeec3e..011d8a151b 100644 --- a/src/views/AddPriceSingle.vue +++ b/src/views/AddPriceSingle.vue @@ -102,8 +102,8 @@ {{ location.display_name }} - Find +

Select your location