diff --git a/src/components/LocationSelector.vue b/src/components/LocationSelector.vue index ef5b0a867c..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 }}
@@ -46,18 +42,20 @@ -

+

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 d491ef85ae..011d8a151b 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 🔎 -

-

{{ locationSelectedDisplayName }}

- - - - - - - - +

🌍 Location

+
+ + + {{ location.display_name }} + + + Find + + +
+

Select your location

-

📅 Date

+

📅 Date

@@ -181,13 +173,7 @@ export default { }, data() { return { - // proof data - proofImage: null, - proofImagePreview: null, - createProofLoading: false, - proofSuccessMessage: false, - // price data - currencyList: constants.CURRENCY_LIST, + // price form addPriceSingleForm: { proof_id: null, product_code: '', @@ -198,7 +184,17 @@ export default { date: new Date().toISOString().substr(0, 10) }, createPriceLoading: false, + // proof data + proofImage: null, + proofImagePreview: null, + createProofLoading: false, + proofSuccessMessage: false, + // product data barcodeScanner: false, + // price data + currencyList: constants.CURRENCY_LIST, + // location data + recentLocations: api.getRecentLocations(3), locationSelector: false, locationSelectedDisplayName: '' }; @@ -212,6 +208,10 @@ export default { let keys = ['product_code', 'price', 'currency'] return Object.keys(this.addPriceSingleForm).filter(k => 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]) @@ -294,11 +294,21 @@ 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() - } + }, + isSelectedLocation(location) { + return this.locationSelectedDisplayName && this.locationSelectedDisplayName == location.display_name + }, } }