@woosmap/ui 4.98.4 → 4.98.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import React, { Component } from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import cl from 'classnames';
|
|
6
6
|
import polyline from '@mapbox/polyline';
|
|
7
|
+
import Datetime from 'react-datetime';
|
|
7
8
|
import Demo from './SkeletonDemo';
|
|
8
9
|
import Input from '../Input/Input';
|
|
9
10
|
import Constants from '../../Constants';
|
|
@@ -19,7 +20,7 @@ import { createWoosmapMap } from '../Map/drawOnMap';
|
|
|
19
20
|
|
|
20
21
|
const languages = [
|
|
21
22
|
{ value: 'fr', label: 'French' },
|
|
22
|
-
{ value: '
|
|
23
|
+
{ value: 'en', label: 'English' },
|
|
23
24
|
{ value: 'es', label: 'Spanish' },
|
|
24
25
|
{ value: 'it', label: 'Italian' },
|
|
25
26
|
{ value: 'de', label: 'German' },
|
|
@@ -64,6 +65,8 @@ export default class DistanceDemo extends Component {
|
|
|
64
65
|
error: null,
|
|
65
66
|
originLocation: this.defaultOrigin.location,
|
|
66
67
|
destinationLocation: this.defaultDestination.location,
|
|
68
|
+
departureTime: null,
|
|
69
|
+
arrivalTime: null,
|
|
67
70
|
unit: units[0],
|
|
68
71
|
method: methods[0],
|
|
69
72
|
travelMode: travelModes[0],
|
|
@@ -96,7 +99,9 @@ export default class DistanceDemo extends Component {
|
|
|
96
99
|
const { originLocation, destinationLocation, routes } = this.state;
|
|
97
100
|
|
|
98
101
|
if (!this.directionsRenderer) {
|
|
99
|
-
this.directionsRenderer = new window.woosmap.map.DirectionsRenderer({
|
|
102
|
+
this.directionsRenderer = new window.woosmap.map.DirectionsRenderer({
|
|
103
|
+
preserveViewport: true,
|
|
104
|
+
});
|
|
100
105
|
this.directionsRenderer.setMap(this.map);
|
|
101
106
|
}
|
|
102
107
|
|
|
@@ -172,9 +177,19 @@ export default class DistanceDemo extends Component {
|
|
|
172
177
|
};
|
|
173
178
|
|
|
174
179
|
getRequestparams = () => {
|
|
175
|
-
const {
|
|
180
|
+
const {
|
|
181
|
+
language,
|
|
182
|
+
originLocation,
|
|
183
|
+
destinationLocation,
|
|
184
|
+
unit,
|
|
185
|
+
method,
|
|
186
|
+
travelMode,
|
|
187
|
+
alternatives,
|
|
188
|
+
arrivalTime,
|
|
189
|
+
departureTime,
|
|
190
|
+
} = this.state;
|
|
176
191
|
|
|
177
|
-
|
|
192
|
+
const params = {
|
|
178
193
|
key: Constants.woosmapKey,
|
|
179
194
|
origin: `${originLocation.lat},${originLocation.lng}`,
|
|
180
195
|
destination: `${destinationLocation.lat},${destinationLocation.lng}`,
|
|
@@ -184,6 +199,12 @@ export default class DistanceDemo extends Component {
|
|
|
184
199
|
mode: travelMode.value,
|
|
185
200
|
alternatives,
|
|
186
201
|
};
|
|
202
|
+
if (departureTime) {
|
|
203
|
+
params.departure_time = departureTime.unix();
|
|
204
|
+
} else if (arrivalTime) {
|
|
205
|
+
params.arrival_time = arrivalTime.unix();
|
|
206
|
+
}
|
|
207
|
+
return params;
|
|
187
208
|
};
|
|
188
209
|
|
|
189
210
|
renderRoutesSummary = () => {
|
|
@@ -269,7 +290,35 @@ export default class DistanceDemo extends Component {
|
|
|
269
290
|
),
|
|
270
291
|
};
|
|
271
292
|
|
|
272
|
-
|
|
293
|
+
const departureTimeInput = {
|
|
294
|
+
label: tr('Departure Time'),
|
|
295
|
+
component: (
|
|
296
|
+
<>
|
|
297
|
+
<Datetime
|
|
298
|
+
key="dt_departure"
|
|
299
|
+
className="datetime"
|
|
300
|
+
inputProps={{ className: 'input__item' }}
|
|
301
|
+
onChange={(dt) => this.setState({ departureTime: dt, arrivalTime: null }, this.requestDistance)}
|
|
302
|
+
/>
|
|
303
|
+
</>
|
|
304
|
+
),
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const arrivalTimeInput = {
|
|
308
|
+
label: tr('Arrival Time'),
|
|
309
|
+
component: (
|
|
310
|
+
<>
|
|
311
|
+
<Datetime
|
|
312
|
+
key="dt_arrival"
|
|
313
|
+
className="datetime"
|
|
314
|
+
inputProps={{ className: 'input__item' }}
|
|
315
|
+
onChange={(dt) => this.setState({ arrivalTime: dt, departureTime: null }, this.requestDistance)}
|
|
316
|
+
/>
|
|
317
|
+
</>
|
|
318
|
+
),
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
return [originInputs, destinationInputs, departureTimeInput, arrivalTimeInput];
|
|
273
322
|
};
|
|
274
323
|
|
|
275
324
|
renderFooterFilters = () => {
|
|
@@ -43,7 +43,7 @@ it('test method button', () => {
|
|
|
43
43
|
|
|
44
44
|
it('test language button', () => {
|
|
45
45
|
render(<DistanceDemo />);
|
|
46
|
-
expect(screen.getByText('language=
|
|
46
|
+
expect(screen.getByText('language=en&\\')).toBeVisible();
|
|
47
47
|
fireEvent.click(screen.getByTitle('Italian'));
|
|
48
48
|
expect(screen.getByText('language=it&\\')).toBeVisible();
|
|
49
49
|
});
|