@eeacms/volto-arcgis-block 0.1.367 → 0.1.369

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.369](https://github.com/eea/volto-arcgis-block/compare/0.1.368...0.1.369) - 18 June 2025
8
+
9
+ ### [0.1.368](https://github.com/eea/volto-arcgis-block/compare/0.1.367...0.1.368) - 17 June 2025
10
+
7
11
  ### [0.1.367](https://github.com/eea/volto-arcgis-block/compare/0.1.366...0.1.367) - 17 June 2025
8
12
 
9
13
  #### :house: Internal changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.367",
3
+ "version": "0.1.369",
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 {
@@ -1087,6 +1087,15 @@ class MenuWidget extends React.Component {
1087
1087
  if (productDropdown) {
1088
1088
  let scrollPosition = productDropdown.offsetTop;
1089
1089
  if (dataset) {
1090
+ let familyDropdown = node.closest('.map-menu-family-dropdown');
1091
+ if (familyDropdown) {
1092
+ let button = familyDropdown.querySelector(
1093
+ '.ccl-expandable__button',
1094
+ );
1095
+ if (button) {
1096
+ button.setAttribute('aria-expanded', 'true');
1097
+ }
1098
+ }
1090
1099
  let datasetDropdown = node.closest('.map-menu-product-dropdown');
1091
1100
  if (datasetDropdown) {
1092
1101
  let button = datasetDropdown.querySelector(
@@ -1402,13 +1411,14 @@ class MenuWidget extends React.Component {
1402
1411
  );
1403
1412
  }
1404
1413
 
1405
- metodProcessFamily(family, familyTitle, inheritedIndex, checkProduct) {
1414
+ metodProcessFamily(family, familyTitle, inheritedIndex, checkFamily) {
1406
1415
  var dataset_def = [];
1407
1416
  var datasets = [];
1408
1417
  var index = 0;
1409
1418
  var familyId = familyTitle.replace(/\s+/g, '');
1410
- var inheritedIndexProduct = inheritedIndex + '_' + familyId;
1411
- checkProduct = 'map_product_' + inheritedIndexProduct;
1419
+ var inheritedIndexFamily = inheritedIndex + '_' + familyId;
1420
+ checkFamily = 'map_family_' + inheritedIndexFamily;
1421
+ var checkProduct = 'map_product_' + inheritedIndex;
1412
1422
  var familyTitleName = '';
1413
1423
  this.tax.tree.forEach((element) => {
1414
1424
  element.children.forEach((element) => {
@@ -1419,38 +1429,23 @@ class MenuWidget extends React.Component {
1419
1429
  });
1420
1430
  if (family && Array.isArray(family)) {
1421
1431
  for (var i in family) {
1422
- // if (this.filtersApplied) {
1423
- // dataset_def = document
1424
- // .querySelector('#' + checkProduct)
1425
- // ?.getAttribute('defcheck');
1426
- // } else if (
1427
- // product.Datasets[i] &&
1428
- // product.Datasets[i].Default_active === true
1429
- // ) {
1430
- // var idDataset = 'map_dataset_' + inheritedIndexProduct + '_' + index;
1431
- // dataset_def.push(idDataset);
1432
- // }
1433
-
1434
- // CLMS-1545
1435
- // if (!product.Datasets[i].MarkAsDownloadableNoServiceToVisualize) {
1436
1432
  if (family[i]) {
1437
1433
  datasets.push(
1438
1434
  this.metodProcessDataset(
1439
1435
  family[i],
1440
1436
  index,
1441
- inheritedIndexProduct,
1442
- checkProduct,
1437
+ inheritedIndex,
1438
+ checkFamily,
1443
1439
  ),
1444
1440
  );
1445
1441
  index++;
1446
1442
  }
1447
- // }
1448
1443
  }
1449
1444
  }
1450
1445
 
1451
1446
  // Empty vector, add the first dataset
1452
1447
  if (!dataset_def.length) {
1453
- var idDatasetB = 'map_dataset_' + inheritedIndexProduct + '_0';
1448
+ var idDatasetB = 'map_dataset_' + inheritedIndexFamily + '_0';
1454
1449
  dataset_def.push(idDatasetB);
1455
1450
  }
1456
1451
  let style = this.props.download ? { display: 'none' } : {};
@@ -1458,13 +1453,13 @@ class MenuWidget extends React.Component {
1458
1453
  return (
1459
1454
  <div
1460
1455
  className="map-menu-family-dropdown"
1461
- id={'family_' + inheritedIndexProduct}
1456
+ id={'family_' + inheritedIndexFamily}
1462
1457
  familyid={familyId}
1463
1458
  key={'a' + familyId}
1464
1459
  >
1465
1460
  <fieldset className="ccl-fieldset" key={'b' + familyId}>
1466
1461
  <div
1467
- id={'dropdown_' + inheritedIndexProduct}
1462
+ id={'dropdown_' + inheritedIndexFamily}
1468
1463
  className="ccl-expandable__button"
1469
1464
  aria-expanded="false"
1470
1465
  key={'c' + familyId}
@@ -1481,7 +1476,8 @@ class MenuWidget extends React.Component {
1481
1476
  <div className="ccl-form-group" key={'e' + familyId}>
1482
1477
  <input
1483
1478
  type="checkbox"
1484
- id={checkProduct}
1479
+ id={checkFamily}
1480
+ parentid={checkProduct}
1485
1481
  name=""
1486
1482
  value="name"
1487
1483
  className="ccl-checkbox ccl-required ccl-form-check-input"
@@ -1493,7 +1489,7 @@ class MenuWidget extends React.Component {
1493
1489
  ></input>
1494
1490
  <label
1495
1491
  className="ccl-form-check-label"
1496
- htmlFor={checkProduct}
1492
+ htmlFor={checkFamily}
1497
1493
  key={'f' + familyId}
1498
1494
  >
1499
1495
  <legend className="ccl-form-legend">
@@ -1517,7 +1513,7 @@ class MenuWidget extends React.Component {
1517
1513
  </div>
1518
1514
  <div
1519
1515
  className="ccl-form map-menu-family-container"
1520
- id={'family_container_' + inheritedIndexProduct}
1516
+ id={'family_container_' + inheritedIndexFamily}
1521
1517
  >
1522
1518
  {datasets}
1523
1519
  </div>
@@ -1875,6 +1871,27 @@ class MenuWidget extends React.Component {
1875
1871
  datasetCheck.checked = trueChecks > 0;
1876
1872
 
1877
1873
  let parentId = datasetCheck.getAttribute('parentid');
1874
+ if (parentId) {
1875
+ if (parentId.includes('map_family')) {
1876
+ this.updateCheckFamily(parentId);
1877
+ } else {
1878
+ this.updateCheckProduct(parentId);
1879
+ }
1880
+ }
1881
+ }
1882
+
1883
+ updateCheckFamily(id) {
1884
+ let familyCheck = document.querySelector('#' + id);
1885
+ if (!familyCheck) return;
1886
+
1887
+ let layerChecks = Array.from(
1888
+ document.querySelectorAll('[parentid="' + id + '"]'),
1889
+ );
1890
+
1891
+ let trueChecks = layerChecks.filter((elem) => elem.checked).length;
1892
+ familyCheck.checked = trueChecks > 0;
1893
+
1894
+ let parentId = familyCheck.getAttribute('parentid');
1878
1895
  if (parentId) {
1879
1896
  this.updateCheckProduct(parentId);
1880
1897
  }