@eeacms/volto-arcgis-block 0.1.138 → 0.1.139

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,19 @@ 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.139](https://github.com/eea/volto-arcgis-block/compare/0.1.138...0.1.139) - 9 May 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-1953 (fix): Ran linting scripts [ujbolivar - [`8bc10f2`](https://github.com/eea/volto-arcgis-block/commit/8bc10f2f50b42037dadd4af9e53b055f0f3ad333)]
12
+ - CLMS-1953 (fix): Fixed broken legend images [ujbolivar - [`f794725`](https://github.com/eea/volto-arcgis-block/commit/f7947251ddfe5841074e4ef525317b86c6d4c98c)]
13
+ - CLMS-1984 (fix): getting closer to a solution [ujbolivar - [`c994a5a`](https://github.com/eea/volto-arcgis-block/commit/c994a5ac475edaf23e05e19370f9fd3226f99b7c)]
14
+ - latest update [ujbolivar - [`d758119`](https://github.com/eea/volto-arcgis-block/commit/d758119e12f13854b0969f2feab35cdebb831e76)]
15
+ - latest update still working on it [ujbolivar - [`045321a`](https://github.com/eea/volto-arcgis-block/commit/045321a1bea32934561658ab109f3b391215c3d8)]
16
+ - clms-2051 (fix): still not completed. saving for git pull [ujbolivar - [`c29d59e`](https://github.com/eea/volto-arcgis-block/commit/c29d59e921ffe5999cfd5321c465b6258b2680c3)]
17
+ - 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)]
18
+ - CLMS-1953-CLMS-2051 (bug): final update for the day [ujbolivar - [`0292d4d`](https://github.com/eea/volto-arcgis-block/commit/0292d4d9237074457a00ca153fa873ca6549f666)]
19
+ - 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
20
  ### [0.1.138](https://github.com/eea/volto-arcgis-block/compare/0.1.137...0.1.138) - 9 May 2023
8
21
 
9
22
  #### :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.139",
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,41 @@ 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
+ img.style.display = 'none';
38
+
39
+ let span = document.createElement('span');
40
+ span.innerHTML = 'No legend available';
41
+ element.parentNode.appendChild(span);
42
+ }
43
+ });
44
+ }
45
+
23
46
  loader() {
24
- return loadModules(['esri/widgets/Legend']).then(([_Legend]) => {
47
+ return loadModules([
48
+ 'esri/widgets/Legend',
49
+ 'esri/widgets/Legend/LegendViewModel',
50
+ ]).then(([_Legend, _LegendViewModel]) => {
25
51
  Legend = _Legend;
52
+ LegendViewModel = _LegendViewModel;
26
53
  });
27
54
  }
28
55
 
@@ -60,6 +87,7 @@ class LegendWidget extends React.Component {
60
87
  this.setState({ showMapMenu: true });
61
88
  }
62
89
  }
90
+
63
91
  /**
64
92
  * This method is executed after the rener method is executed
65
93
  */
@@ -68,9 +96,19 @@ class LegendWidget extends React.Component {
68
96
  this.props.view.ui.add(this.container.current, 'top-right');
69
97
  this.LegendWidget = new Legend({
70
98
  view: this.props.view,
99
+ viewModel: new LegendViewModel({
100
+ view: this.props.view,
101
+ }),
71
102
  container: document.querySelector('.legend-panel'),
72
103
  });
104
+
105
+ this.props.view.allLayerViews.watch('length', () => {
106
+ setTimeout(() => {
107
+ this.brokenLegendImagePatch();
108
+ }, 1000);
109
+ });
73
110
  }
111
+
74
112
  /**
75
113
  * This method renders the component
76
114
  * @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() {}
@@ -648,6 +648,25 @@ class MenuWidget extends React.Component {
648
648
  }, 1000);
649
649
  }
650
650
 
651
+ setLegendOpacity = () => {
652
+ const collection = document.getElementsByClassName('esri-legend__symbol');
653
+
654
+ Array.prototype.forEach.call(collection, function (element) {
655
+ let img = {};
656
+
657
+ if (element.hasChildNodes()) {
658
+ img = element.childNodes[0];
659
+ } else {
660
+ img = element;
661
+ }
662
+ // Set Legend opacity back to 1;
663
+ img.setAttribute(
664
+ 'style',
665
+ 'opacity:1; -moz-opacity:1; filter:alpha(opacity=100)',
666
+ );
667
+ });
668
+ };
669
+
651
670
  /**
652
671
  * This method is executed after the render method is executed
653
672
  */
@@ -2682,6 +2701,7 @@ class MenuWidget extends React.Component {
2682
2701
  '.active-layer[layer-id="' + layer + '"] .active-layer-opacity',
2683
2702
  ).dataset.opacity = value;
2684
2703
  // }
2704
+ this.setLegendOpacity();
2685
2705
  }
2686
2706
 
2687
2707
  /**