Skip to content

Commit cd3b171

Browse files
committed
SonarQube fixes + localisation of Route Details
1 parent 3b6ad4b commit cd3b171

File tree

6 files changed

+13
-54
lines changed

6 files changed

+13
-54
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export default Vue.extend({
302302
localKey: 'common:plugins.routing.avoidRoutes.ferries',
303303
},
304304
]
305-
}['']
305+
}
306306
return availableOptions
307307
},
308308
areFieldsMissing() {

packages/plugins/Routing/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue'
2-
import { RoutingConfiguration } from '@polar/lib-custom-types' // TODO: Merken: Wird erst nach mergen des PR aktualisiert
2+
import { RoutingConfiguration } from '@polar/lib-custom-types'
33
import { makeStoreModule } from './store'
44
import { Routing } from './components'
55
import language from './language'

packages/plugins/Routing/src/language.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const language: LanguageOption[] = [
4040
toolTip:
4141
'Pflichtfelder: Startadresse, Zieladresse, Fortbewegungsart und bevorzugte Route.',
4242
routeDetails: 'Details zur Route',
43+
distance: 'Entfernung:',
44+
duration: 'Dauer:',
4345
},
4446
},
4547
},
@@ -82,6 +84,8 @@ const language: LanguageOption[] = [
8284
toolTip:
8385
'Required: Start Address, Destination Address, Travel Mode and Preferred Route.',
8486
routeDetails: 'Route Details',
87+
distance: 'Distance:',
88+
duration: 'Duration:',
8589
},
8690
},
8791
},

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,16 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
215215
* @param responseText - XML response text.
216216
* @returns Parsed house numbers data.
217217
*/
218+
// empty action context is necessary here
219+
// eslint-disable-next-line no-empty-pattern
218220
parseResponseHausnummern({}, responseText) {
219221
try {
220222
const parser = new DOMParser()
221223
const xmlDoc = parser.parseFromString(responseText, 'application/xml')
222224
const members = xmlDoc.getElementsByTagName('wfs:member')
223225
const features: SearchResponseDataInterface[] = []
224226

225-
for (let i = 0; i < members.length; i++) {
226-
const member = members[i]
227+
for (const member of members) {
227228
const hauskoordinaten = member.getElementsByTagName(
228229
'gages:Hauskoordinaten'
229230
)[0]
@@ -282,8 +283,7 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
282283
const members = xmlDoc.getElementsByTagName('wfs:member')
283284
const features: FeatureInterface[] = []
284285

285-
for (let i = 0; i < members.length; i++) {
286-
const member = members[i]
286+
for (const member of members) {
287287
const strasseElement = member.getElementsByTagName('dog:Strassen')[0]
288288

289289
if (strasseElement) {
@@ -307,8 +307,8 @@ const actions: PolarActionTree<RoutingState, RoutingGetters> = {
307307

308308
const hausnummerElements =
309309
strasseElement.getElementsByTagName('dog:hausnummer')
310-
for (let j = 0; j < hausnummerElements.length; j++) {
311-
hausnummern.push(hausnummerElements[j].textContent)
310+
for (const hausnummer of hausnummerElements) {
311+
hausnummern.push(hausnummer.textContent)
312312
}
313313

314314
features.push({

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -130,51 +130,6 @@ describe('plugin-routing', () => {
130130
clickHandler({ coordinate: [20, 60] })
131131
expect(actionContext.commit).toHaveBeenCalledWith('setEnd', [20, 60])
132132
})
133-
/*
134-
it('should not set end point if it matches start point', () => {
135-
let clickHandler
136-
actionContext.rootGetters.map.on = jest.fn((event, handler) => {
137-
if (event === 'click') clickHandler = handler
138-
})
139-
140-
// @ts-ignore
141-
initializeTool(actionContext)
142-
143-
if (!clickHandler) throw new Error('Click handler was not set')
144-
145-
console.error('Initial state:', actionContext.state)
146-
console.error(
147-
'Map event listeners:',
148-
actionContext.rootGetters.map.on.mock.calls
149-
)
150-
console.error('Commits before click:', actionContext.commit.mock.calls)
151-
152-
// Simulate first click (start point)
153-
clickHandler({ coordinate: [10, 50] })
154-
155-
console.error("Commits after first click:", actionContext.commit.mock.calls);
156-
console.error("State after first click:", actionContext.state);
157-
158-
expect(actionContext.commit).toHaveBeenCalledWith(
159-
expect.stringMatching(/setStart/),
160-
expect.arrayContaining([10, 50])
161-
)
162-
163-
// Simulate a second click on the same coordinate
164-
clickHandler({ coordinate: [10, 50] })
165-
expect(actionContext.commit).not.toHaveBeenCalledWith(
166-
'setEnd',
167-
[10, 50]
168-
)
169-
const calls = actionContext.commit.mock.calls.map((call) => call[0])
170-
expect(calls).toEqual([
171-
'setSelectableTravelModes',
172-
'setSelectablePreferences',
173-
'setDisplayPreferences',
174-
'setDisplayRouteTypesToAvoid',
175-
'setStart',
176-
])
177-
}) */
178133
})
179134
describe('resetCoordinates', () => {
180135
const routingStore = makeStoreModule()

packages/plugins/Routing/src/utils/createDrawLayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import VectorLayer from 'ol/layer/Vector'
22
import { Stroke, Style } from 'ol/style'
3-
import { RouteStyle } from '@polar/lib-custom-types' // TODO: routeStyle aus der mapConfig?
3+
import { RouteStyle } from '@polar/lib-custom-types'
44
import { PolarVectorOptions } from '../types'
55

66
/**

0 commit comments

Comments
 (0)