@eeacms/volto-arcgis-block 0.1.183 → 0.1.184

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,11 @@ 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.184](https://github.com/eea/volto-arcgis-block/compare/0.1.183...0.1.184) - 21 August 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-2454 (feat): ESRI Copyright displayed in Area Selection widget when selecting countries [Urkorue - [`e7d060d`](https://github.com/eea/volto-arcgis-block/commit/e7d060dfd8436584e34bc08d67840875b2e3c136)]
7
12
  ### [0.1.183](https://github.com/eea/volto-arcgis-block/compare/0.1.182...0.1.183) - 7 August 2023
8
13
 
9
14
  #### :hammer_and_wrench: Others
package/Jenkinsfile CHANGED
@@ -198,7 +198,7 @@ pipeline {
198
198
  }
199
199
  }
200
200
  }
201
-
201
+ /*
202
202
  stage('SonarQube compare to master') {
203
203
  when {
204
204
  allOf {
@@ -223,7 +223,7 @@ pipeline {
223
223
  }
224
224
  }
225
225
  }
226
-
226
+ */
227
227
  stage('Pull Request') {
228
228
  when {
229
229
  not {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.183",
3
+ "version": "0.1.184",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -259,6 +259,7 @@ class AreaWidget extends React.Component {
259
259
  document.querySelector('.drawRectanglePopup-block').style.display =
260
260
  'block';
261
261
  }
262
+ this.props.view.ui._removeComponents(['attribution']);
262
263
  }
263
264
 
264
265
  /**
@@ -272,6 +273,7 @@ class AreaWidget extends React.Component {
272
273
  });
273
274
  this.props.map.add(this.nutsGroupLayer);
274
275
  this.props.view.on('click', (event) => {
276
+ this.props.view.ui.components = ['attribution'];
275
277
  if (
276
278
  (this.props.mapViewer.activeWidget === this || this.props.download) &&
277
279
  (this.props.mapViewer.activeWidget
@@ -0,0 +1,152 @@
1
+ import React, { createRef } from 'react';
2
+ //import "@arcgis/core/assets/esri/css/main.css";
3
+ //import "./css/ArcgisMap.css";
4
+ import { loadModules } from 'esri-loader';
5
+
6
+ export const BOOKMARK_SESSION_KEY = 'bookmark_session';
7
+
8
+ var Bookmarks;
9
+ class BookmarkWidget extends React.Component {
10
+ /**
11
+ * Creator of the Basemap widget class
12
+ * @param {*} props
13
+ */
14
+ constructor(props) {
15
+ super(props);
16
+ //We create a reference to a DOM element to be mounted
17
+ this.container = createRef();
18
+ //Initially, we set the state of the component to
19
+ //not be showing the basemap panel
20
+ this.state = {
21
+ showMapMenu: false,
22
+ };
23
+ this.mapViewer = this.props.mapViewer;
24
+ this.userID = this.props.userID;
25
+ this.menuClass =
26
+ 'esri-icon-bookmark esri-widget--button esri-widget esri-interactive';
27
+ }
28
+
29
+ loader() {
30
+ return loadModules(['esri/widgets/Bookmarks']).then(([_Bookmarks]) => {
31
+ Bookmarks = _Bookmarks;
32
+ });
33
+ }
34
+ /**
35
+ * Method that will be invoked when the
36
+ * button is clicked. It controls the open
37
+ * and close actions of the component
38
+ */
39
+ openMenu() {
40
+ if (this.state.showMapMenu) {
41
+ this.props.mapViewer.setActiveWidget();
42
+ this.container.current.querySelector('.right-panel').style.display =
43
+ 'none';
44
+ this.container.current
45
+ .querySelector('.esri-widget--button')
46
+ .classList.remove('active-widget');
47
+ document
48
+ .querySelector('.esri-ui-top-right.esri-ui-corner')
49
+ .classList.remove('show-panel');
50
+ // By invoking the setState, we notify the state we want to reach
51
+ // and ensure that the component is rendered again
52
+ this.setState({ showMapMenu: false });
53
+ } else {
54
+ this.props.mapViewer.setActiveWidget(this);
55
+ this.container.current.querySelector('.right-panel').style.display =
56
+ 'flex';
57
+ this.container.current
58
+ .querySelector('.esri-widget--button')
59
+ .classList.add('active-widget');
60
+ document
61
+ .querySelector('.esri-ui-top-right.esri-ui-corner')
62
+ .classList.add('show-panel');
63
+ // By invoking the setState, we notify the state we want to reach
64
+ // and ensure that the component is rendered again
65
+ this.setState({ showMapMenu: true });
66
+ }
67
+ }
68
+ /**
69
+ * This method is executed after the rener method is executed
70
+ */
71
+
72
+ async componentDidMount() {
73
+ await this.loader();
74
+ this.props.view.ui.add(this.container.current, 'top-right');
75
+ let sessionBookmarks = {};
76
+ if (this.userID != null) {
77
+ sessionBookmarks =
78
+ JSON.parse(
79
+ localStorage.getItem(BOOKMARK_SESSION_KEY + '_' + this.userID),
80
+ ) || {};
81
+ }
82
+ this.Bookmarks = new Bookmarks({
83
+ view: this.props.view,
84
+ // allows bookmarks to be added, edited, or deleted
85
+ editingEnabled: true,
86
+ visibleElements: {
87
+ time: false, // don't show the time (h:m:s) next to the date
88
+ },
89
+ container: document.querySelector('.bookmark-panel'),
90
+ bookmarks: sessionBookmarks,
91
+ });
92
+
93
+ this.Bookmarks.when(() => {
94
+ this.Bookmarks.bookmarks.on('change', () => {
95
+ if (this.userID != null) {
96
+ localStorage.setItem(
97
+ BOOKMARK_SESSION_KEY + '_' + this.userID,
98
+ JSON.stringify(this.Bookmarks.bookmarks.items),
99
+ );
100
+ }
101
+ });
102
+ this.Bookmarks.on('bookmark-edit', () => {
103
+ if (this.userID != null) {
104
+ localStorage.setItem(
105
+ BOOKMARK_SESSION_KEY + '_' + this.userID,
106
+ JSON.stringify(this.Bookmarks.bookmarks.items),
107
+ );
108
+ }
109
+ });
110
+ });
111
+ }
112
+ /**
113
+ * This method renders the component
114
+ * @returns jsx
115
+ */
116
+ render() {
117
+ return (
118
+ <>
119
+ <div ref={this.container} className="legend-container">
120
+ <div tooltip="Bookmark" direction="left" type="widget">
121
+ <div
122
+ className={this.menuClass}
123
+ id="legend_button"
124
+ aria-label="Bookmark"
125
+ onClick={this.openMenu.bind(this)}
126
+ onKeyDown={this.openMenu.bind(this)}
127
+ tabIndex="0"
128
+ role="button"
129
+ ></div>
130
+ </div>
131
+ <div className="right-panel">
132
+ <div className="right-panel-header">
133
+ <span>Bookmark</span>
134
+ <span
135
+ className="map-menu-icon esri-icon-close"
136
+ onClick={this.openMenu.bind(this)}
137
+ onKeyDown={this.openMenu.bind(this)}
138
+ tabIndex="0"
139
+ role="button"
140
+ ></span>
141
+ </div>
142
+ <div className="right-panel-content">
143
+ <div className="bookmark-panel"></div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ </>
148
+ );
149
+ }
150
+ }
151
+
152
+ export default BookmarkWidget;
@@ -18,6 +18,7 @@ import InfoWidget from './InfoWidget';
18
18
  import MenuWidget from './MenuWidget';
19
19
  import HotspotWidget from './HotspotWidget';
20
20
  import PanWidget from './PanWidget';
21
+ import BookmarkWidget from './BookmarkWidget';
21
22
  //import "isomorphic-fetch"; <-- Necessary to use fetch?
22
23
  var Map, MapView, Zoom, intl, Basemap, WebTileLayer, Extent;
23
24
  let mapStatus = {};
@@ -55,6 +56,7 @@ class MapViewer extends React.Component {
55
56
  this.activeLayersArray = {};
56
57
  this.props.mapviewer_config.loading = true;
57
58
  this.cfgUrls = this.props.cfg.Urls;
59
+ this.userID = null;
58
60
  }
59
61
 
60
62
  activeLayersHandler(newActiveLayers) {
@@ -90,6 +92,7 @@ class MapViewer extends React.Component {
90
92
  'esri/Basemap',
91
93
  'esri/layers/WebTileLayer',
92
94
  'esri/geometry/Extent',
95
+ 'esri/widgets/Bookmarks',
93
96
  ]).then(
94
97
  ([_Map, _MapView, _Zoom, _intl, _Basemap, _WebTileLayer, _Extent]) => {
95
98
  [Map, MapView, Zoom, intl, Basemap, WebTileLayer, Extent] = [
@@ -350,6 +353,10 @@ class MapViewer extends React.Component {
350
353
  ); //call conf
351
354
  }
352
355
 
356
+ renderBookmark() {
357
+ if (this.view) return <CheckUserID reference={this} />;
358
+ }
359
+
353
360
  appLanguage() {
354
361
  return intl && <CheckLanguage />;
355
362
  }
@@ -383,6 +390,7 @@ class MapViewer extends React.Component {
383
390
  {this.renderInfo()}
384
391
  {this.renderHotspot()}
385
392
  {this.renderMenu()}
393
+ {this.renderBookmark()}
386
394
  </div>
387
395
  </div>
388
396
  );
@@ -407,6 +415,36 @@ export const CheckLogin = ({ reference }) => {
407
415
  </>
408
416
  );
409
417
  };
418
+ export const CheckUserID = ({ reference }) => {
419
+ let { user_id, isLoggedIn } = useCartState();
420
+ if (isLoggedIn) {
421
+ return (
422
+ <>
423
+ {
424
+ <BookmarkWidget
425
+ view={reference.view}
426
+ map={reference.map}
427
+ mapViewer={reference}
428
+ userID={user_id}
429
+ />
430
+ }
431
+ </>
432
+ );
433
+ } else {
434
+ return (
435
+ <>
436
+ {
437
+ <BookmarkWidget
438
+ view={reference.view}
439
+ map={reference.map}
440
+ mapViewer={reference}
441
+ userID={null}
442
+ />
443
+ }
444
+ </>
445
+ );
446
+ }
447
+ };
410
448
 
411
449
  export default compose(
412
450
  connect(