@eeacms/volto-arcgis-block 0.1.263 → 0.1.265

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,10 @@ 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.265](https://github.com/eea/volto-arcgis-block/compare/0.1.264...0.1.265) - 13 March 2024
8
+
9
+ ### [0.1.264](https://github.com/eea/volto-arcgis-block/compare/0.1.263...0.1.264) - 11 March 2024
10
+
7
11
  ### [0.1.263](https://github.com/eea/volto-arcgis-block/compare/0.1.262...0.1.263) - 29 February 2024
8
12
 
9
13
  ### [0.1.262](https://github.com/eea/volto-arcgis-block/compare/0.1.261...0.1.262) - 27 February 2024
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.263",
3
+ "version": "0.1.265",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -402,13 +402,7 @@ class AreaWidget extends React.Component {
402
402
  if (graphic) {
403
403
  let geometry = graphic.geometry;
404
404
  if (geometry.type === 'polygon') {
405
- let nuts;
406
- if ('countries'.includes(graphic.layer.id)) {
407
- nuts = graphic.attributes.ISO_2DIGIT;
408
- } else {
409
- nuts = graphic.attributes.NUTS_ID;
410
- }
411
- this.props.updateArea(nuts);
405
+ this.props.updateArea(graphic);
412
406
  let symbol = new SimpleFillSymbol(
413
407
  'solid',
414
408
  new SimpleLineSymbol('solid', new Color([232, 104, 80]), 2),
@@ -449,7 +443,9 @@ class AreaWidget extends React.Component {
449
443
 
450
444
  async initFMI() {
451
445
  let fetchUrl =
452
- window.location.href.replace(window.location.pathname.substring(0), '') +
446
+ window.location.href
447
+ .replace(window.location.pathname.substring(0), '')
448
+ .replace(window.location.search.substring(0), '') +
453
449
  '/++api++/@anon-registry';
454
450
  try {
455
451
  let nutsResponse = await fetch(
@@ -26,6 +26,7 @@ export const AddCartItem = ({
26
26
  download,
27
27
  areaData,
28
28
  dataset,
29
+ handleOpenPopup,
29
30
  }) => {
30
31
  const { addCartItem, isLoggedIn } = useCartState();
31
32
 
@@ -48,7 +49,13 @@ export const AddCartItem = ({
48
49
  } else {
49
50
  if (areaData) {
50
51
  area.type = 'nuts';
51
- area.value = areaData;
52
+ if (areaData.geometry.type === 'polygon') {
53
+ if ('countries'.includes(areaData.layer.id)) {
54
+ area.value = areaData.attributes.ISO_2DIGIT;
55
+ } else {
56
+ area.value = areaData.attributes.NUTS_ID;
57
+ }
58
+ }
52
59
  } else {
53
60
  area = '';
54
61
  }
@@ -67,6 +74,65 @@ export const AddCartItem = ({
67
74
  }
68
75
  });
69
76
  };
77
+ const checkExtent = (e) => {
78
+ let intersection = false;
79
+ let areaExtent = null;
80
+ let check = document.querySelector('.area-panel input:checked').value;
81
+ if (check === 'area') {
82
+ areaExtent = new Extent({
83
+ xmin: Math.min(areaData.end.x, areaData.origin.x),
84
+ xmax: Math.max(areaData.end.x, areaData.origin.x),
85
+ ymin: Math.min(areaData.end.y, areaData.origin.y),
86
+ ymax: Math.max(areaData.end.y, areaData.origin.y),
87
+ });
88
+ } else {
89
+ areaExtent = areaData.geometry;
90
+ }
91
+ if (dataset?.DatasetTitle) {
92
+ Object.keys(props.layers).forEach((id) => {
93
+ if (
94
+ props.layers[id]?.DatasetTitle &&
95
+ dataset.DatasetTitle === props.layers[id].DatasetTitle
96
+ ) {
97
+ let layerExtent = null;
98
+ if (props.layers[id].fullExtent) {
99
+ layerExtent = new Extent({
100
+ xmin: props.layers[id].fullExtent.xmin,
101
+ ymin: props.layers[id].fullExtent.ymin,
102
+ xmax: props.layers[id].fullExtent.xmax,
103
+ ymax: props.layers[id].fullExtent.ymax,
104
+ });
105
+ } else if (
106
+ props.layers[id].fullExtents &&
107
+ props.layers[id].fullExtents[0]
108
+ ) {
109
+ layerExtent = new Extent({
110
+ xmin: props.layers[id].fullExtents[0].xmin,
111
+ ymin: props.layers[id].fullExtents[0].ymin,
112
+ xmax: props.layers[id].fullExtents[0].xmax,
113
+ ymax: props.layers[id].fullExtents[0].ymax,
114
+ });
115
+ } else {
116
+ layerExtent = new Extent({
117
+ xmin: -20037508.342789,
118
+ ymin: -20037508.342789,
119
+ xmax: 20037508.342789,
120
+ ymax: 20037508.342789,
121
+ });
122
+ }
123
+ if (layerExtent.intersects(areaExtent)) {
124
+ intersection = true;
125
+ }
126
+ }
127
+ });
128
+ if (intersection) {
129
+ checkArea();
130
+ } else {
131
+ e.currentTarget.appendChild(document.querySelector('.popup-container'));
132
+ handleOpenPopup();
133
+ }
134
+ }
135
+ };
70
136
 
71
137
  const checkCartData = (cartData, area, dataset) => {
72
138
  if (!dataset) {
@@ -112,7 +178,7 @@ export const AddCartItem = ({
112
178
  document.querySelector('.drawRectanglePopup-block').style
113
179
  .display === 'none'
114
180
  ) {
115
- checkArea(e);
181
+ checkExtent(e);
116
182
  }
117
183
  }
118
184
  }}
@@ -144,7 +210,7 @@ export const AddCartItem = ({
144
210
  document.querySelector('#map_area_button').click();
145
211
  }
146
212
  } else {
147
- checkArea(e);
213
+ checkExtent(e);
148
214
  }
149
215
  }
150
216
  }}
@@ -254,6 +320,7 @@ class MenuWidget extends React.Component {
254
320
  setNoServiceModal: true,
255
321
  TMSLayerObj: null,
256
322
  draggedElements: [],
323
+ popup: false,
257
324
  };
258
325
  this.menuClass =
259
326
  'esri-icon-drag-horizontal esri-widget--button esri-widget esri-interactive';
@@ -269,6 +336,7 @@ class MenuWidget extends React.Component {
269
336
  this.prepareHotspotLayers = this.prepareHotspotLayers.bind(this);
270
337
  this.activeLayersToHotspotData = this.activeLayersToHotspotData.bind(this);
271
338
  this.getLimitScale = this.getLimitScale.bind(this);
339
+ this.handleOpenPopup = this.handleOpenPopup.bind(this);
272
340
  // add zoomend listener to map to show/hide zoom in message
273
341
  this.view.watch('stationary', (isStationary) => {
274
342
  let snowAndIceInSessionStorage = sessionStorage.getItem('snowAndIce');
@@ -1403,6 +1471,7 @@ class MenuWidget extends React.Component {
1403
1471
  download={this.props.download}
1404
1472
  areaData={this.props.area}
1405
1473
  dataset={dataset}
1474
+ handleOpenPopup={this.handleOpenPopup}
1406
1475
  />
1407
1476
  ) : (
1408
1477
  <span
@@ -3758,6 +3827,23 @@ class MenuWidget extends React.Component {
3758
3827
  }, 100);
3759
3828
  }
3760
3829
  }
3830
+ handleOpenPopup = () => {
3831
+ clearTimeout(this.timeout);
3832
+ this.setState({
3833
+ popup: true,
3834
+ });
3835
+
3836
+ this.timeout = setTimeout(() => {
3837
+ this.handleClosePopup();
3838
+ }, 2000);
3839
+ };
3840
+
3841
+ handleClosePopup = () => {
3842
+ this.setState({
3843
+ popup: false,
3844
+ });
3845
+ clearTimeout(this.timeout);
3846
+ };
3761
3847
 
3762
3848
  /**
3763
3849
  * This method renders the component
@@ -3768,6 +3854,15 @@ class MenuWidget extends React.Component {
3768
3854
  <>
3769
3855
  <div ref={this.container} className="map-left-menu-container">
3770
3856
  <div className="map-menu tab-container" id="tabcontainer">
3857
+ <Popup
3858
+ type={'info'}
3859
+ open={this.state.popup}
3860
+ position="right center"
3861
+ trigger={<div className="popup-container"></div>}
3862
+ offset={[0, 20]}
3863
+ >
3864
+ {'No data available on the selected area'}
3865
+ </Popup>
3771
3866
  <div className="tabs" role="tablist">
3772
3867
  <span
3773
3868
  className={!this.props.download ? 'tab tab-selected' : 'tab'}
@@ -3874,6 +3969,7 @@ class MenuWidget extends React.Component {
3874
3969
  mapViewer={this.props.mapViewer}
3875
3970
  download={this.props.download}
3876
3971
  areaData={this.props.area}
3972
+ handleOpenPopup={this.handleOpenPopup}
3877
3973
  />
3878
3974
  </div>
3879
3975
  )}