From 338e6ee04aff3d03cd0611f7d61d17ca3efe5ea0 Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Thu, 19 Oct 2023 14:57:39 +0200 Subject: [PATCH 1/8] refactor: geoUtils.getBounds() simplify method to use array of lat and lng values instead of objects. --- src/support/geo-utils.js | 49 +++++++++++----------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/src/support/geo-utils.js b/src/support/geo-utils.js index 8e487cbf3..06d1da9b6 100644 --- a/src/support/geo-utils.js +++ b/src/support/geo-utils.js @@ -239,49 +239,26 @@ const geoUtils = { * @returns {Array} of 2 objects {lon:..., lat:...} */ getBounds: (places = [], polyline = []) => { - const boundsCollection = [] - let minLat = null - let maxLat = null - let minLng = null - let maxLng = null - - places.forEach((place) => { - boundsCollection.push({ - lat: place.lat, - lng: place.lng - }) - }) - if (Array.isArray(polyline)) { - polyline.forEach((lngLatArr) => { - boundsCollection.push({ - lng: lngLatArr[0], - lat: lngLatArr[1] - }) - }) - } + let latValues = [] + let lngValues = [] - if (places.length === 1 && boundsCollection.length === 1) { - const place = places[0] - minLat = maxLat = place.lat - minLng = maxLng = place.lng - } else { - for (let itemKey in boundsCollection) { - let lngLat = boundsCollection[itemKey] - minLat = minLat === null || lngLat.lat < minLat ? lngLat.lat : minLat - minLng = minLng === null || lngLat.lng < minLng ? lngLat.lng : minLng - maxLat = maxLat === null || lngLat.lat > maxLat ? lngLat.lat : maxLat - maxLng = maxLng === null || lngLat.lng > maxLng ? lngLat.lng : maxLng - } + if (places.length) { + latValues.push(...places.map(p => p.lat)) + lngValues.push(...places.map(p => p.lng)) + } + if (polyline.length) { + latValues.push(...polyline.map(e => e[1])) + lngValues.push(...polyline.map(e => e[0])) } return [ { - lon: minLng, - lat: minLat + lon: lngValues.length ? Math.min(...lngValues) : null, + lat: latValues.length ? Math.min(...latValues) : null }, { - lon: maxLng, - lat: maxLat + lon: lngValues.length ? Math.max(...lngValues) : null, + lat: latValues.length ? Math.max(...latValues) : null } ] }, From e8f886b220f3bc4f4132fae4735df70adaca35fd Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Thu, 19 Oct 2023 15:41:21 +0200 Subject: [PATCH 2/8] refactor: remove unused function routeSummary --- .../components/route-details/route-details.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/route-details.js b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/route-details.js index b8543fa5d..ad9d1d08f 100644 --- a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/route-details.js +++ b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/route-details.js @@ -49,17 +49,6 @@ export default { startedPanelExtended () { return this.localMapViewData.routes.length > 0 ? 0 : null }, - /** - * Builds and return route summary - * @returns {Object} - */ - routeSummary () { - if (this.hasRoutes) { - let summary = Object.assign({}, this.localMapViewData.routes[this.$store.getters.activeRouteIndex].summary) - summary = this.getHumanizedSummary(summary, summary.unit) - return summary - } - }, /** * Builds and return the routes * parsed, with translations and From 0c9325dfd65d1cc4cc39e590ad76e327ae5b7aaa Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Thu, 19 Oct 2023 17:00:56 +0200 Subject: [PATCH 3/8] fix: check for difference in opacity --- src/fragments/map-view/map-view.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fragments/map-view/map-view.js b/src/fragments/map-view/map-view.js index 8c0e1d090..abb3fe411 100644 --- a/src/fragments/map-view/map-view.js +++ b/src/fragments/map-view/map-view.js @@ -694,13 +694,12 @@ export default { clearTimeout(this.mapDataViewChangeDebounceTimeoutId) } this.mapDataViewChangeDebounceTimeoutId = setTimeout(function () { + let changes = Utils.getObjectsDiff(context.localMapViewData, context.mapViewData) // Create a new instance of MapViewData and set all the props into the local instance context.localMapViewData = context.mapViewData.clone() - - let changes = Utils.getObjectsDiff(context.localMapViewData, context.mapViewData) let different = changes.different // Only refresh local data if the change was not only the opacity - if (different.length !== 1 || (different.length === 1 && different[0].indexOf('.opacity') > 0)) { + if (!(different.length === 1 && different[0].indexOf('.opacity') > 0)) { context.loadMapData() context.refreshAltitudeModal() } From 0830c7ad13e2689defaab10de3613f5552bfb54b Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Thu, 19 Oct 2023 17:05:33 +0200 Subject: [PATCH 4/8] fix: keeping active route index for new routes when an alternative route was selected and the routes recalculated, the UI would keep the activeRouteIndex. It is now reset to the first route instead which is the normal route. --- src/fragments/map-view/map-view.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fragments/map-view/map-view.js b/src/fragments/map-view/map-view.js index abb3fe411..786f7bde4 100644 --- a/src/fragments/map-view/map-view.js +++ b/src/fragments/map-view/map-view.js @@ -700,6 +700,7 @@ export default { let different = changes.different // Only refresh local data if the change was not only the opacity if (!(different.length === 1 && different[0].indexOf('.opacity') > 0)) { + context.setActiveRouteIndex(0) context.loadMapData() context.refreshAltitudeModal() } From d8219a5de24d6c667954b99002ceebdd1e931f59 Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Fri, 20 Oct 2023 14:44:26 +0200 Subject: [PATCH 5/8] feat(route-extras): store displayed extra when using alternative routes, the selected extra information was lost when switching the active route. The selected extra is now saved in the store and displayed when the active route changes. --- .../components/extras/route-extras.js | 14 +++++++++++ .../components/extras/route-extras.store.js | 25 +++++++++++++++++++ .../extra-info-highlight.js | 1 + 3 files changed, 40 insertions(+) create mode 100644 src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.store.js diff --git a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.js b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.js index 61d860b1a..f6441428d 100644 --- a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.js +++ b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.js @@ -17,6 +17,18 @@ export default { return this.route.properties.extras || [] } }, + created() { + // get current displayed extras + let {key: extraKey, value: extraValue, index: index} = this.$store.getters.extraHighlight + if (extraKey) { + // does the active route have the specific extraValue? + if (this.routeExtras[extraKey].summary.map(e => e.value).includes(extraValue)) { + this.showSection(extraKey, extraValue, index) + } else { + this.showAllSections(extraKey) + } + } + }, methods: { /** * Determines if a given @@ -112,6 +124,7 @@ export default { * @emits highlightPolylineSections (via EventBus) */ showSection (extraKey, value, index) { + this.$store.commit('extraHighlight', {key: extraKey, value: value, index: index}) const sectionTitle = this.$t('global.' + extraKey).toLowerCase() const color = this.colorValue(extraKey, index) const highlightData = { extraKey, sectionTitle, sections: [{ intervals: [], color }] } @@ -130,6 +143,7 @@ export default { * @emits highlightPolylineSections (via EventBus) */ showAllSections (extraKey) { + this.$store.commit('extraHighlight', {key: extraKey, value: 'all', index: 0}) const sectionTitle = this.$t('global.' + extraKey).toLowerCase() const highlightData = { extraKey: extraKey, sectionTitle, sections: [] } diff --git a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.store.js b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.store.js new file mode 100644 index 000000000..72bdaa5aa --- /dev/null +++ b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/route-extras.store.js @@ -0,0 +1,25 @@ +const state = { + extraHighlight: {} +} + +const getters = { + extraHighlight: state => { + return state.extraHighlight + } +} + +const mutations = { + extraHighlight: (state, extraHighlight) => { + state.extraHighlight = extraHighlight + } +} + +const actions = { +} + +export default { + state, + getters, + mutations, + actions +} diff --git a/src/fragments/map-view/components/extra-info-highlight/extra-info-highlight.js b/src/fragments/map-view/components/extra-info-highlight/extra-info-highlight.js index 784034b80..264fc4290 100644 --- a/src/fragments/map-view/components/extra-info-highlight/extra-info-highlight.js +++ b/src/fragments/map-view/components/extra-info-highlight/extra-info-highlight.js @@ -39,6 +39,7 @@ export default { removeHighlightedSegments () { this.highlightedPolyline = null this.highlightedPolylineSnack = false + this.$store.commit('extraHighlight', {}) this.$emit('closed') }, highlightedSectionStyle (backgroundColor) { From 3c7b9e8ae2dd226401524db75178d6028dccc30d Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Fri, 20 Oct 2023 14:51:52 +0200 Subject: [PATCH 6/8] feat(route-extras): expand extra info section dynamically when switching between alternative routes, the extra info section is now expanded if some extra info is currently displayed on the map. --- .../route-details/components/extras/RouteExtras.vue | 2 +- .../route-details/components/extras/route-extras.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/RouteExtras.vue b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/RouteExtras.vue index 3071845f6..45d24cefa 100644 --- a/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/RouteExtras.vue +++ b/src/fragments/forms/map-form/components/place-and-directions/components/route-details/components/extras/RouteExtras.vue @@ -1,6 +1,6 @@