Skip to content

Commit a44f223

Browse files
committed
cleanup and tsDoc comments
1 parent eb185b9 commit a44f223

File tree

13 files changed

+1429
-1528
lines changed

13 files changed

+1429
-1528
lines changed

package-lock.json

Lines changed: 1133 additions & 1184 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/clients/snowbox/src/addPlugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import ReverseGeocoder from '@polar/plugin-reverse-geocoder'
1616
import Scale from '@polar/plugin-scale'
1717
import Toast from '@polar/plugin-toast'
1818
import Zoom from '@polar/plugin-zoom'
19-
import Routing from '@polar/plugin-routing'
19+
import Routing from '../../../plugins/Routing'
2020

2121
const defaultOptions = {
2222
displayComponent: true,

packages/clients/snowbox/src/mapConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export const mapConfiguration = {
274274
selectablePreferences: [],
275275
displayPreferences: true,
276276
displayRouteTypesToAvoid: true,
277-
style: {
277+
routeStyle: {
278278
stroke: {
279279
color: '#e51313',
280280
width: 6,

packages/plugins/Routing/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ This module has been written for the "BKG-Routing-Service" and uses the "Adresss
1717
|selectable Preferences|string[]|Specifies which preferences for the route are offered to the user.|
1818
|displayPreferences|bolean|Defines wether the preferences for the route are offered to the user for selection.|
1919
|displayRouteTypesToAvoid|boolean|Defines wether route types to avoid are offered to the user for selection.|
20-
|style|||
21-
|style.stroke|||
22-
|style.color|||
23-
|style.width|||
20+
|routeStyle|||
21+
|routeStyle.stroke|||
22+
|routeStyle.color|||
23+
|routeStyle.width|||
2424
|addressSearch|||
2525
|addressSearch.addLoading|||
2626
|addressSearch.removeLoading|||

packages/plugins/Routing/src/components/Routing.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<template #activator="{ on }">
108108
<div v-on="on">
109109
<v-btn
110+
class="sendButton"
110111
:aria-label="$t('common:plugins.routing.sendRequestButton')"
111112
:disabled="areFieldsMissing"
112113
@click="sendRequest"
@@ -420,6 +421,7 @@ export default Vue.extend({
420421
align-items: center;
421422
padding-left: 20px;
422423
padding-right: 20px;
424+
padding-bottom: 20px;
423425
}
424426
.align-center {
425427
text-align: center;
@@ -442,6 +444,9 @@ export default Vue.extend({
442444
gap: 20px;
443445
justify-content: space-evenly;
444446
}
447+
.sendButton {
448+
margin-bottom: 20px;
449+
}
445450
.details-container {
446451
max-height: 300px;
447452
overflow-y: auto; /* enables scrolling */

packages/plugins/Routing/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import { makeStoreModule } from './store'
44
import { Routing } from './components'
55
import language from './language'
66

7+
/**
8+
* A function that dispatches an action to add the routing component to the Vuex store.
9+
*
10+
* This function returns another function that accepts a Vue instance. It dispatches the
11+
* 'addComponent' action to the store with relevant configuration options such as the
12+
* routing plugin, language, and the store module.
13+
*
14+
* @param options - Configuration options for the routing setup, including language and other routing-related settings.
15+
* @returns A function that accepts a Vue instance and dispatches the 'addComponent' action to the Vuex store.
16+
*/
717
export default (options: RoutingConfiguration) => (instance: Vue) => {
818
return instance.$store.dispatch('addComponent', {
919
name: 'routing',

packages/plugins/Routing/src/store/actions.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
2525
* @param contextState - VueX state object.
2626
*/
2727
initializeTool({ rootGetters: { map, configuration }, commit, state }) {
28+
/* setup drawLayer and click event listener */
29+
30+
drawLayer = createDrawLayer(drawSource)
31+
map?.addLayer(drawLayer)
32+
map?.on('click', function (event) {
33+
const clickCoordinate = event.coordinate
34+
if (state.start.length === 0) {
35+
commit('setStart', clickCoordinate)
36+
} else if (
37+
state.end.length === 0 &&
38+
!state.start.every((v, i) => v === clickCoordinate[i]) // end Coordinate should not be the same as start Coordinate
39+
) {
40+
commit('setEnd', clickCoordinate)
41+
}
42+
})
43+
2844
/* update state with configuration settings */
2945

3046
if (configuration?.routing?.selectableTravelModes.length > 0) {
@@ -44,22 +60,6 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
4460
'setDisplayRouteTypesToAvoid',
4561
configuration?.routing?.displayRouteTypesToAvoid
4662
)
47-
48-
/* setup drawLayer and click event listener */
49-
50-
drawLayer = createDrawLayer(drawSource)
51-
map?.addLayer(drawLayer)
52-
map?.on('click', function (event) {
53-
const clickCoordinate = event.coordinate
54-
if (state.start.length === 0) {
55-
commit('setStart', clickCoordinate)
56-
} else if (
57-
state.end.length === 0 &&
58-
!state.start.every((v, i) => v === clickCoordinate[i]) // end Coordinate should not be the same as start Coordinate
59-
) {
60-
commit('setEnd', clickCoordinate)
61-
}
62-
})
6363
},
6464

6565
/* ROUTING REQUEST */
@@ -416,7 +416,7 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
416416
*/
417417
drawRoute({ rootGetters: { configuration }, state }) {
418418
const transformedCoordinates =
419-
state.searchResponseData.features[0].geometry.coordinates.map(
419+
state.searchResponseData?.features[0].geometry.coordinates.map(
420420
(coordinate) => transform(coordinate, 'EPSG:4326', 'EPSG:25832')
421421
)
422422
const routeLineString = new LineString(transformedCoordinates)
@@ -426,8 +426,8 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
426426
})
427427
routeFeature.setStyle(
428428
createDrawStyle(
429-
configuration?.routing?.style?.stroke?.color,
430-
configuration?.routing?.style
429+
configuration?.routing?.routeStyle?.stroke?.color,
430+
configuration?.routing?.routeStyle
431431
)
432432
)
433433
drawSource.addFeature(routeFeature)

packages/plugins/Routing/src/store/getters.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { generateSimpleGetters } from '@repositoryname/vuex-generators'
22
import { getInitialState } from './state'
33

4+
/**
5+
* Defines Vuex getters for the routing module.
6+
*
7+
* - Includes automatically generated simple getters based on the initial state.
8+
* - Provides a custom getter 'renderType', which retrieves the 'renderType'
9+
* from the 'configuration.routing' state in the root Vuex store.
10+
* If not defined, it defaults to 'independent'.
11+
*/
412
const getters = {
513
...generateSimpleGetters(getInitialState()),
614
renderType: (_, __, ___, rootGetters) => {

packages/plugins/Routing/src/store/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import actions from './actions'
55
import getters from './getters'
66
import mutations from './mutations'
77

8+
/**
9+
* Creates and returns a Vuex store module with namespacing enabled.
10+
*
11+
* The module is initialized with a predefined state, actions, getters, and mutations.
12+
*
13+
* @returns A Vuex store module configured with state, actions, getters, and mutations.
14+
*/
815
export const makeStoreModule = () => {
916
const storeModule: PolarModule<RoutingState, RoutingGetters> = {
1017
namespaced: true,

packages/plugins/Routing/src/tests/routing.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import createTestMountParameters, {
55
import { Routing } from '../components/index'
66
import { makeStoreModule } from '../store/index'
77

8+
/**
9+
* Test suite for the 'plugin-routing' module.
10+
*
11+
* This suite includes tests for the Vue component integration and the store functionality
12+
* within the 'plugin-routing' module.
13+
*/
814
describe('plugin-routing', () => {
915
let testParameters: MockParameters
1016

@@ -17,6 +23,9 @@ describe('plugin-routing', () => {
1723
)
1824
})
1925

26+
/**
27+
* Test suite for components within the 'plugin-routing' module.
28+
*/
2029
describe('components', () => {
2130
it('should define all elements', () => {
2231
const wrapper = mount(Routing, { ...testParameters }) // hier wird das mounten des Routing components vorgetäuscht

0 commit comments

Comments
 (0)