@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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "4.98.4",
3
+ "version": "4.98.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -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: 'gb', label: 'English' },
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({ preserveViewport: true });
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 { language, originLocation, destinationLocation, unit, method, travelMode, alternatives } = this.state;
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
- return {
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
- return [originInputs, destinationInputs];
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=gb&\\')).toBeVisible();
46
+ expect(screen.getByText('language=en&\\')).toBeVisible();
47
47
  fireEvent.click(screen.getByTitle('Italian'));
48
48
  expect(screen.getByText('language=it&\\')).toBeVisible();
49
49
  });
@@ -900,6 +900,7 @@
900
900
 
901
901
 
902
902
  .flag-gb
903
+ .flag-en
903
904
  .flag-uk
904
905
  background-position 0 92.561983%
905
906