From 67a3d62c47f5b8f645cfd7bc49294a4ff33a4d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Odini?= Date: Sun, 23 Jun 2024 12:19:38 +0200 Subject: [PATCH] feat(price add): move location to the proof section (#648) --- src/components/LocationChip.vue | 50 +++++++++++++++++ src/components/LocationInputRow.vue | 19 ++++++- src/components/PriceFooterRow.vue | 4 +- src/components/PriceLocationChip.vue | 46 ---------------- src/components/ProofCard.vue | 4 +- src/components/ProofFooter.vue | 2 + src/components/ProofInputRow.vue | 21 ++++++-- src/services/api.js | 5 +- src/utils.js | 12 ++++- src/views/AddPriceMultiple.vue | 50 ++++------------- src/views/AddPriceSingle.vue | 80 ++++++++++------------------ 11 files changed, 139 insertions(+), 154 deletions(-) create mode 100644 src/components/LocationChip.vue delete mode 100644 src/components/PriceLocationChip.vue diff --git a/src/components/LocationChip.vue b/src/components/LocationChip.vue new file mode 100644 index 0000000000..dd9b82a4d1 --- /dev/null +++ b/src/components/LocationChip.vue @@ -0,0 +1,50 @@ + + + diff --git a/src/components/LocationInputRow.vue b/src/components/LocationInputRow.vue index 2e9a2a1a95..2eb2e57ebe 100644 --- a/src/components/LocationInputRow.vue +++ b/src/components/LocationInputRow.vue @@ -47,22 +47,34 @@ export default { type: Object, default: () => ({ location_osm_id: null, location_osm_type: null }) }, + maxRecentLocations: { + type: Number, + default: 3 + } }, + emits: ['location'], data() { return { locationSelectorDialog: false, + locationObject: null, + loading: false, } }, computed: { ...mapStores(useAppStore), recentLocations() { - return this.appStore.getRecentLocations(3) + return this.appStore.getRecentLocations(this.maxRecentLocations) }, locationFormFilled() { let keys = ['location_osm_id', 'location_osm_type'] return Object.keys(this.locationForm).filter(k => keys.includes(k)).every(k => !!this.locationForm[k]) }, }, + watch: { + locationObject(newLocationObject, oldLocationObject) { // eslint-disable-line no-unused-vars + this.$emit('location', newLocationObject) + } + }, mounted() { this.initLocationForm() }, @@ -83,11 +95,14 @@ export default { }, setLocationData(location) { this.appStore.addRecentLocation(location) + // update locationForm this.locationForm.location_osm_id = utils.getLocationID(location) this.locationForm.location_osm_type = utils.getLocationType(location) + // set locationObject + this.locationObject = location }, isSelectedLocation(location) { - return (this.locationForm.location_osm_id === utils.getLocationID(location)) && (this.locationForm.location_osm_type === utils.getLocationType(location)) + return utils.buildLocationUniqueId(this.locationForm.location_osm_id, this.locationForm.location_osm_type) === utils.getLocationUniqueID(location) }, } } diff --git a/src/components/PriceFooterRow.vue b/src/components/PriceFooterRow.vue index 49b36e7ebe..49d6643b40 100644 --- a/src/components/PriceFooterRow.vue +++ b/src/components/PriceFooterRow.vue @@ -1,7 +1,7 @@