@eeacms/volto-arcgis-block 0.1.138 → 0.1.140

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,26 @@ 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.140](https://github.com/eea/volto-arcgis-block/compare/0.1.139...0.1.140) - 11 May 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-1953 (lint): Sets only one span with text. Can handle layers with no legends [ujbolivar - [`4335250`](https://github.com/eea/volto-arcgis-block/commit/433525063af14ac1e48d9a5bb646127769efb5e2)]
12
+ - CLMS-1953 (lint): Ran linting scripts [ujbolivar - [`b73661d`](https://github.com/eea/volto-arcgis-block/commit/b73661d000cda6629be6dd0b110d5acb96c1e1bf)]
13
+ - CLMS-1953 (chore): cleaned up and took out unecessary functions [ujbolivar - [`60cd5f8`](https://github.com/eea/volto-arcgis-block/commit/60cd5f87f7737bfda0ae801b3acf7627bfe2c182)]
14
+ ### [0.1.139](https://github.com/eea/volto-arcgis-block/compare/0.1.138...0.1.139) - 10 May 2023
15
+
16
+ #### :hammer_and_wrench: Others
17
+
18
+ - CLMS-1953 (fix): Ran linting scripts [ujbolivar - [`8bc10f2`](https://github.com/eea/volto-arcgis-block/commit/8bc10f2f50b42037dadd4af9e53b055f0f3ad333)]
19
+ - CLMS-1953 (fix): Fixed broken legend images [ujbolivar - [`f794725`](https://github.com/eea/volto-arcgis-block/commit/f7947251ddfe5841074e4ef525317b86c6d4c98c)]
20
+ - CLMS-1984 (fix): getting closer to a solution [ujbolivar - [`c994a5a`](https://github.com/eea/volto-arcgis-block/commit/c994a5ac475edaf23e05e19370f9fd3226f99b7c)]
21
+ - latest update [ujbolivar - [`d758119`](https://github.com/eea/volto-arcgis-block/commit/d758119e12f13854b0969f2feab35cdebb831e76)]
22
+ - latest update still working on it [ujbolivar - [`045321a`](https://github.com/eea/volto-arcgis-block/commit/045321a1bea32934561658ab109f3b391215c3d8)]
23
+ - clms-2051 (fix): still not completed. saving for git pull [ujbolivar - [`c29d59e`](https://github.com/eea/volto-arcgis-block/commit/c29d59e921ffe5999cfd5321c465b6258b2680c3)]
24
+ - CLMS-2051 (fix): Monitoring the creation and destruction of layers in the view now possible. Not completed [ujbolivar - [`2bc2a2e`](https://github.com/eea/volto-arcgis-block/commit/2bc2a2e77d5e6ce1be49c5a9d5d0fccb1adfbb3f)]
25
+ - CLMS-1953-CLMS-2051 (bug): final update for the day [ujbolivar - [`0292d4d`](https://github.com/eea/volto-arcgis-block/commit/0292d4d9237074457a00ca153fa873ca6549f666)]
26
+ - CLMS-1953-CLMS-2051 (FIX): Got the legend to update when a new layer is checked. However it is still missing one final update. Not completed. I can monitor the change in opacity slider but not getting through to setting the opacity style of the legend correctly yet. Not completed [ujbolivar - [`f70a51b`](https://github.com/eea/volto-arcgis-block/commit/f70a51bd949f9efa169c46c60f5030980d03f31d)]
7
27
  ### [0.1.138](https://github.com/eea/volto-arcgis-block/compare/0.1.137...0.1.138) - 9 May 2023
8
28
 
9
29
  #### :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.138",
3
+ "version": "0.1.140",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -2,7 +2,7 @@ import React, { createRef } from 'react';
2
2
  //import "@arcgis/core/assets/esri/css/main.css";
3
3
  //import "./css/ArcgisMap.css";
4
4
  import { loadModules } from 'esri-loader';
5
- var Legend;
5
+ var Legend, LegendViewModel;
6
6
 
7
7
  class LegendWidget extends React.Component {
8
8
  /**
@@ -15,14 +15,45 @@ class LegendWidget extends React.Component {
15
15
  this.container = createRef();
16
16
  //Initially, we set the state of the component to
17
17
  //not be showing the basemap panel
18
- this.state = { showMapMenu: false };
18
+ this.state = {
19
+ showMapMenu: false,
20
+ };
21
+ this.mapViewer = this.props.mapViewer;
19
22
  this.menuClass =
20
23
  'esri-icon-legend esri-widget--button esri-widget esri-interactive';
21
24
  }
22
25
 
26
+ brokenLegendImagePatch() {
27
+ const collection = document.getElementsByClassName('esri-legend__symbol');
28
+
29
+ Array.prototype.forEach.call(collection, (element) => {
30
+ let img = {};
31
+
32
+ if (element.hasChildNodes()) img = element.childNodes[0];
33
+ else img = element;
34
+
35
+ // If img src returns a broken link
36
+ if (!(img.complete && img.naturalHeight !== 0)) {
37
+ if (img.style) {
38
+ img.style.display = 'none';
39
+ }
40
+
41
+ if (element.parentNode.querySelector('span')) return;
42
+
43
+ let span = document.createElement('span');
44
+ span.innerHTML = 'No legend available';
45
+ element.parentNode.appendChild(span);
46
+ }
47
+ });
48
+ }
49
+
23
50
  loader() {
24
- return loadModules(['esri/widgets/Legend']).then(([_Legend]) => {
51
+ return loadModules([
52
+ 'esri/widgets/Legend',
53
+ 'esri/widgets/Legend/LegendViewModel',
54
+ ]).then(([_Legend, _LegendViewModel]) => {
25
55
  Legend = _Legend;
56
+ LegendViewModel = _LegendViewModel;
26
57
  });
27
58
  }
28
59
 
@@ -60,6 +91,7 @@ class LegendWidget extends React.Component {
60
91
  this.setState({ showMapMenu: true });
61
92
  }
62
93
  }
94
+
63
95
  /**
64
96
  * This method is executed after the rener method is executed
65
97
  */
@@ -68,9 +100,19 @@ class LegendWidget extends React.Component {
68
100
  this.props.view.ui.add(this.container.current, 'top-right');
69
101
  this.LegendWidget = new Legend({
70
102
  view: this.props.view,
103
+ viewModel: new LegendViewModel({
104
+ view: this.props.view,
105
+ }),
71
106
  container: document.querySelector('.legend-panel'),
72
107
  });
108
+
109
+ this.props.view.allLayerViews.watch('length', () => {
110
+ setTimeout(() => {
111
+ this.brokenLegendImagePatch();
112
+ }, 1000);
113
+ });
73
114
  }
115
+
74
116
  /**
75
117
  * This method renders the component
76
118
  * @returns jsx
@@ -182,7 +182,6 @@ class MapViewer extends React.Component {
182
182
  this.view.watch('zoom', (newValue, oldValue, property, object) => {
183
183
  this.setZoomState(newValue);
184
184
  });
185
-
186
185
  this.view.popup.autoOpenEnabled = false;
187
186
  // After launching the MapViewerConfig action
188
187
  // we will have stored the json response here:
@@ -204,8 +203,6 @@ class MapViewer extends React.Component {
204
203
  this.view.destroy();
205
204
  delete this.view;
206
205
  }
207
- //mapStatus = {};
208
- //sessionStorage.clear();
209
206
  }
210
207
 
211
208
  setWidgetState() {}