@eeacms/volto-arcgis-block 0.1.392 → 0.1.394

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,8 +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.394](https://github.com/eea/volto-arcgis-block/compare/0.1.393...0.1.394) - 2 October 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - (task): local storage cleanup of bookmarks data in local storage. Persistence for authed users and isolation of bookmark data for all users. [Unai Bolivar - [`5af4c51`](https://github.com/eea/volto-arcgis-block/commit/5af4c5196cc2696b437d563513fb3b78c733a89e)]
12
+ - (task): local storage cleanup of bookmarks data in local storage. [Unai Bolivar - [`ce9ad06`](https://github.com/eea/volto-arcgis-block/commit/ce9ad06db65c96f6fe1a985b3e4962b977bb30de)]
13
+ ### [0.1.393](https://github.com/eea/volto-arcgis-block/compare/0.1.392...0.1.393) - 1 October 2025
14
+
7
15
  ### [0.1.392](https://github.com/eea/volto-arcgis-block/compare/0.1.391...0.1.392) - 25 September 2025
8
16
 
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - Merge pull request #1025 from eea/develop [Unai Bolivar - [`e8ad1fd`](https://github.com/eea/volto-arcgis-block/commit/e8ad1fdd177db59e8265e36609c41ce9a71de2f2)]
9
20
  ### [0.1.391](https://github.com/eea/volto-arcgis-block/compare/0.1.390...0.1.391) - 24 September 2025
10
21
 
11
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.392",
3
+ "version": "0.1.394",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -34,6 +34,7 @@ class BookmarkWidget extends React.Component {
34
34
  this.arcgisEventHandles = [];
35
35
  this.boundLimitMaxLenth = this.limitMaxLenth.bind(this);
36
36
  this._isMounted = false;
37
+ this._skipNextChangePersist = true;
37
38
  }
38
39
 
39
40
  loader() {
@@ -166,52 +167,54 @@ class BookmarkWidget extends React.Component {
166
167
  this.props.view.ui.add(this.container.current, 'top-right');
167
168
  });
168
169
  if (this.userID != null) {
169
- this.sessionBookmarks =
170
- JSON.parse(
171
- localStorage.getItem(BOOKMARK_SESSION_KEY + '_' + this.userID),
172
- ) || [];
173
- this.sessionBookmarkLayers =
174
- JSON.parse(
175
- localStorage.getItem(
176
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
177
- ),
178
- ) || [];
179
- while (this.sessionBookmarkLayers.length < this.sessionBookmarks.length) {
180
- this.sessionBookmarkLayers.push([]);
181
- }
182
- this.sessionBookmarkOpacity =
183
- JSON.parse(
184
- localStorage.getItem(
185
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
186
- ),
187
- ) || [];
188
- while (
189
- this.sessionBookmarkOpacity.length < this.sessionBookmarks.length
190
- ) {
191
- this.sessionBookmarkOpacity.push([]);
192
- }
193
- this.sessionBookmarkVisible =
194
- JSON.parse(
195
- localStorage.getItem(
196
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
197
- ),
198
- ) || [];
199
- while (
200
- this.sessionBookmarkVisible.length < this.sessionBookmarks.length
201
- ) {
202
- this.sessionBookmarkVisible.push([]);
203
- }
204
- this.sessionBookmarkHotspot =
205
- JSON.parse(
206
- localStorage.getItem(
207
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
208
- ),
209
- ) || [];
210
- while (
211
- this.sessionBookmarkHotspot.length < this.sessionBookmarks.length
212
- ) {
213
- this.sessionBookmarkHotspot.push([]);
214
- }
170
+ this.migrateLegacyBookmarksToUserObject();
171
+ // this.sessionBookmarks =
172
+ // JSON.parse(
173
+ // localStorage.getItem(BOOKMARK_SESSION_KEY + '_' + this.userID),
174
+ // ) || [];
175
+ // this.sessionBookmarkLayers =
176
+ // JSON.parse(
177
+ // localStorage.getItem(
178
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
179
+ // ),
180
+ // ) || [];
181
+ // while (this.sessionBookmarkLayers.length < this.sessionBookmarks.length) {
182
+ // this.sessionBookmarkLayers.push([]);
183
+ // }
184
+ // this.sessionBookmarkOpacity =
185
+ // JSON.parse(
186
+ // localStorage.getItem(
187
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
188
+ // ),
189
+ // ) || [];
190
+ // while (
191
+ // this.sessionBookmarkOpacity.length < this.sessionBookmarks.length
192
+ // ) {
193
+ // this.sessionBookmarkOpacity.push([]);
194
+ // }
195
+ // this.sessionBookmarkVisible =
196
+ // JSON.parse(
197
+ // localStorage.getItem(
198
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
199
+ // ),
200
+ // ) || [];
201
+ // while (
202
+ // this.sessionBookmarkVisible.length < this.sessionBookmarks.length
203
+ // ) {
204
+ // this.sessionBookmarkVisible.push([]);
205
+ // }
206
+ // this.sessionBookmarkHotspot =
207
+ // JSON.parse(
208
+ // localStorage.getItem(
209
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
210
+ // ),
211
+ // ) || [];
212
+ // while (
213
+ // this.sessionBookmarkHotspot.length < this.sessionBookmarks.length
214
+ // ) {
215
+ // this.sessionBookmarkHotspot.push([]);
216
+ // }
217
+ this.loadBookmarksToWidget();
215
218
  }
216
219
  this.Bookmarks = new Bookmarks({
217
220
  view: this.props.view,
@@ -392,26 +395,31 @@ class BookmarkWidget extends React.Component {
392
395
  // shouldUpdate = true;
393
396
  // }
394
397
  if (shouldUpdate && this.userID != null) {
395
- localStorage.setItem(
396
- BOOKMARK_SESSION_KEY + '_' + this.userID,
397
- JSON.stringify(this.Bookmarks.bookmarks.items),
398
- );
399
- localStorage.setItem(
400
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
401
- JSON.stringify(this.sessionBookmarkLayers),
402
- );
403
- localStorage.setItem(
404
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
405
- JSON.stringify(this.sessionBookmarkOpacity),
406
- );
407
- localStorage.setItem(
408
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
409
- JSON.stringify(this.sessionBookmarkVisible),
410
- );
411
- localStorage.setItem(
412
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
413
- JSON.stringify(this.sessionBookmarkHotspot),
414
- );
398
+ // localStorage.setItem(
399
+ // BOOKMARK_SESSION_KEY + '_' + this.userID,
400
+ // JSON.stringify(this.Bookmarks.bookmarks.items),
401
+ // );
402
+ // localStorage.setItem(
403
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
404
+ // JSON.stringify(this.sessionBookmarkLayers),
405
+ // );
406
+ // localStorage.setItem(
407
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
408
+ // JSON.stringify(this.sessionBookmarkOpacity),
409
+ // );
410
+ // localStorage.setItem(
411
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
412
+ // JSON.stringify(this.sessionBookmarkVisible),
413
+ // );
414
+ // localStorage.setItem(
415
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
416
+ // JSON.stringify(this.sessionBookmarkHotspot),
417
+ // );
418
+ if (this._skipNextChangePersist) {
419
+ this._skipNextChangePersist = false;
420
+ } else {
421
+ this.saveBookmarksToUserObject();
422
+ }
415
423
  }
416
424
  if (shouldUpdate) {
417
425
  let bookmarkData = {
@@ -481,26 +489,27 @@ class BookmarkWidget extends React.Component {
481
489
  }
482
490
  }
483
491
  if (this.userID != null) {
484
- localStorage.setItem(
485
- BOOKMARK_SESSION_KEY + '_' + this.userID,
486
- JSON.stringify(this.Bookmarks.bookmarks.items),
487
- );
488
- localStorage.setItem(
489
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
490
- JSON.stringify(this.sessionBookmarkLayers),
491
- );
492
- localStorage.setItem(
493
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
494
- JSON.stringify(this.sessionBookmarkOpacity),
495
- );
496
- localStorage.setItem(
497
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
498
- JSON.stringify(this.sessionBookmarkVisible),
499
- );
500
- localStorage.setItem(
501
- BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
502
- JSON.stringify(this.sessionBookmarkHotspot),
503
- );
492
+ // localStorage.setItem(
493
+ // BOOKMARK_SESSION_KEY + '_' + this.userID,
494
+ // JSON.stringify(this.Bookmarks.bookmarks.items),
495
+ // );
496
+ // localStorage.setItem(
497
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
498
+ // JSON.stringify(this.sessionBookmarkLayers),
499
+ // );
500
+ // localStorage.setItem(
501
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
502
+ // JSON.stringify(this.sessionBookmarkOpacity),
503
+ // );
504
+ // localStorage.setItem(
505
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
506
+ // JSON.stringify(this.sessionBookmarkVisible),
507
+ // );
508
+ // localStorage.setItem(
509
+ // BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
510
+ // JSON.stringify(this.sessionBookmarkHotspot),
511
+ // );
512
+ this.saveBookmarksToUserObject();
504
513
  }
505
514
 
506
515
  let bookmarkData = {
@@ -534,6 +543,7 @@ class BookmarkWidget extends React.Component {
534
543
  'bookmarkHotspotFilter',
535
544
  JSON.stringify(this.sessionBookmarkHotspot[index]),
536
545
  );
546
+ this.saveBookmarksToUserObject();
537
547
  }
538
548
  }
539
549
  if (
@@ -622,7 +632,142 @@ class BookmarkWidget extends React.Component {
622
632
  );
623
633
  });
624
634
  }
635
+ migrateLegacyBookmarksToUserObject() {
636
+ if (this.userID == null) return;
637
+ const storageKey = 'user_' + this.userID;
638
+ let userObj;
639
+ try {
640
+ userObj = JSON.parse(localStorage.getItem(storageKey)) || {};
641
+ } catch (e) {
642
+ userObj = {};
643
+ }
644
+ const hasUserBookmarks =
645
+ userObj &&
646
+ userObj.bookmarks &&
647
+ typeof userObj.bookmarks === 'object' &&
648
+ Array.isArray(userObj.bookmarks.items) &&
649
+ userObj.bookmarks.items.length > 0;
650
+ if (hasUserBookmarks) return;
651
+ let legacyItems;
652
+ let legacyLayers;
653
+ let legacyOpacity;
654
+ let legacyVisible;
655
+ let legacyHotspot;
656
+ try {
657
+ legacyItems =
658
+ JSON.parse(
659
+ localStorage.getItem(BOOKMARK_SESSION_KEY + '_' + this.userID),
660
+ ) || [];
661
+ } catch (e) {
662
+ legacyItems = [];
663
+ }
664
+ try {
665
+ legacyLayers =
666
+ JSON.parse(
667
+ localStorage.getItem(
668
+ BOOKMARK_SESSION_KEY + '_' + this.userID + '_layers',
669
+ ),
670
+ ) || [];
671
+ } catch (e) {
672
+ legacyLayers = [];
673
+ }
674
+ try {
675
+ legacyOpacity =
676
+ JSON.parse(
677
+ localStorage.getItem(
678
+ BOOKMARK_SESSION_KEY + '_' + this.userID + '_opacity',
679
+ ),
680
+ ) || [];
681
+ } catch (e) {
682
+ legacyOpacity = [];
683
+ }
684
+ try {
685
+ legacyVisible =
686
+ JSON.parse(
687
+ localStorage.getItem(
688
+ BOOKMARK_SESSION_KEY + '_' + this.userID + '_visible',
689
+ ),
690
+ ) || [];
691
+ } catch (e) {
692
+ legacyVisible = [];
693
+ }
694
+ try {
695
+ legacyHotspot =
696
+ JSON.parse(
697
+ localStorage.getItem(
698
+ BOOKMARK_SESSION_KEY + '_' + this.userID + '_hotspot',
699
+ ),
700
+ ) || [];
701
+ } catch (e) {
702
+ legacyHotspot = [];
703
+ }
704
+ const hasLegacyData =
705
+ (Array.isArray(legacyItems) && legacyItems.length > 0) ||
706
+ (Array.isArray(legacyLayers) && legacyLayers.length > 0) ||
707
+ (Array.isArray(legacyOpacity) && legacyOpacity.length > 0) ||
708
+ (Array.isArray(legacyVisible) && legacyVisible.length > 0) ||
709
+ (Array.isArray(legacyHotspot) && legacyHotspot.length > 0);
710
+ if (!hasLegacyData) return;
711
+ let selectedHotspotFilter = null;
712
+ try {
713
+ selectedHotspotFilter = JSON.parse(
714
+ localStorage.getItem('bookmarkHotspotFilter'),
715
+ );
716
+ } catch (e) {
717
+ selectedHotspotFilter = null;
718
+ }
719
+ if (!userObj.bookmarks || typeof userObj.bookmarks !== 'object') {
720
+ userObj.bookmarks = {};
721
+ }
722
+ userObj.bookmarks.items = legacyItems;
723
+ userObj.bookmarks.layers = legacyLayers;
724
+ userObj.bookmarks.opacity = legacyOpacity;
725
+ userObj.bookmarks.visible = legacyVisible;
726
+ userObj.bookmarks.hotspot = legacyHotspot;
727
+ userObj.bookmarks.selectedHotspotFilter = selectedHotspotFilter;
728
+ localStorage.setItem(storageKey, JSON.stringify(userObj));
729
+ }
625
730
  componentDidUpdate() {
731
+ if (this.userID !== this.props.userID) {
732
+ this.userID = this.props.userID;
733
+ this._skipNextChangePersist = true;
734
+ if (this.Bookmarks && this.Bookmarks.bookmarks) {
735
+ this.Bookmarks.bookmarks.removeAll();
736
+ }
737
+ this.sessionBookmarks = [];
738
+ this.sessionBookmarkLayers = [];
739
+ this.sessionBookmarkOpacity = [];
740
+ this.sessionBookmarkVisible = [];
741
+ this.sessionBookmarkHotspot = [];
742
+ try {
743
+ if (!this.userID) {
744
+ localStorage.removeItem('bookmarkHotspotFilter');
745
+ } else {
746
+ this.loadBookmarksToWidget();
747
+ if (this.Bookmarks && this.Bookmarks.bookmarks) {
748
+ const mapped = this.sessionBookmarks.map((bm) => {
749
+ if (bm && bm.extent) {
750
+ const { extent, ...rest } = bm;
751
+ let geometry;
752
+ if (extent && typeof extent === 'object') {
753
+ geometry = extent.type ? extent : new Extent(extent);
754
+ }
755
+ return {
756
+ ...rest,
757
+ viewpoint: { targetGeometry: geometry },
758
+ };
759
+ }
760
+ return bm;
761
+ });
762
+ mapped.forEach((item) => this.Bookmarks.bookmarks.add(item));
763
+ this.sessionBookmarks = [];
764
+ this.Bookmarks.bookmarks.items.forEach((bookmark) => {
765
+ this.sessionBookmarks.push(bookmark);
766
+ });
767
+ }
768
+ }
769
+ } catch (e) {}
770
+ }
626
771
  this.props.view.when(() => {
627
772
  this.Bookmarks.when(() => {
628
773
  this.Bookmarks.container.addEventListener(
@@ -653,6 +798,95 @@ class BookmarkWidget extends React.Component {
653
798
  );
654
799
  }
655
800
  }
801
+ loadBookmarksToWidget() {
802
+ if (this.userID == null) return;
803
+ const storageKey = 'user_' + this.userID;
804
+ let userObj;
805
+ try {
806
+ userObj = JSON.parse(localStorage.getItem(storageKey)) || {};
807
+ } catch (e) {
808
+ userObj = {};
809
+ }
810
+ let bookmarks =
811
+ userObj && userObj.bookmarks && typeof userObj.bookmarks === 'object'
812
+ ? userObj.bookmarks
813
+ : null;
814
+ if (!bookmarks) return;
815
+ const items = Array.isArray(bookmarks.items) ? bookmarks.items : [];
816
+ const layers = Array.isArray(bookmarks.layers) ? bookmarks.layers : [];
817
+ const opacity = Array.isArray(bookmarks.opacity) ? bookmarks.opacity : [];
818
+ const visible = Array.isArray(bookmarks.visible) ? bookmarks.visible : [];
819
+ const hotspot = Array.isArray(bookmarks.hotspot) ? bookmarks.hotspot : [];
820
+ const selectedHotspotFilter =
821
+ bookmarks.selectedHotspotFilter != null
822
+ ? bookmarks.selectedHotspotFilter
823
+ : null;
824
+ this.sessionBookmarks = items;
825
+ this.sessionBookmarkLayers = layers;
826
+ while (this.sessionBookmarkLayers.length < this.sessionBookmarks.length) {
827
+ this.sessionBookmarkLayers.push([]);
828
+ }
829
+ this.sessionBookmarkOpacity = opacity;
830
+ while (this.sessionBookmarkOpacity.length < this.sessionBookmarks.length) {
831
+ this.sessionBookmarkOpacity.push([]);
832
+ }
833
+ this.sessionBookmarkVisible = visible;
834
+ while (this.sessionBookmarkVisible.length < this.sessionBookmarks.length) {
835
+ this.sessionBookmarkVisible.push([]);
836
+ }
837
+ this.sessionBookmarkHotspot = hotspot;
838
+ while (this.sessionBookmarkHotspot.length < this.sessionBookmarks.length) {
839
+ this.sessionBookmarkHotspot.push([]);
840
+ }
841
+ if (selectedHotspotFilter !== null) {
842
+ localStorage.setItem(
843
+ 'bookmarkHotspotFilter',
844
+ JSON.stringify(selectedHotspotFilter),
845
+ );
846
+ }
847
+ }
848
+ saveBookmarksToUserObject() {
849
+ if (this.userID == null) return;
850
+ const storageKey = 'user_' + this.userID;
851
+ let userObj;
852
+ try {
853
+ userObj = JSON.parse(localStorage.getItem(storageKey)) || {};
854
+ } catch (e) {
855
+ userObj = {};
856
+ }
857
+ const items = this.Bookmarks?.bookmarks?.items
858
+ ? this.Bookmarks.bookmarks.items
859
+ : this.sessionBookmarks;
860
+ const layers = this.sessionBookmarkLayers;
861
+ const opacity = this.sessionBookmarkOpacity;
862
+ const visible = this.sessionBookmarkVisible;
863
+ const hotspot = this.sessionBookmarkHotspot;
864
+ let selectedHotspotFilter = null;
865
+ try {
866
+ selectedHotspotFilter = JSON.parse(
867
+ localStorage.getItem('bookmarkHotspotFilter'),
868
+ );
869
+ } catch (e) {
870
+ selectedHotspotFilter = null;
871
+ }
872
+ if (!userObj.bookmarks || typeof userObj.bookmarks !== 'object') {
873
+ userObj.bookmarks = {};
874
+ }
875
+ const existingItems =
876
+ userObj.bookmarks && Array.isArray(userObj.bookmarks.items)
877
+ ? userObj.bookmarks.items
878
+ : [];
879
+ if ((!items || items.length === 0) && existingItems.length > 0) {
880
+ return;
881
+ }
882
+ userObj.bookmarks.items = items;
883
+ userObj.bookmarks.layers = layers;
884
+ userObj.bookmarks.opacity = opacity;
885
+ userObj.bookmarks.visible = visible;
886
+ userObj.bookmarks.hotspot = hotspot;
887
+ userObj.bookmarks.selectedHotspotFilter = selectedHotspotFilter;
888
+ localStorage.setItem(storageKey, JSON.stringify(userObj));
889
+ }
656
890
  /**
657
891
  * This method renders the component
658
892
  * @returns jsx
@@ -3956,6 +3956,17 @@ class MenuWidget extends React.Component {
3956
3956
  let firstLayer;
3957
3957
  let landCoverAndLandUseMapping = document.querySelector('#component_0');
3958
3958
  let productIds = [];
3959
+ if (landCoverAndLandUseMapping) {
3960
+ const productElements = landCoverAndLandUseMapping.querySelectorAll(
3961
+ '.map-menu-product-dropdown',
3962
+ );
3963
+ productElements.forEach((productElement) => {
3964
+ const productId = productElement.getAttribute('productid');
3965
+ if (productId) {
3966
+ productIds.push(productId);
3967
+ }
3968
+ });
3969
+ }
3959
3970
  if (isCDSE) {
3960
3971
  const cdseGeometry = await this.getCDSEWFSGeoCoordinates(
3961
3972
  this.url,
@@ -3967,16 +3978,6 @@ class MenuWidget extends React.Component {
3967
3978
  zoom: 4,
3968
3979
  });
3969
3980
  return;
3970
- } else if (landCoverAndLandUseMapping) {
3971
- const productElements = landCoverAndLandUseMapping.querySelectorAll(
3972
- '.map-menu-product-dropdown',
3973
- );
3974
- productElements.forEach((productElement) => {
3975
- const productId = productElement.getAttribute('productid');
3976
- if (productId) {
3977
- productIds.push(productId);
3978
- }
3979
- });
3980
3981
  } else if (this.productId?.includes('333e4100b79045daa0ff16466ac83b7f')) {
3981
3982
  //global dynamic landCover
3982
3983
  this.findDatasetBoundingBox(elem);