@eeacms/volto-arcgis-block 0.1.370 → 0.1.372

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.372](https://github.com/eea/volto-arcgis-block/compare/0.1.371...0.1.372) - 26 June 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - (bug): Fixed crash that occurs when a search is made and the map used after it. [Unai Bolivar - [`83bc494`](https://github.com/eea/volto-arcgis-block/commit/83bc494dfa65e33cf499ca58daf0e1a22bdcdc64)]
12
+ ### [0.1.371](https://github.com/eea/volto-arcgis-block/compare/0.1.370...0.1.371) - 25 June 2025
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - (bug): Fixed families, and fixed active layer elements for rest map image layers [Unai Bolivar - [`9b0018e`](https://github.com/eea/volto-arcgis-block/commit/9b0018ed0f03d272945ce5f0f2bc4e1f581cf917)]
7
17
  ### [0.1.370](https://github.com/eea/volto-arcgis-block/compare/0.1.369...0.1.370) - 19 June 2025
8
18
 
9
19
  #### :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.370",
3
+ "version": "0.1.372",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -434,6 +434,7 @@ class MenuWidget extends React.Component {
434
434
  this.activeLayersToHotspotData = this.activeLayersToHotspotData.bind(this);
435
435
  this.getLimitScale = this.getLimitScale.bind(this);
436
436
  this.handleOpenPopup = this.handleOpenPopup.bind(this);
437
+ this.datasetFamilies = {};
437
438
  this.filtersApplied = false;
438
439
  this.filtersApplied = false;
439
440
  // add zoomend listener to map to show/hide zoom in message
@@ -1263,6 +1264,7 @@ class MenuWidget extends React.Component {
1263
1264
  var dataset_def = [];
1264
1265
  var datasets = [];
1265
1266
  var families = [];
1267
+ this.DatasetFamilies = {};
1266
1268
  var index = 0;
1267
1269
  var inheritedIndexProduct = inheritedIndex + '_' + prodIndex;
1268
1270
  var checkProduct = 'map_product_' + inheritedIndexProduct;
@@ -1272,69 +1274,122 @@ class MenuWidget extends React.Component {
1272
1274
  : product.ProductDescription;
1273
1275
 
1274
1276
  if (product.Datasets && Array.isArray(product.Datasets)) {
1275
- let familiesMap = new Map();
1276
- familiesMap['noFamily'] = [];
1277
- for (let index = 0; index < product.Datasets.length; index++) {
1278
- if (familiesMap[product.Datasets[index].FamilyTitle]) {
1279
- familiesMap[product.Datasets[index].FamilyTitle].push(
1280
- product.Datasets[index],
1281
- );
1282
- } else if (product.Datasets[index].FamilyTitle) {
1283
- familiesMap[product.Datasets[index].FamilyTitle] = [
1284
- product.Datasets[index],
1285
- ];
1277
+ var familyIndex = 0;
1278
+ var firstChildAdded = false;
1279
+ for (
1280
+ let datasetIndex = 0;
1281
+ datasetIndex < product.Datasets.length;
1282
+ datasetIndex++
1283
+ ) {
1284
+ const dataset = product.Datasets[datasetIndex];
1285
+
1286
+ if (dataset.FamilyTitle) {
1287
+ if (!this.DatasetFamilies[dataset.FamilyTitle]) {
1288
+ this.DatasetFamilies[dataset.FamilyTitle] = [];
1289
+ }
1290
+ this.DatasetFamilies[dataset.FamilyTitle].push(dataset);
1286
1291
  } else {
1287
- familiesMap['noFamily'].push(product.Datasets[index]);
1292
+ if (this.filtersApplied) {
1293
+ const defcheckValue = document
1294
+ .querySelector('#' + checkProduct)
1295
+ ?.getAttribute('defcheck');
1296
+ if (defcheckValue) {
1297
+ dataset_def = defcheckValue
1298
+ .split(',')
1299
+ .filter((id) => id.trim() !== '');
1300
+ }
1301
+ } else if (
1302
+ dataset &&
1303
+ dataset.Default_active === true &&
1304
+ !firstChildAdded
1305
+ ) {
1306
+ var idDataset =
1307
+ 'map_dataset_' + inheritedIndexProduct + '_' + index;
1308
+ dataset_def.push(idDataset);
1309
+ firstChildAdded = true;
1310
+ }
1311
+
1312
+ if (dataset) {
1313
+ datasets.push(
1314
+ this.metodProcessDataset(
1315
+ dataset,
1316
+ index,
1317
+ inheritedIndexProduct,
1318
+ checkProduct,
1319
+ ),
1320
+ );
1321
+ index++;
1322
+ }
1288
1323
  }
1289
1324
  }
1290
- for (var j in familiesMap) {
1291
- if (j === 'noFamily') {
1292
- for (var i in familiesMap[j]) {
1293
- if (this.filtersApplied) {
1294
- dataset_def = document
1295
- .querySelector('#' + checkProduct)
1296
- ?.getAttribute('defcheck');
1297
- } else if (
1298
- product.Datasets[i] &&
1299
- product.Datasets[i].Default_active === true
1300
- ) {
1301
- var idDataset =
1302
- 'map_dataset_' + inheritedIndexProduct + '_' + index;
1303
- dataset_def.push(idDataset);
1304
- }
1305
1325
 
1306
- // CLMS-1545
1307
- // if (!product.Datasets[i].MarkAsDownloadableNoServiceToVisualize) {
1308
- if (product.Datasets[i]) {
1309
- datasets.push(
1310
- this.metodProcessDataset(
1311
- product.Datasets[i],
1312
- index,
1313
- inheritedIndexProduct,
1314
- checkProduct,
1315
- ),
1316
- );
1317
- index++;
1318
- }
1319
- // }
1326
+ Object.keys(this.DatasetFamilies).forEach((familyTitle) => {
1327
+ var inheritedIndexFamily = inheritedIndexProduct + '_' + familyIndex;
1328
+ var checkFamily = 'map_family_' + inheritedIndexFamily;
1329
+ var familyDatasets = [];
1330
+ var familyDatasetDef = [];
1331
+
1332
+ this.DatasetFamilies[familyTitle].forEach((dataset) => {
1333
+ if (this.filtersApplied) {
1334
+ familyDatasetDef = document
1335
+ .querySelector('#' + checkFamily)
1336
+ ?.getAttribute('defcheck');
1337
+ } else if (dataset && dataset.Default_active === true) {
1338
+ var idDataset = 'map_dataset_' + inheritedIndexFamily + '_' + index;
1339
+ familyDatasetDef.push(idDataset);
1320
1340
  }
1321
- } else {
1322
- families.push(
1323
- this.metodProcessFamily(
1324
- familiesMap[j],
1325
- j,
1326
- inheritedIndexProduct,
1327
- checkProduct,
1341
+ familyDatasets.push(
1342
+ this.metodProcessDataset(
1343
+ dataset,
1344
+ index,
1345
+ inheritedIndexFamily,
1346
+ checkFamily,
1328
1347
  ),
1329
1348
  );
1349
+ index++;
1350
+ });
1351
+
1352
+ if (familyDatasets.length > 0) {
1353
+ var firstFamilyDatasetId =
1354
+ 'map_dataset_' +
1355
+ inheritedIndexFamily +
1356
+ '_' +
1357
+ (index - familyDatasets.length);
1358
+
1359
+ if (!familyDatasetDef.length) {
1360
+ familyDatasetDef.push(firstFamilyDatasetId);
1361
+ }
1362
+
1363
+ if (!firstChildAdded) {
1364
+ dataset_def.push(checkFamily);
1365
+ firstChildAdded = true;
1366
+ }
1330
1367
  }
1331
- }
1368
+
1369
+ families.push(
1370
+ this.metodProcessFamily(
1371
+ familyTitle,
1372
+ familyDatasets,
1373
+ inheritedIndexFamily,
1374
+ checkFamily,
1375
+ checkProduct,
1376
+ familyDatasetDef,
1377
+ ),
1378
+ );
1379
+
1380
+ familyIndex++;
1381
+ });
1332
1382
  }
1333
1383
 
1334
1384
  // Empty vector, add the first dataset
1335
1385
  if (!dataset_def.length) {
1336
- var idDatasetB = 'map_dataset_' + inheritedIndexProduct + '_0';
1337
- dataset_def.push(idDatasetB);
1386
+ if (families.length > 0) {
1387
+ var firstFamilyId = 'map_family_' + inheritedIndexProduct + '_0';
1388
+ dataset_def.push(firstFamilyId);
1389
+ } else {
1390
+ var idDatasetB = 'map_dataset_' + inheritedIndexProduct + '_0';
1391
+ dataset_def.push(idDatasetB);
1392
+ }
1338
1393
  }
1339
1394
  let style = this.props.download ? { display: 'none' } : {};
1340
1395
 
@@ -1411,15 +1466,18 @@ class MenuWidget extends React.Component {
1411
1466
  );
1412
1467
  }
1413
1468
 
1414
- metodProcessFamily(family, familyTitle, inheritedIndex, checkFamily) {
1415
- var dataset_def = [];
1469
+ metodProcessFamily(
1470
+ familyTitle,
1471
+ familyDatasets,
1472
+ inheritedIndexFamily,
1473
+ checkFamily,
1474
+ checkProduct,
1475
+ familyDatasetDef,
1476
+ ) {
1416
1477
  var datasets = [];
1417
- var index = 0;
1418
1478
  var familyId = familyTitle.replace(/\s+/g, '');
1419
- var inheritedIndexFamily = inheritedIndex + '_' + familyId;
1420
- checkFamily = 'map_family_' + inheritedIndexFamily;
1421
- var checkProduct = 'map_product_' + inheritedIndex;
1422
1479
  var familyTitleName = '';
1480
+
1423
1481
  this.tax.tree.forEach((element) => {
1424
1482
  element.children.forEach((element) => {
1425
1483
  if (element.key === familyTitle) {
@@ -1427,27 +1485,16 @@ class MenuWidget extends React.Component {
1427
1485
  }
1428
1486
  });
1429
1487
  });
1430
- if (family && Array.isArray(family)) {
1431
- for (var i in family) {
1432
- if (family[i]) {
1433
- datasets.push(
1434
- this.metodProcessDataset(
1435
- family[i],
1436
- index,
1437
- inheritedIndex,
1438
- checkFamily,
1439
- ),
1440
- );
1441
- index++;
1442
- }
1443
- }
1444
- }
1445
1488
 
1446
- // Empty vector, add the first dataset
1447
- if (!dataset_def.length) {
1489
+ familyDatasets.forEach((dataset) => {
1490
+ datasets.push(dataset);
1491
+ });
1492
+
1493
+ if (!familyDatasetDef.length && familyDatasets.length > 0) {
1448
1494
  var idDatasetB = 'map_dataset_' + inheritedIndexFamily + '_0';
1449
- dataset_def.push(idDatasetB);
1495
+ familyDatasetDef.push(idDatasetB);
1450
1496
  }
1497
+
1451
1498
  let style = this.props.download ? { display: 'none' } : {};
1452
1499
 
1453
1500
  return (
@@ -1482,9 +1529,9 @@ class MenuWidget extends React.Component {
1482
1529
  value="name"
1483
1530
  className="ccl-checkbox ccl-required ccl-form-check-input"
1484
1531
  key={'h' + familyId}
1485
- defcheck={dataset_def}
1532
+ defcheck={familyDatasetDef}
1486
1533
  onChange={(e) =>
1487
- this.toggleProduct(e.target.checked, checkProduct, e)
1534
+ this.toggleFamily(e.target.checked, checkFamily, e)
1488
1535
  }
1489
1536
  ></input>
1490
1537
  <label
@@ -1493,19 +1540,7 @@ class MenuWidget extends React.Component {
1493
1540
  key={'f' + familyId}
1494
1541
  >
1495
1542
  <legend className="ccl-form-legend">
1496
- {
1497
- /* {description ? (
1498
- <Popup
1499
- trigger={<span>{familyTitle}</span>}
1500
- content={description}
1501
- basic
1502
- className="custom"
1503
- style={{ transform: 'translateX(-4rem)' }}
1504
- />
1505
- ) : (*/
1506
- <span>{familyTitleName}</span>
1507
- /*)} */
1508
- }
1543
+ {<span>{familyTitleName}</span>}
1509
1544
  </legend>
1510
1545
  </label>
1511
1546
  </div>
@@ -2267,7 +2302,6 @@ class MenuWidget extends React.Component {
2267
2302
 
2268
2303
  this.saveCheckedLayer(layerId);
2269
2304
 
2270
- // Update state to include the new layer, which will trigger componentDidUpdate
2271
2305
  this.setState((prevState) => {
2272
2306
  const updatedLayers = [
2273
2307
  ...prevState.wmsUserServiceLayers,
@@ -2867,9 +2901,10 @@ class MenuWidget extends React.Component {
2867
2901
  ? true
2868
2902
  : false;
2869
2903
  if (group) {
2870
- elem.title = isMapServer
2871
- ? this.layers[elem.id].DatasetTitle
2872
- : this.getLayerTitle(this.layers[elem.id]);
2904
+ elem.title =
2905
+ this.layers[elem.id].type === 'map-image'
2906
+ ? this.layers[elem.id].DatasetTitle
2907
+ : this.getLayerTitle(this.layers[elem.id]);
2873
2908
  let groupLayers = this.getGroupLayers(group);
2874
2909
  if (groupLayers.length > 0 && groupLayers[0] in this.activeLayersJSON) {
2875
2910
  elem.hide = isMapServer;
@@ -3146,7 +3181,18 @@ class MenuWidget extends React.Component {
3146
3181
  if (value) {
3147
3182
  for (let i = 0; i < splitdefCheck.length; i++) {
3148
3183
  selector = document.querySelector(`[id="${splitdefCheck[i]}"]`);
3149
- layerChecks.push(selector);
3184
+ if (selector) {
3185
+ const layer = this.layers[splitdefCheck[i]];
3186
+ if (
3187
+ layer?.url?.toLowerCase().includes('/rest/') &&
3188
+ layer?.type === 'map-image'
3189
+ ) {
3190
+ layerChecks.push(selector);
3191
+ break;
3192
+ } else {
3193
+ layerChecks.push(selector);
3194
+ }
3195
+ }
3150
3196
  }
3151
3197
  } else {
3152
3198
  layerChecks = document.querySelectorAll(`[parentid=${id}]`);
@@ -3189,6 +3235,29 @@ class MenuWidget extends React.Component {
3189
3235
  });
3190
3236
  }
3191
3237
 
3238
+ toggleFamily(value, id, element) {
3239
+ let familyDefCheck = element.target.getAttribute('defcheck');
3240
+ let splitdefCheck = familyDefCheck.split(',');
3241
+
3242
+ let datasetChecks = [];
3243
+ let selector = [];
3244
+
3245
+ if (value) {
3246
+ for (let i = 0; i < splitdefCheck.length; i++) {
3247
+ selector = document.querySelector(`[id="${splitdefCheck[i]}"]`);
3248
+ datasetChecks.push(selector);
3249
+ }
3250
+ } else {
3251
+ datasetChecks = document.querySelectorAll(`[parentid=${id}]`);
3252
+ }
3253
+
3254
+ datasetChecks.forEach((element) => {
3255
+ if (element) {
3256
+ element.checked = value;
3257
+ this.toggleDataset(value, element.id, element);
3258
+ }
3259
+ });
3260
+ }
3192
3261
  /**
3193
3262
  * Method to toggle dropdown content (datasets and layers)
3194
3263
  * @param {*} e