@eeacms/volto-arcgis-block 0.1.102 → 0.1.104

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/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [0.1.104](https://github.com/eea/volto-arcgis-block/compare/0.1.103...0.1.104) - 22 February 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-1822 FIX: removed componentDidUpdate life cycle in menuWidget as it was unecessary and was causing the site to crash [ujbolivar - [`a89586b`](https://github.com/eea/volto-arcgis-block/commit/a89586ba6d0a4a5a8aa1251bff6d2f7fc2e7f66a)]
12
+ ### [0.1.103](https://github.com/eea/volto-arcgis-block/compare/0.1.102...0.1.103) - 21 February 2023
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - CLMS-1810 [Amanda Rodriguez - [`5add6fb`](https://github.com/eea/volto-arcgis-block/commit/5add6fb11971f1cf1d8e3023a30076cda9dcce30)]
17
+ - CLMS-1808 [Amanda Rodriguez - [`16093bb`](https://github.com/eea/volto-arcgis-block/commit/16093bb2fbd2d45405cf2725247b8787e70be545)]
7
18
  ### [0.1.102](https://github.com/eea/volto-arcgis-block/compare/0.1.101...0.1.102) - 21 February 2023
8
19
 
9
20
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.102",
3
+ "version": "0.1.104",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -25,7 +25,7 @@ class AreaWidget extends React.Component {
25
25
  //not be showing the basemap panel
26
26
  this.state = {
27
27
  showMapMenu: false,
28
- showInfoPopup: false,
28
+ showInfoPopup: this.props.download ? true : false,
29
29
  infoPopupType: 'area',
30
30
  };
31
31
  this.menuClass =
@@ -181,6 +181,10 @@ class AreaWidget extends React.Component {
181
181
  showInfoPopup: true,
182
182
  infoPopupType: 'download',
183
183
  });
184
+ if (this.props.download) {
185
+ document.querySelector('.drawRectanglePopup-block').style.display =
186
+ 'none';
187
+ }
184
188
  } else if (e.action === 'update') {
185
189
  if (extentGraphic) this.props.view.graphics.remove(extentGraphic);
186
190
  let p = this.props.view.toMap(e);
@@ -218,6 +222,10 @@ class AreaWidget extends React.Component {
218
222
  this.setState({
219
223
  infoPopupType: 'area',
220
224
  });
225
+ if (this.props.download) {
226
+ document.querySelector('.drawRectanglePopup-block').style.display =
227
+ 'block';
228
+ }
221
229
  }
222
230
  /**
223
231
  * This method is executed after the rener method is executed
@@ -264,6 +272,11 @@ class AreaWidget extends React.Component {
264
272
  showInfoPopup: true,
265
273
  infoPopupType: 'download',
266
274
  });
275
+ if (this.props.download) {
276
+ document.querySelector(
277
+ '.drawRectanglePopup-block',
278
+ ).style.display = 'none';
279
+ }
267
280
  }
268
281
  }
269
282
  }
@@ -274,6 +287,16 @@ class AreaWidget extends React.Component {
274
287
  this.props.download
275
288
  ? this.container !== null && this.props.view.ui.add(this.container)
276
289
  : this.props.view.ui.add(this.container.current, 'top-right');
290
+
291
+ var z = document.createElement('div'); // is a node
292
+ z.className = 'drawRectanglePopup-block';
293
+ z.innerHTML =
294
+ '<div class="drawRectanglePopup-content">' +
295
+ '<span class="drawRectanglePopup-icon"><span class="esri-icon-cursor-marquee"></span></span>' +
296
+ '<div class="drawRectanglePopup-text">Select an area of interest to download a dataset</div>' +
297
+ '</div>';
298
+
299
+ this.props.download && this.props.view.ui.add(z, 'top-right');
277
300
  }
278
301
 
279
302
  /**
@@ -415,7 +438,7 @@ class AreaWidget extends React.Component {
415
438
  </div>
416
439
  </div>
417
440
  </div>
418
- {this.state.showInfoPopup && (
441
+ {!this.props.download && this.state.showInfoPopup && (
419
442
  <div className="map-container">
420
443
  <div className="drawRectanglePopup-block">
421
444
  <div className="drawRectanglePopup-content">
@@ -55,21 +55,10 @@ export const AddCartItem = ({
55
55
  area = '';
56
56
  }
57
57
  }
58
- if (download) {
59
- if (area) {
60
- let data = checkCartData(cartData, area);
61
- addCartItem(data).then(() => {
62
- showMessageTimer('Added to cart', 'success', 'Success');
63
- });
64
- } else {
65
- showMessageTimer('Please select an area', 'warning', 'Warning');
66
- }
67
- } else {
68
- let data = checkCartData(cartData, area, dataset);
69
- addCartItem(data).then(() => {
70
- showMessageTimer('Added to cart', 'success', 'Success');
71
- });
72
- }
58
+ let data = checkCartData(cartData, area, dataset);
59
+ addCartItem(data).then(() => {
60
+ showMessageTimer('Added to cart', 'success', 'Success');
61
+ });
73
62
  };
74
63
 
75
64
  const checkCartData = (cartData, area, dataset) => {
@@ -108,6 +97,7 @@ export const AddCartItem = ({
108
97
  mapViewer.view.popup.close();
109
98
  mapViewer.view.graphics.removeAll();
110
99
  props.updateArea('');
100
+ document.querySelector('.drawRectanglePopup-block').style.display = 'block';
111
101
  };
112
102
 
113
103
  const showMessageTimer = (msg, type, title) => {
@@ -134,9 +124,8 @@ export const AddCartItem = ({
134
124
  return datasetActive ? datasetActive.hasAttribute('time-start') : false;
135
125
  };
136
126
 
137
- let timeData;
138
- if (dataset.IsTimeSeries) {
139
- timeData = checkTimeData(dataset);
127
+ if (!dataset) {
128
+ dataset = cartData[0].Products[0].Datasets[0];
140
129
  }
141
130
 
142
131
  return (
@@ -146,7 +135,25 @@ export const AddCartItem = ({
146
135
  <button
147
136
  id="map_download_add"
148
137
  className="ccl-button ccl-button-green"
149
- onClick={() => checkArea()}
138
+ onClick={(e) => {
139
+ if (dataset.IsTimeSeries && !checkTimeData(dataset)) {
140
+ document.getElementById('active_label').click();
141
+ if (!document.querySelector('.timeslider-container')) {
142
+ let layerId = document
143
+ .querySelector(
144
+ '[datasetid="' + dataset.DatasetId + '"] input',
145
+ )
146
+ .getAttribute('defcheck');
147
+ document
148
+ .querySelector(
149
+ "[layer-id='" + layerId + "'] .active-layer-time",
150
+ )
151
+ .click(e);
152
+ }
153
+ } else if (areaData) {
154
+ checkArea(e);
155
+ }
156
+ }}
150
157
  >
151
158
  Add to cart
152
159
  </button>
@@ -167,7 +174,7 @@ export const AddCartItem = ({
167
174
  (isLoggedIn ? ' logged' : '')
168
175
  }
169
176
  onClick={(e) => {
170
- if (dataset.IsTimeSeries && !timeData) {
177
+ if (dataset.IsTimeSeries && !checkTimeData(dataset)) {
171
178
  document.getElementById('active_label').click();
172
179
  if (!document.querySelector('.timeslider-container')) {
173
180
  let layerId = document
@@ -195,7 +202,7 @@ export const AddCartItem = ({
195
202
  }
196
203
  }}
197
204
  onKeyDown={(e) => {
198
- if (dataset.IsTimeSeries && !timeData) {
205
+ if (dataset.IsTimeSeries && !checkTimeData(dataset)) {
199
206
  document.getElementById('active_label').click();
200
207
  if (!document.querySelector('.timeslider-container')) {
201
208
  let layerId = document
@@ -436,7 +443,13 @@ class MenuWidget extends React.Component {
436
443
  if (this.props.download && this.layers) {
437
444
  let layerid = Object.keys(this.layers)[0];
438
445
 
439
- if (layerid && this.layers[layerid].isTimeSeries) {
446
+ if (
447
+ layerid &&
448
+ this.layers[layerid].isTimeSeries &&
449
+ !this.container.current
450
+ .querySelector('.esri-widget')
451
+ .classList.contains('esri-icon-drag-horizontal')
452
+ ) {
440
453
  // select active on map tab
441
454
  let event = new MouseEvent('click', {
442
455
  view: window,
@@ -448,7 +461,7 @@ class MenuWidget extends React.Component {
448
461
 
449
462
  //open time slider
450
463
  let layerElem = document.getElementById(layerid);
451
- this.showTimeSlider(layerElem);
464
+ this.showTimeSlider(layerElem, true);
452
465
  }
453
466
  }
454
467
  }
@@ -482,33 +495,10 @@ class MenuWidget extends React.Component {
482
495
  this.loadVisibility();
483
496
  }
484
497
 
485
- /**
486
- * Active on map is tab and time slider widget is opened by default if the user selected time slider and is coming back from the EU pass login
487
- */
488
-
489
- componentDidUpdate(prevProps) {
490
- if (this.props !== prevProps) {
491
- let isLoggedIn = document
492
- .querySelector('[defcheck=' + this.props.elem.id + ']')
493
- .parentElement.querySelector('.map-menu-icon-login')
494
- .classList.contains('logged');
495
- if (this.props.sliderIsActive && isLoggedIn) {
496
- let event = new MouseEvent('click', {
497
- view: window,
498
- bubbles: true,
499
- cancelable: false,
500
- });
501
- let el = document.getElementById('active_label');
502
- el.dispatchEvent(event);
503
- this.showTimeSlider();
504
- }
505
- }
506
- }
507
-
508
- setActiveSlider(val) {
509
- if (!sessionStorage.key('sliderIsActive'))
510
- sessionStorage.setItem('sliderIsActive', 'false');
511
- sessionStorage.setItem('sliderIsActive', val);
498
+ setSliderTag(val) {
499
+ if (!sessionStorage.key('timeSliderTag'))
500
+ sessionStorage.setItem('timeSliderTag', 'false');
501
+ sessionStorage.setItem('timeSliderTag', val);
512
502
  }
513
503
 
514
504
  /**
@@ -1400,6 +1390,7 @@ class MenuWidget extends React.Component {
1400
1390
  delete this.timeLayers[elem.id];
1401
1391
  }
1402
1392
  this.updateCheckDataset(parentId);
1393
+ //!this.props.download && this.toggleHotspotWidget();
1403
1394
  this.toggleHotspotWidget();
1404
1395
  this.layersReorder();
1405
1396
  this.checkInfoWidget();
@@ -1423,6 +1414,9 @@ class MenuWidget extends React.Component {
1423
1414
  toggleHotspotWidget() {
1424
1415
  let hotspotButton = document.querySelector('#hotspot_button');
1425
1416
  let checkedLayers = JSON.parse(sessionStorage.getItem('checkedLayers'));
1417
+ if (this.props.download) {
1418
+ checkedLayers = Object.keys(this.activeLayersJSON);
1419
+ }
1426
1420
  checkedLayers.forEach((key) => {
1427
1421
  // if key includes all_present_lc_a_pol or all_lcc_a_pol and if the activeWidget is not the hotspot widget, click on the hotspot button, else close the active widget and set the hotspot container to display to none
1428
1422
  if (
@@ -1883,11 +1877,11 @@ class MenuWidget extends React.Component {
1883
1877
 
1884
1878
  showTimeSlider(elem, fromDownload) {
1885
1879
  if (
1886
- sessionStorage.key('sliderIsActive') &&
1887
- sessionStorage.getItem('sliderIsActive') === 'false'
1880
+ sessionStorage.key('timeSliderTag') &&
1881
+ sessionStorage.getItem('timeSliderTag') === 'false'
1888
1882
  )
1889
- this.setActiveSlider(true);
1890
- else this.setActiveSlider(false);
1883
+ this.setSliderTag(true);
1884
+ else this.setSliderTag(false);
1891
1885
  let activeLayers = document.querySelectorAll('.active-layer');
1892
1886
  let group = this.getGroup(elem);
1893
1887
  let groupLayers = this.getGroupLayers(group);
@@ -28,6 +28,10 @@ class TimesliderWidget extends React.Component {
28
28
  dateStart: this.props.time.start ? new Date(this.props.time.start) : null,
29
29
  dateEnd: this.props.time.end ? new Date(this.props.time.end) : null,
30
30
  periodicity: null,
31
+ inputStart: this.props.time.start
32
+ ? new Date(this.props.time.start)
33
+ : null,
34
+ inputEnd: this.props.time.end ? new Date(this.props.time.end) : null,
31
35
  };
32
36
  this.map = this.props.map;
33
37
  this.layer = this.props.layer;
@@ -240,7 +244,8 @@ class TimesliderWidget extends React.Component {
240
244
  }
241
245
  this.setState({
242
246
  lockDatePanel: false,
243
- showCalendar: this.props.fromDownload ? true : false,
247
+ showCalendar:
248
+ this.props.fromDownload || this.props.download ? true : false,
244
249
  });
245
250
  }
246
251
  },
@@ -487,30 +492,40 @@ class TimesliderWidget extends React.Component {
487
492
  });
488
493
  }
489
494
 
495
+ handleInputChange(e) {
496
+ if (e.currentTarget.id === 'date_start') {
497
+ this.setState({ inputStart: e.currentTarget.value });
498
+ } else if (e.currentTarget.id === 'date_end') {
499
+ this.setState({ inputEnd: e.currentTarget.value });
500
+ }
501
+ }
502
+
503
+ formatDate(date) {
504
+ return new Date(date).toISOString().split('T')[0].toString();
505
+ }
506
+
490
507
  /**
491
508
  * This method renders the component
492
509
  * @returns jsx
493
510
  */
494
511
  render() {
512
+ let inputStart;
513
+ let inputEnd;
495
514
  let timeStart;
496
515
  let timeEnd;
497
516
  if (this.state.showCalendar) {
498
- timeStart = new Date(
499
- this.state.dateStart
500
- ? this.state.dateStart
517
+ inputStart = this.formatDate(
518
+ this.state.inputStart
519
+ ? this.state.inputStart
501
520
  : this.TimesliderWidget.fullTimeExtent.start,
502
- )
503
- .toISOString()
504
- .split('T')[0]
505
- .toString();
506
- timeEnd = new Date(
507
- this.state.dateEnd
508
- ? this.state.dateEnd
521
+ );
522
+ inputEnd = this.formatDate(
523
+ this.state.inputEnd
524
+ ? this.state.inputEnd
509
525
  : this.TimesliderWidget.fullTimeExtent.end,
510
- )
511
- .toISOString()
512
- .split('T')[0]
513
- .toString();
526
+ );
527
+ timeStart = this.formatDate(this.TimesliderWidget.fullTimeExtent.start);
528
+ timeEnd = this.formatDate(this.TimesliderWidget.fullTimeExtent.end);
514
529
  }
515
530
  return (
516
531
  <>
@@ -529,7 +544,7 @@ class TimesliderWidget extends React.Component {
529
544
  <div className="timeslider-panel"></div>
530
545
  {this.state.showDatePanel && (
531
546
  <div className="timeslider-calendar-button">
532
- {this.props.logged ? (
547
+ {this.props.logged || this.props.download ? (
533
548
  <button
534
549
  onClick={() => {
535
550
  this.showCalendar();
@@ -586,9 +601,14 @@ class TimesliderWidget extends React.Component {
586
601
  <input
587
602
  type="date"
588
603
  id="date_start"
589
- defaultValue={timeStart}
590
604
  min={timeStart}
591
- max={timeEnd}
605
+ max={
606
+ Date.parse(inputEnd) < Date.parse(timeEnd)
607
+ ? inputEnd
608
+ : timeEnd
609
+ }
610
+ value={inputStart}
611
+ onChange={(e) => this.handleInputChange(e)}
592
612
  />
593
613
  </div>
594
614
  <div className="timeslider-calendar-row">
@@ -596,9 +616,14 @@ class TimesliderWidget extends React.Component {
596
616
  <input
597
617
  type="date"
598
618
  id="date_end"
599
- defaultValue={timeEnd}
600
- min={timeStart}
619
+ min={
620
+ Date.parse(inputStart) > Date.parse(timeStart)
621
+ ? inputStart
622
+ : timeStart
623
+ }
601
624
  max={timeEnd}
625
+ value={inputEnd}
626
+ onChange={(e) => this.handleInputChange(e)}
602
627
  />
603
628
  </div>
604
629
  <button
@@ -1224,6 +1224,16 @@ input[type='range']::-ms-track {
1224
1224
  font-size: 0.875rem;
1225
1225
  }
1226
1226
 
1227
+ .esri-component.drawRectanglePopup-block {
1228
+ margin: 0 !important;
1229
+ }
1230
+
1231
+ .esri-component .drawRectanglePopup-content {
1232
+ top: 0;
1233
+ right: -450px;
1234
+ transform: translate(-50vw, 0);
1235
+ }
1236
+
1227
1237
  /* Hotspot*/
1228
1238
  .hotspot-container {
1229
1239
  display: none;