@eeacms/volto-arcgis-block 0.1.368 → 0.1.370

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,16 @@ 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.370](https://github.com/eea/volto-arcgis-block/compare/0.1.369...0.1.370) - 19 June 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-287480 (bug): Implement the regrouping of layers when REST services exist [Unai Bolivar - [`0e9ed21`](https://github.com/eea/volto-arcgis-block/commit/0e9ed218e0fbe691773220afd7cbd4f2a948c33d)]
12
+ ### [0.1.369](https://github.com/eea/volto-arcgis-block/compare/0.1.368...0.1.369) - 18 June 2025
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - Merge pull request #978 from eea/develop [Unai Bolivar - [`32cddf9`](https://github.com/eea/volto-arcgis-block/commit/32cddf9f880a50082094cf73e10316848555d792)]
7
17
  ### [0.1.368](https://github.com/eea/volto-arcgis-block/compare/0.1.367...0.1.368) - 17 June 2025
8
18
 
9
19
  ### [0.1.367](https://github.com/eea/volto-arcgis-block/compare/0.1.366...0.1.367) - 17 June 2025
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.368",
3
+ "version": "0.1.370",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -27,7 +27,6 @@ class BookmarkWidget extends React.Component {
27
27
  this.menuClass =
28
28
  'esri-icon-bookmark esri-widget--button esri-widget esri-interactive';
29
29
  this.sessionBookmarks = [];
30
- this.sessionBookmarkIndexLinkUid = [];
31
30
  this.sessionBookmarkLayers = [];
32
31
  this.sessionBookmarkOpacity = [];
33
32
  this.sessionBookmarkVisible = [];
@@ -93,6 +92,72 @@ class BookmarkWidget extends React.Component {
93
92
  }
94
93
  }
95
94
 
95
+ processReorder(newOrder) {
96
+ const oldBookmarks = this.sessionBookmarks;
97
+ const reorderedBookmarks = newOrder.map((uid) => {
98
+ const index = oldBookmarks.findIndex(
99
+ (bookmark) => bookmark && bookmark.uid === uid,
100
+ );
101
+ return index !== -1 ? oldBookmarks[index] : null;
102
+ });
103
+
104
+ const hasEqualLength =
105
+ oldBookmarks.length === newOrder.length &&
106
+ newOrder.length === reorderedBookmarks.length;
107
+ const hasNullValues = reorderedBookmarks.some((item) => item === null);
108
+
109
+ if (hasEqualLength && !hasNullValues) {
110
+ return reorderedBookmarks;
111
+ }
112
+
113
+ let missingBookmark = null;
114
+ let missingIndex = -1;
115
+
116
+ for (let i = 0; i < oldBookmarks.length; i++) {
117
+ const oldBookmark = oldBookmarks[i];
118
+ const newUid = i < newOrder.length ? newOrder[i] : null;
119
+
120
+ if (
121
+ oldBookmark &&
122
+ newUid &&
123
+ oldBookmark.uid === newUid &&
124
+ !reorderedBookmarks.includes(oldBookmark)
125
+ ) {
126
+ missingBookmark = oldBookmark;
127
+ missingIndex = i;
128
+ break;
129
+ }
130
+ }
131
+
132
+ if (missingBookmark && missingIndex !== -1) {
133
+ if (reorderedBookmarks.length !== oldBookmarks.length) {
134
+ const finalBookmarks = [];
135
+ let reorderIndex = 0;
136
+
137
+ for (let i = 0; i < oldBookmarks.length; i++) {
138
+ if (i === missingIndex) {
139
+ finalBookmarks[i] = missingBookmark;
140
+ } else {
141
+ finalBookmarks[i] =
142
+ reorderIndex < reorderedBookmarks.length
143
+ ? reorderedBookmarks[reorderIndex]
144
+ : null;
145
+ reorderIndex++;
146
+ }
147
+ }
148
+ return finalBookmarks;
149
+ } else if (hasNullValues) {
150
+ const nullIndex = reorderedBookmarks.findIndex((item) => item === null);
151
+ if (nullIndex === missingIndex) {
152
+ reorderedBookmarks[nullIndex] = missingBookmark;
153
+ }
154
+ return reorderedBookmarks;
155
+ }
156
+ }
157
+
158
+ return reorderedBookmarks;
159
+ }
160
+
96
161
  async componentDidMount() {
97
162
  this._isMounted = true;
98
163
  await this.loader();
@@ -201,7 +266,6 @@ class BookmarkWidget extends React.Component {
201
266
  }
202
267
  });
203
268
  this.sessionBookmarks.push(e.added[0]);
204
- this.sessionBookmarkIndexLinkUid.push(e.added[0].uid);
205
269
  this.sessionBookmarkLayers.push(check);
206
270
  this.sessionBookmarkOpacity.push(opacity);
207
271
  this.sessionBookmarkVisible.push(visible);
@@ -250,35 +314,37 @@ class BookmarkWidget extends React.Component {
250
314
  }
251
315
  }
252
316
  } else if (e.moved) {
253
- let newSessionBookmarks = [];
254
- let newSessionBookmarkIndexLinkUid = [];
255
- let newSessionBookmarkLayers = [];
256
- let newSessionBookmarkOpacity = [];
257
- let newSessionBookmarkVisible = [];
258
- let newSessionBookmarkHotspot = [];
259
- e.moved.forEach((bookmark) => {
260
- let index = this.sessionBookmarkIndexLinkUid.indexOf(
261
- bookmark.uid,
262
- );
263
- newSessionBookmarks.push(bookmark);
264
- newSessionBookmarkIndexLinkUid.push(bookmark.uid);
265
- newSessionBookmarkLayers.push(this.sessionBookmarkLayers[index]);
266
- newSessionBookmarkOpacity.push(
267
- this.sessionBookmarkOpacity[index],
268
- );
269
- newSessionBookmarkVisible.push(
270
- this.sessionBookmarkVisible[index],
271
- );
272
- newSessionBookmarkHotspot.push(
273
- this.sessionBookmarkHotspot[index],
317
+ const newOrder = e.target?.items.map((bookmark) => bookmark.uid);
318
+ const reorderedBookmarks = this.processReorder(newOrder);
319
+
320
+ const reorderedLayers = [];
321
+ const reorderedOpacity = [];
322
+ const reorderedVisible = [];
323
+ const reorderedHotspot = [];
324
+
325
+ reorderedBookmarks.forEach((bookmark) => {
326
+ const originalIndex = this.sessionBookmarks.findIndex(
327
+ (original) => original && original.uid === bookmark.uid,
274
328
  );
329
+ if (originalIndex !== -1) {
330
+ reorderedLayers.push(this.sessionBookmarkLayers[originalIndex]);
331
+ reorderedOpacity.push(
332
+ this.sessionBookmarkOpacity[originalIndex],
333
+ );
334
+ reorderedVisible.push(
335
+ this.sessionBookmarkVisible[originalIndex],
336
+ );
337
+ reorderedHotspot.push(
338
+ this.sessionBookmarkHotspot[originalIndex],
339
+ );
340
+ }
275
341
  });
276
- this.sessionBookmarks = newSessionBookmarks;
277
- this.sessionBookmarkIndexLinkUid = newSessionBookmarkIndexLinkUid;
278
- this.sessionBookmarkLayers = newSessionBookmarkLayers;
279
- this.sessionBookmarkOpacity = newSessionBookmarkOpacity;
280
- this.sessionBookmarkVisible = newSessionBookmarkVisible;
281
- this.sessionBookmarkHotspot = newSessionBookmarkHotspot;
342
+
343
+ this.sessionBookmarks = reorderedBookmarks;
344
+ this.sessionBookmarkLayers = reorderedLayers;
345
+ this.sessionBookmarkOpacity = reorderedOpacity;
346
+ this.sessionBookmarkVisible = reorderedVisible;
347
+ this.sessionBookmarkHotspot = reorderedHotspot;
282
348
  shouldUpdate = true;
283
349
  }
284
350
  // } else {
@@ -2862,11 +2862,17 @@ class MenuWidget extends React.Component {
2862
2862
  }
2863
2863
  this.visibleLayers[elem.id] = ['fas', 'eye'];
2864
2864
  this.timeLayers[elem.id] = ['far', 'clock'];
2865
+ let layer = this.layers[elem.id];
2866
+ let isMapServer = layer?.url.toLowerCase().endsWith('mapserver')
2867
+ ? true
2868
+ : false;
2865
2869
  if (group) {
2866
- elem.title = this.getLayerTitle(this.layers[elem.id]);
2870
+ elem.title = isMapServer
2871
+ ? this.layers[elem.id].DatasetTitle
2872
+ : this.getLayerTitle(this.layers[elem.id]);
2867
2873
  let groupLayers = this.getGroupLayers(group);
2868
2874
  if (groupLayers.length > 0 && groupLayers[0] in this.activeLayersJSON) {
2869
- elem.hide = true;
2875
+ elem.hide = isMapServer;
2870
2876
  }
2871
2877
  this.activeLayersJSON[elem.id] = this.addActiveLayer(
2872
2878
  elem,
@@ -3757,7 +3763,7 @@ class MenuWidget extends React.Component {
3757
3763
  layer-id={elem.id}
3758
3764
  layer-order={order}
3759
3765
  draggable="true"
3760
- // {...(elem.hide && { style: { display: 'none' } })}
3766
+ {...(elem.hide && { style: { display: 'none' } })}
3761
3767
  onDrop={(e) => this.onDrop(e)}
3762
3768
  onDragOver={(e) => this.onDragOver(e)}
3763
3769
  onDragStart={(e) => this.onDragStart(e)}