@eeacms/volto-arcgis-block 0.1.393 → 0.1.395
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,14 @@ 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.395](https://github.com/eea/volto-arcgis-block/compare/0.1.394...0.1.395) - 3 October 2025
|
|
8
|
+
|
|
9
|
+
### [0.1.394](https://github.com/eea/volto-arcgis-block/compare/0.1.393...0.1.394) - 2 October 2025
|
|
10
|
+
|
|
11
|
+
#### :hammer_and_wrench: Others
|
|
12
|
+
|
|
13
|
+
- (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)]
|
|
14
|
+
- (task): local storage cleanup of bookmarks data in local storage. [Unai Bolivar - [`ce9ad06`](https://github.com/eea/volto-arcgis-block/commit/ce9ad06db65c96f6fe1a985b3e4962b977bb30de)]
|
|
7
15
|
### [0.1.393](https://github.com/eea/volto-arcgis-block/compare/0.1.392...0.1.393) - 1 October 2025
|
|
8
16
|
|
|
9
17
|
### [0.1.392](https://github.com/eea/volto-arcgis-block/compare/0.1.391...0.1.392) - 25 September 2025
|
package/package.json
CHANGED
|
@@ -1328,6 +1328,7 @@ class AreaWidget extends React.Component {
|
|
|
1328
1328
|
'</div>';
|
|
1329
1329
|
this.props.download && this.props.view.ui.add(popup, 'top-right');
|
|
1330
1330
|
});
|
|
1331
|
+
this.dragElement(document.querySelector('.coordinateWindow'));
|
|
1331
1332
|
}
|
|
1332
1333
|
|
|
1333
1334
|
async initFMI() {
|
|
@@ -1349,6 +1350,38 @@ class AreaWidget extends React.Component {
|
|
|
1349
1350
|
//console.error('There was a problem with the fetch operation:', error);
|
|
1350
1351
|
}
|
|
1351
1352
|
}
|
|
1353
|
+
dragElement(elmnt) {
|
|
1354
|
+
var pos1 = 0,
|
|
1355
|
+
pos2 = 0,
|
|
1356
|
+
pos3 = 0,
|
|
1357
|
+
pos4 = 0;
|
|
1358
|
+
let header = document.querySelector('.coordinateHeader');
|
|
1359
|
+
const dragMouseDown = (e) => {
|
|
1360
|
+
e.preventDefault();
|
|
1361
|
+
pos3 = e.clientX;
|
|
1362
|
+
pos4 = e.clientY;
|
|
1363
|
+
document.onmouseup = closeDragElement;
|
|
1364
|
+
document.onmousemove = elementDrag;
|
|
1365
|
+
};
|
|
1366
|
+
const elementDrag = (e) => {
|
|
1367
|
+
e.preventDefault();
|
|
1368
|
+
pos1 = pos3 - e.clientX;
|
|
1369
|
+
pos2 = pos4 - e.clientY;
|
|
1370
|
+
pos3 = e.clientX;
|
|
1371
|
+
pos4 = e.clientY;
|
|
1372
|
+
elmnt.style.top = elmnt.offsetTop - pos2 + 'px';
|
|
1373
|
+
elmnt.style.left = elmnt.offsetLeft - pos1 + 'px';
|
|
1374
|
+
};
|
|
1375
|
+
const closeDragElement = () => {
|
|
1376
|
+
document.onmouseup = null;
|
|
1377
|
+
document.onmousemove = null;
|
|
1378
|
+
};
|
|
1379
|
+
if (header) {
|
|
1380
|
+
header.addEventListener('mousedown', dragMouseDown);
|
|
1381
|
+
} else {
|
|
1382
|
+
elmnt.addEventListener('mousedown', dragMouseDown);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1352
1385
|
/**
|
|
1353
1386
|
* This method renders the component
|
|
1354
1387
|
* @returns jsx
|
|
@@ -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.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
397
|
-
|
|
398
|
-
);
|
|
399
|
-
localStorage.setItem(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
);
|
|
403
|
-
localStorage.setItem(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
);
|
|
407
|
-
localStorage.setItem(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
);
|
|
411
|
-
localStorage.setItem(
|
|
412
|
-
|
|
413
|
-
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
);
|
|
488
|
-
localStorage.setItem(
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
);
|
|
492
|
-
localStorage.setItem(
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
);
|
|
496
|
-
localStorage.setItem(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
);
|
|
500
|
-
localStorage.setItem(
|
|
501
|
-
|
|
502
|
-
|
|
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
|