@itwin/map-layers 5.0.0-dev.3 → 5.1.0
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 +20 -1
- package/lib/cjs/MapLayerPreferences.js +1 -1
- package/lib/cjs/MapLayerPreferences.js.map +1 -1
- package/lib/cjs/MapLayersPrefBrowserStorage.d.ts +5 -0
- package/lib/cjs/MapLayersPrefBrowserStorage.d.ts.map +1 -0
- package/lib/cjs/MapLayersPrefBrowserStorage.js +16 -0
- package/lib/cjs/MapLayersPrefBrowserStorage.js.map +1 -0
- package/lib/cjs/PreferencesBrowserStorage.d.ts +36 -0
- package/lib/cjs/PreferencesBrowserStorage.d.ts.map +1 -0
- package/lib/cjs/PreferencesBrowserStorage.js +92 -0
- package/lib/cjs/PreferencesBrowserStorage.js.map +1 -0
- package/lib/cjs/map-layers.d.ts +1 -0
- package/lib/cjs/map-layers.d.ts.map +1 -1
- package/lib/cjs/map-layers.js +1 -0
- package/lib/cjs/map-layers.js.map +1 -1
- package/lib/cjs/public/locales/en/mapLayers.json +7 -2
- package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
- package/lib/cjs/ui/widget/AttachLayerPopupButton.js +144 -64
- package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
- package/lib/cjs/ui/widget/BasemapPanel.js +44 -15
- package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapLayerDroppable.js +31 -3
- package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.js +35 -57
- package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.scss +2 -8
- package/lib/cjs/ui/widget/MapSelectFeaturesDialog.d.ts +11 -0
- package/lib/cjs/ui/widget/MapSelectFeaturesDialog.d.ts.map +1 -0
- package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js +58 -0
- package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js.map +1 -0
- package/lib/cjs/ui/widget/MapSelectFeaturesDialog.scss +17 -0
- package/lib/cjs/ui/widget/MapUrlDialog.d.ts +7 -2
- package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.js +38 -134
- package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.scss +10 -10
- package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts +3 -3
- package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
- package/lib/cjs/ui/widget/SubLayersDataProvider.js +4 -5
- package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts +3 -7
- package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts.map +1 -1
- package/lib/cjs/ui/widget/SubLayersPopupButton.js +2 -2
- package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.d.ts +17 -9
- package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.js +59 -112
- package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.scss +12 -3
- package/lib/esm/MapLayerPreferences.js +1 -1
- package/lib/esm/MapLayerPreferences.js.map +1 -1
- package/lib/esm/MapLayersPrefBrowserStorage.d.ts +5 -0
- package/lib/esm/MapLayersPrefBrowserStorage.d.ts.map +1 -0
- package/lib/esm/MapLayersPrefBrowserStorage.js +12 -0
- package/lib/esm/MapLayersPrefBrowserStorage.js.map +1 -0
- package/lib/esm/PreferencesBrowserStorage.d.ts +36 -0
- package/lib/esm/PreferencesBrowserStorage.d.ts.map +1 -0
- package/lib/esm/PreferencesBrowserStorage.js +88 -0
- package/lib/esm/PreferencesBrowserStorage.js.map +1 -0
- package/lib/esm/map-layers.d.ts +1 -0
- package/lib/esm/map-layers.d.ts.map +1 -1
- package/lib/esm/map-layers.js +1 -0
- package/lib/esm/map-layers.js.map +1 -1
- package/lib/esm/public/locales/en/mapLayers.json +7 -2
- package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
- package/lib/esm/ui/widget/AttachLayerPopupButton.js +145 -65
- package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
- package/lib/esm/ui/widget/BasemapPanel.js +44 -15
- package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapLayerDroppable.js +32 -4
- package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.js +36 -58
- package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.scss +2 -8
- package/lib/esm/ui/widget/MapSelectFeaturesDialog.d.ts +11 -0
- package/lib/esm/ui/widget/MapSelectFeaturesDialog.d.ts.map +1 -0
- package/lib/esm/ui/widget/MapSelectFeaturesDialog.js +54 -0
- package/lib/esm/ui/widget/MapSelectFeaturesDialog.js.map +1 -0
- package/lib/esm/ui/widget/MapSelectFeaturesDialog.scss +17 -0
- package/lib/esm/ui/widget/MapUrlDialog.d.ts +7 -2
- package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.js +38 -134
- package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.scss +10 -10
- package/lib/esm/ui/widget/SubLayersDataProvider.d.ts +3 -3
- package/lib/esm/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
- package/lib/esm/ui/widget/SubLayersDataProvider.js +4 -5
- package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersPopupButton.d.ts +3 -7
- package/lib/esm/ui/widget/SubLayersPopupButton.d.ts.map +1 -1
- package/lib/esm/ui/widget/SubLayersPopupButton.js +2 -2
- package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersTree.d.ts +17 -9
- package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
- package/lib/esm/ui/widget/SubLayersTree.js +60 -113
- package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersTree.scss +12 -3
- package/lib/public/locales/en/mapLayers.json +7 -2
- package/package.json +26 -25
|
@@ -7,43 +7,12 @@ exports.SubLayersTree = exports.SubLayersPanel = void 0;
|
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
9
9
|
const components_react_1 = require("@itwin/components-react");
|
|
10
|
-
const core_common_1 = require("@itwin/core-common");
|
|
11
|
-
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
10
|
const core_react_1 = require("@itwin/core-react");
|
|
13
11
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
14
12
|
const React = require("react");
|
|
15
13
|
const SubLayersDataProvider_1 = require("./SubLayersDataProvider");
|
|
16
14
|
require("./SubLayersTree.scss");
|
|
17
15
|
const mapLayers_1 = require("../../mapLayers");
|
|
18
|
-
const getWindow = () => {
|
|
19
|
-
return typeof window === "undefined" ? undefined : window;
|
|
20
|
-
};
|
|
21
|
-
const useResizeObserver = (onResize) => {
|
|
22
|
-
const resizeObserver = React.useRef();
|
|
23
|
-
const elementRef = React.useCallback((element) => {
|
|
24
|
-
if (!getWindow()?.ResizeObserver) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
resizeObserver.current?.disconnect();
|
|
28
|
-
if (element) {
|
|
29
|
-
resizeObserver.current = new ResizeObserver(([{ contentRect }]) => onResize(contentRect));
|
|
30
|
-
resizeObserver.current?.observe(element);
|
|
31
|
-
}
|
|
32
|
-
}, [onResize]);
|
|
33
|
-
return [elementRef, resizeObserver.current];
|
|
34
|
-
};
|
|
35
|
-
/** Mimic processing of `react-resize-detector` to return width and height.
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
function useResizeDetector() {
|
|
39
|
-
const [width, setWidth] = React.useState();
|
|
40
|
-
const [height, setHeight] = React.useState();
|
|
41
|
-
const [ref] = useResizeObserver(React.useCallback((size) => {
|
|
42
|
-
setWidth(size.width);
|
|
43
|
-
setHeight(size.height);
|
|
44
|
-
}, []));
|
|
45
|
-
return { width, height, ref };
|
|
46
|
-
}
|
|
47
16
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
48
17
|
function Toolbar(props) {
|
|
49
18
|
return (React.createElement("div", { className: "map-manager-sublayer-tree-toolbar" },
|
|
@@ -51,104 +20,75 @@ function Toolbar(props) {
|
|
|
51
20
|
props.searchField && React.createElement("div", { className: "tree-toolbar-searchbox" }, props.searchField)));
|
|
52
21
|
}
|
|
53
22
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
54
|
-
function SubLayersPanel(
|
|
23
|
+
function SubLayersPanel(props) {
|
|
55
24
|
const [noneAvailableLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.NoSubLayers"));
|
|
56
|
-
if (
|
|
25
|
+
if (undefined === props.subLayers || 0 === props.subLayers.length) {
|
|
57
26
|
return React.createElement("div", { className: "map-manager-sublayer-panel" },
|
|
58
27
|
React.createElement("div", null, noneAvailableLabel));
|
|
59
28
|
}
|
|
60
|
-
|
|
29
|
+
else {
|
|
30
|
+
return (React.createElement(SubLayersTree, { subLayers: props.subLayers, ...props }));
|
|
31
|
+
}
|
|
61
32
|
}
|
|
62
33
|
exports.SubLayersPanel = SubLayersPanel;
|
|
63
|
-
function getSubLayerProps(subLayerSettings) {
|
|
64
|
-
return subLayerSettings.map((subLayer) => subLayer.toJSON());
|
|
65
|
-
}
|
|
66
|
-
function getStyleMapLayerSettings(settings, isOverlay, layerIndex, treeVisibility) {
|
|
67
|
-
return {
|
|
68
|
-
visible: settings.visible,
|
|
69
|
-
name: settings.name,
|
|
70
|
-
source: settings.source,
|
|
71
|
-
transparency: settings.transparency,
|
|
72
|
-
transparentBackground: settings.transparentBackground,
|
|
73
|
-
subLayers: settings.subLayers ? getSubLayerProps(settings.subLayers) : undefined,
|
|
74
|
-
showSubLayers: true,
|
|
75
|
-
isOverlay,
|
|
76
|
-
layerIndex,
|
|
77
|
-
provider: core_frontend_1.IModelApp.viewManager.selectedView?.getMapLayerImageryProvider({ index: layerIndex, isOverlay }),
|
|
78
|
-
treeVisibility,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
34
|
/**
|
|
82
35
|
* Tree Control that displays sub-layer hierarchy
|
|
83
36
|
* @internal
|
|
84
37
|
*/
|
|
85
38
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
86
39
|
function SubLayersTree(props) {
|
|
40
|
+
const [width, setWidth] = React.useState(props.width);
|
|
41
|
+
const [height, setHeight] = React.useState(props.height);
|
|
87
42
|
const [placeholderLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.SearchPlaceholder"));
|
|
43
|
+
const [noResults] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.NoResults"));
|
|
88
44
|
const [allOnLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.AllOn"));
|
|
89
45
|
const [allOffLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.AllOff"));
|
|
90
|
-
const [
|
|
46
|
+
const [subLayers, setSubLayers] = React.useState(props.subLayers);
|
|
91
47
|
const [layerFilterString, setLayerFilterString] = React.useState("");
|
|
92
48
|
// create data provider to get some nodes to show in tree
|
|
93
49
|
// `React.useMemo' is used avoid creating new object on each render cycle
|
|
94
|
-
const dataProvider = React.useMemo(() => new SubLayersDataProvider_1.SubLayersDataProvider(
|
|
50
|
+
const dataProvider = React.useMemo(() => new SubLayersDataProvider_1.SubLayersDataProvider(subLayers, props.expandMode), [subLayers, props.expandMode]);
|
|
95
51
|
const { modelSource, nodeLoader, nodeHighlightingProps, } = useTreeFiltering(dataProvider, layerFilterString);
|
|
96
52
|
// create custom event handler. It handles all tree event same as `TreeEventHandler` but additionally
|
|
97
53
|
// it selects/deselects node when checkbox is checked/unchecked and vice versa.
|
|
98
54
|
// `useDisposable` takes care of disposing old event handler when new is created in case 'nodeLoader' has changed
|
|
99
55
|
// `React.useCallback` is used to avoid creating new callback that creates handler on each render
|
|
100
|
-
const eventHandler = (0, core_react_1.useDisposable)(React.useCallback(() => new SubLayerCheckboxHandler(
|
|
56
|
+
const eventHandler = (0, core_react_1.useDisposable)(React.useCallback(() => new SubLayerCheckboxHandler(subLayers, props.singleVisibleSubLayer ?? false, nodeLoader, props.onSubLayerStateChange), [nodeLoader, subLayers, props.onSubLayerStateChange, props.singleVisibleSubLayer]));
|
|
101
57
|
// Get an immutable tree model from the model source. The model is regenerated every time the model source
|
|
102
58
|
// emits the `onModelChanged` event.
|
|
103
59
|
const treeModel = (0, components_react_1.useTreeModel)(modelSource);
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (updatedMapLayer) {
|
|
112
|
-
if (updatedMapLayer instanceof core_common_1.ImageMapLayerSettings) {
|
|
113
|
-
const treeVisibility = vp.getMapLayerScaleRangeVisibility({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });
|
|
114
|
-
setMapLayer(getStyleMapLayerSettings(updatedMapLayer, mapLayer.isOverlay, indexInDisplayStyle, treeVisibility));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, [mapLayer]);
|
|
119
|
-
const hideAll = React.useCallback(async () => {
|
|
120
|
-
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
121
|
-
const displayStyle = vp?.displayStyle;
|
|
122
|
-
if (displayStyle && vp) {
|
|
123
|
-
const indexInDisplayStyle = displayStyle ? displayStyle.findMapLayerIndexByNameAndSource(mapLayer.name, mapLayer.source, mapLayer.isOverlay) : -1;
|
|
124
|
-
displayStyle.changeMapSubLayerProps({ visible: false }, -1, { index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });
|
|
125
|
-
const updatedMapLayer = displayStyle.mapLayerAtIndex({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });
|
|
126
|
-
if (updatedMapLayer && updatedMapLayer instanceof core_common_1.ImageMapLayerSettings) {
|
|
127
|
-
const treeVisibility = vp.getMapLayerScaleRangeVisibility({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });
|
|
128
|
-
setMapLayer(getStyleMapLayerSettings(updatedMapLayer, mapLayer.isOverlay, indexInDisplayStyle, treeVisibility));
|
|
129
|
-
}
|
|
60
|
+
const changeAll = React.useCallback(async (visible) => {
|
|
61
|
+
const tmpSubLayers = [...subLayers]; // deep copy to trigger state change
|
|
62
|
+
if (tmpSubLayers) {
|
|
63
|
+
tmpSubLayers?.forEach((subLayer) => {
|
|
64
|
+
subLayer.visible = visible;
|
|
65
|
+
});
|
|
66
|
+
setSubLayers(tmpSubLayers);
|
|
130
67
|
}
|
|
131
|
-
|
|
68
|
+
if (props.onSubLayerStateChange)
|
|
69
|
+
props.onSubLayerStateChange(-1, visible);
|
|
70
|
+
}, [subLayers, props]);
|
|
132
71
|
const handleFilterTextChanged = React.useCallback((event) => {
|
|
133
72
|
setLayerFilterString(event.target.value);
|
|
134
73
|
}, []);
|
|
135
|
-
const { width, height, ref: containerRef } = useResizeDetector();
|
|
136
74
|
return React.createElement(React.Fragment, null,
|
|
137
75
|
React.createElement("div", { className: "map-manager-sublayer-tree" },
|
|
138
|
-
React.createElement(Toolbar, { searchField: React.createElement(itwinui_react_1.Input, { type: "text", className: "map-manager-
|
|
139
|
-
React.createElement(itwinui_react_1.Button, { size: "small", styleType: "borderless", key: "show-all-btn", title: allOnLabel, onClick:
|
|
140
|
-
React.createElement(core_react_1.WebFontIcon, { iconName: "icon-visibility" })),
|
|
141
|
-
React.createElement(itwinui_react_1.Button, { size: "small", styleType: "borderless", key: "hide-all-btn", title: allOffLabel, onClick:
|
|
142
|
-
React.createElement(core_react_1.WebFontIcon, { iconName: "icon-visibility-hide-2" })),
|
|
76
|
+
React.createElement(Toolbar, { searchField: React.createElement(itwinui_react_1.Input, { type: "text", className: "map-manager-sublayer-tree-searchbox", placeholder: placeholderLabel, value: layerFilterString, onChange: handleFilterTextChanged, size: "small" }) }, props.singleVisibleSubLayer ? undefined : [
|
|
77
|
+
React.createElement(itwinui_react_1.Button, { size: "small", styleType: "borderless", key: "show-all-btn", title: allOnLabel, onClick: async () => changeAll(true) },
|
|
78
|
+
React.createElement(core_react_1.WebFontIcon, { iconName: props.checkboxStyle === "eye" ? "icon-visibility" : "icon-checkbox-select" })),
|
|
79
|
+
React.createElement(itwinui_react_1.Button, { size: "small", styleType: "borderless", key: "hide-all-btn", title: allOffLabel, onClick: async () => changeAll(false) },
|
|
80
|
+
React.createElement(core_react_1.WebFontIcon, { iconName: props.checkboxStyle === "eye" ? "icon-visibility-hide-2" : "icon-checkbox-deselect" })),
|
|
143
81
|
]),
|
|
144
|
-
React.createElement("div", {
|
|
82
|
+
React.createElement("div", { className: "map-manager-sublayer-tree-content" },
|
|
83
|
+
(props.width === undefined && props.height === undefined) && React.createElement(core_react_1.ResizableContainerObserver, { onResize: (w, h) => { setWidth(w); setHeight(h); } }),
|
|
84
|
+
(width !== undefined && height !== undefined)
|
|
85
|
+
&& React.createElement(components_react_1.ControlledTree, { nodeLoader: nodeLoader, selectionMode: components_react_1.SelectionMode.None, eventsHandler: eventHandler, model: treeModel, treeRenderer: props.checkboxStyle === "eye" ? nodeWithEyeCheckboxTreeRenderer : undefined, nodeHighlightingProps: nodeHighlightingProps, width: width, height: height, noDataRenderer: () => (React.createElement("p", { className: "components-controlledTree-errorMessage" }, noResults)) }))));
|
|
145
86
|
}
|
|
146
87
|
exports.SubLayersTree = SubLayersTree;
|
|
147
88
|
/** TreeEventHandler derived class that handler processing changes to subLayer visibility */
|
|
148
89
|
class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
|
|
149
|
-
constructor(
|
|
90
|
+
constructor(subLayers, singleVisibleSubLayer, nodeLoader, onSubLayerStateChange) {
|
|
150
91
|
super({ modelSource: nodeLoader.modelSource, nodeLoader, collapsedChildrenDisposalEnabled: true });
|
|
151
|
-
this._mapLayer = _mapLayer;
|
|
152
92
|
//-----------------------------------------------------------------------
|
|
153
93
|
// Listen to model changes
|
|
154
94
|
//------------------------------------------------------------------------
|
|
@@ -169,6 +109,9 @@ class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
|
|
|
169
109
|
});
|
|
170
110
|
});
|
|
171
111
|
};
|
|
112
|
+
this._subLayers = subLayers;
|
|
113
|
+
this._singleVisibleSubLayer = singleVisibleSubLayer;
|
|
114
|
+
this._onSubLayerStateChange = onSubLayerStateChange;
|
|
172
115
|
this._removeModelChangedListener = this.modelSource.onModelChanged.addListener(this.onModelChanged);
|
|
173
116
|
}
|
|
174
117
|
dispose() {
|
|
@@ -216,7 +159,7 @@ class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
|
|
|
216
159
|
if (!changedNode.checkbox)
|
|
217
160
|
return; // don't see why this would happen, but if there is no checkbox, we cant do much here.
|
|
218
161
|
const parentLayerId = undefined !== parentNode.item.extendedData?.subLayerId ? parentNode.item.extendedData?.subLayerId : parentNode.item.id;
|
|
219
|
-
const parentSubLayer = this.
|
|
162
|
+
const parentSubLayer = this._subLayers?.find((subLayer) => subLayer.id === parentLayerId);
|
|
220
163
|
// If parent is disabled, then children must be too.
|
|
221
164
|
// Also, Non-visible unnamed group must have their children disabled (unamed groups have visibility inherence)
|
|
222
165
|
if (parentNode.checkbox.isDisabled || (SubLayerCheckboxHandler.isUnnamedGroup(parentSubLayer) && parentNode.checkbox.state === core_react_1.CheckBoxState.Off)) {
|
|
@@ -226,7 +169,7 @@ class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
|
|
|
226
169
|
else {
|
|
227
170
|
// Visibility state from StyleMapLayerSettings applies
|
|
228
171
|
const subLayerId = undefined !== changedNode.item.extendedData?.subLayerId ? changedNode.item.extendedData?.subLayerId : changedNode.item.id;
|
|
229
|
-
const foundSubLayer = this.
|
|
172
|
+
const foundSubLayer = this._subLayers?.find((subLayer) => subLayer.id === subLayerId);
|
|
230
173
|
changedNode.checkbox.isDisabled = false;
|
|
231
174
|
changedNode.checkbox.state = foundSubLayer?.visible ? core_react_1.CheckBoxState.On : core_react_1.CheckBoxState.Off;
|
|
232
175
|
}
|
|
@@ -238,32 +181,36 @@ class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
|
|
|
238
181
|
// subscribe to checkbox state changes to new checkbox states and do some additional work with them
|
|
239
182
|
const selectionHandling = stateChanges.subscribe({
|
|
240
183
|
next: (changes) => {
|
|
241
|
-
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
242
|
-
const displayStyle = vp?.displayStyle;
|
|
243
|
-
const indexInDisplayStyle = displayStyle ? displayStyle.findMapLayerIndexByNameAndSource(this._mapLayer.name, this._mapLayer.source, this._mapLayer.isOverlay) : -1;
|
|
244
184
|
changes.forEach((change) => {
|
|
245
185
|
const isSelected = (change.newState === core_react_1.CheckBoxState.On);
|
|
246
186
|
const subLayerId = undefined !== change.nodeItem.extendedData?.subLayerId ? change.nodeItem.extendedData?.subLayerId : change.nodeItem.id;
|
|
247
|
-
// Get the previously visible node if
|
|
248
|
-
let
|
|
249
|
-
if (this.
|
|
250
|
-
|
|
187
|
+
// Get the previously visible node if we are in 'singleVisibleSubLayer' node
|
|
188
|
+
let prevVisibleSubLayers = [];
|
|
189
|
+
if (this._singleVisibleSubLayer) {
|
|
190
|
+
prevVisibleSubLayers = this._subLayers.reduce((filtered, subLayer) => {
|
|
191
|
+
if (subLayer.visible && subLayer.id !== undefined)
|
|
192
|
+
filtered.push(subLayer.id);
|
|
193
|
+
return filtered;
|
|
194
|
+
}, []);
|
|
251
195
|
}
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
prevVisibleLayer.visible = false;
|
|
258
|
-
// Update displaystyle state
|
|
259
|
-
if (-1 !== indexInDisplayStyle && displayStyle) {
|
|
260
|
-
if (prevVisibleLayer && prevVisibleLayer.id !== undefined)
|
|
261
|
-
displayStyle.changeMapSubLayerProps({ visible: false }, prevVisibleLayer.id, { index: indexInDisplayStyle, isOverlay: this._mapLayer.isOverlay });
|
|
262
|
-
displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: indexInDisplayStyle, isOverlay: this._mapLayer.isOverlay });
|
|
196
|
+
// Inform caller that subLayer state is going to change (i.e. update display style state)
|
|
197
|
+
if (this._onSubLayerStateChange) {
|
|
198
|
+
for (const slId of prevVisibleSubLayers)
|
|
199
|
+
this._onSubLayerStateChange(slId, false);
|
|
200
|
+
this._onSubLayerStateChange(subLayerId, isSelected);
|
|
263
201
|
}
|
|
202
|
+
// Update sublayer object, otherwise state would get out of sync with DisplayStyle each time the TreeView is re-rendered
|
|
203
|
+
this._subLayers?.forEach((curSubLayer) => {
|
|
204
|
+
if (curSubLayer.id !== undefined) {
|
|
205
|
+
if (curSubLayer.id === subLayerId)
|
|
206
|
+
curSubLayer.visible = isSelected;
|
|
207
|
+
else if (prevVisibleSubLayers.includes(curSubLayer.id))
|
|
208
|
+
curSubLayer.visible = false;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
264
211
|
// Cascade state
|
|
265
212
|
this.modelSource.modifyModel((model) => {
|
|
266
|
-
if (this.
|
|
213
|
+
if (this._singleVisibleSubLayer)
|
|
267
214
|
this.applyMutualExclusiveState(model, change.nodeItem.id);
|
|
268
215
|
this.cascadeStateToAllChildren(model, change.nodeItem.id);
|
|
269
216
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubLayersTree.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersTree.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,0DAA4D;AAC5D,8DAMiC;AACjC,oDAAkG;AAClG,wDAAkG;AAClG,kDAAsH;AACtH,wDAAqD;AACrD,+BAA+B;AAE/B,mEAAgE;AAChE,gCAA8B;AAC9B,+CAA8C;AAE9C,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CACxB,QAAyC,EACzC,EAAE;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,EAAkB,CAAC;IAEtD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAClC,CAAC,OAAiB,EAAE,EAAE;QACpB,IAAI,CAAC,SAAS,EAAE,EAAE,cAAc,EAAE;YAChC,OAAO;SACR;QAED,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACrC,IAAI,OAAO,EAAE;YACX,cAAc,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,CAChE,QAAQ,CAAC,WAAW,CAAC,CACtB,CAAC;YACF,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;SAC1C;IACH,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,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AAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,IAAI,EAAE,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAqB;QAC9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport {\n AbstractTreeNodeLoaderWithProvider, ControlledTree, DelayLoadedTreeNodeItem, HighlightableTreeProps, ITreeDataProvider,\n MutableTreeModel,\n MutableTreeModelNode,\n SelectionMode, TreeCheckboxStateChangeEventArgs, TreeDataProvider, TreeEventHandler, TreeImageLoader, TreeModel, TreeModelChanges, TreeModelSource, TreeNodeItem, TreeNodeLoader,\n TreeNodeRenderer, TreeNodeRendererProps, TreeRenderer, TreeRendererProps, useTreeModel,\n} from \"@itwin/components-react\";\nimport { ImageMapLayerSettings, MapSubLayerProps, MapSubLayerSettings } from \"@itwin/core-common\";\nimport { IModelApp, MapTileTreeScaleRangeVisibility, ScreenViewport } from \"@itwin/core-frontend\";\nimport { CheckBoxState, ImageCheckBox, NodeCheckboxRenderProps, useDisposable, WebFontIcon } from \"@itwin/core-react\";\nimport { Button, Input } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { StyleMapLayerSettings } from \"../Interfaces\";\nimport { SubLayersDataProvider } from \"./SubLayersDataProvider\";\nimport \"./SubLayersTree.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\nconst getWindow = () => {\n return typeof window === \"undefined\" ? undefined : window;\n};\n\nconst useResizeObserver = <T extends HTMLElement>(\n onResize: (size: DOMRectReadOnly) => void,\n) => {\n const resizeObserver = React.useRef<ResizeObserver>();\n\n const elementRef = React.useCallback(\n (element: T | null) => {\n if (!getWindow()?.ResizeObserver) {\n return;\n }\n\n resizeObserver.current?.disconnect();\n if (element) {\n resizeObserver.current = new ResizeObserver(([{ contentRect }]) =>\n onResize(contentRect),\n );\n resizeObserver.current?.observe(element);\n }\n },\n [onResize],\n );\n\n return [elementRef, resizeObserver.current] as const;\n};\n\n/** Mimic processing of `react-resize-detector` to return width and height.\n * @internal\n */\nfunction useResizeDetector(): { width: number | undefined, height: number | undefined, ref: React.Ref<HTMLDivElement> } {\n const [width, setWidth] = React.useState<number>();\n const [height, setHeight] = React.useState<number>();\n const [ref] = useResizeObserver(React.useCallback((size: DOMRectReadOnly) => {\n setWidth(size.width);\n setHeight(size.height);\n }, []));\n return { width, height, ref };\n}\n\ninterface ToolbarProps {\n searchField?: React.ReactNode;\n children?: React.ReactNode[];\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction Toolbar(props: ToolbarProps) {\n return (\n <div className=\"map-manager-sublayer-tree-toolbar\">\n <div className=\"tree-toolbar-action-buttons\">\n {props.children}\n </div>\n {props.searchField && <div className=\"tree-toolbar-searchbox\">\n {props.searchField}\n </div>}\n </div>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SubLayersPanel({ mapLayer, viewport }: { mapLayer: StyleMapLayerSettings, viewport: ScreenViewport | undefined }) {\n const [noneAvailableLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoSubLayers\"));\n if (!viewport || (undefined === mapLayer.subLayers || 0 === mapLayer.subLayers.length)) {\n return <div className=\"map-manager-sublayer-panel\">\n <div>{noneAvailableLabel}</div>\n </div>;\n }\n\n return (\n <SubLayersTree mapLayer={mapLayer} />\n );\n}\n\nfunction getSubLayerProps(subLayerSettings: MapSubLayerSettings[]): MapSubLayerProps[] {\n return subLayerSettings.map((subLayer) => subLayer.toJSON());\n}\n\nfunction getStyleMapLayerSettings(settings: ImageMapLayerSettings, isOverlay: boolean, layerIndex: number, treeVisibility: MapTileTreeScaleRangeVisibility): StyleMapLayerSettings {\n return {\n visible: settings.visible,\n name: settings.name,\n source: settings.source,\n transparency: settings.transparency,\n transparentBackground: settings.transparentBackground,\n subLayers: settings.subLayers ? getSubLayerProps(settings.subLayers) : undefined,\n showSubLayers: true,\n isOverlay,\n layerIndex,\n provider: IModelApp.viewManager.selectedView?.getMapLayerImageryProvider({ index: layerIndex, isOverlay }),\n treeVisibility,\n };\n}\n\n/**\n * Tree Control that displays sub-layer hierarchy\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SubLayersTree(props: { mapLayer: StyleMapLayerSettings }) {\n const [placeholderLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.SearchPlaceholder\"));\n const [allOnLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.AllOn\"));\n const [allOffLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.AllOff\"));\n const [mapLayer, setMapLayer] = React.useState(props.mapLayer);\n const [layerFilterString, setLayerFilterString] = React.useState<string>(\"\");\n\n // create data provider to get some nodes to show in tree\n // `React.useMemo' is used avoid creating new object on each render cycle\n const dataProvider = React.useMemo(() => new SubLayersDataProvider(mapLayer), [mapLayer]);\n\n const {\n modelSource,\n nodeLoader,\n nodeHighlightingProps,\n } = useTreeFiltering(dataProvider, layerFilterString);\n\n // create custom event handler. It handles all tree event same as `TreeEventHandler` but additionally\n // it selects/deselects node when checkbox is checked/unchecked and vice versa.\n // `useDisposable` takes care of disposing old event handler when new is created in case 'nodeLoader' has changed\n // `React.useCallback` is used to avoid creating new callback that creates handler on each render\n const eventHandler = useDisposable(React.useCallback(() => new SubLayerCheckboxHandler(mapLayer, nodeLoader), [nodeLoader, mapLayer]));\n\n // Get an immutable tree model from the model source. The model is regenerated every time the model source\n // emits the `onModelChanged` event.\n const treeModel = useTreeModel(modelSource);\n\n const showAll = React.useCallback(async () => {\n const vp = IModelApp.viewManager.selectedView;\n const displayStyle = vp?.displayStyle;\n if (displayStyle && vp) {\n const indexInDisplayStyle = displayStyle ? displayStyle.findMapLayerIndexByNameAndSource(mapLayer.name, mapLayer.source, mapLayer.isOverlay) : -1;\n displayStyle.changeMapSubLayerProps({ visible: true }, -1, { index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });\n const updatedMapLayer = displayStyle.mapLayerAtIndex({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });\n if (updatedMapLayer) {\n if (updatedMapLayer instanceof ImageMapLayerSettings) {\n const treeVisibility = vp.getMapLayerScaleRangeVisibility({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });\n setMapLayer(getStyleMapLayerSettings(updatedMapLayer, mapLayer.isOverlay, indexInDisplayStyle, treeVisibility));\n }\n\n }\n }\n }, [mapLayer]);\n\n const hideAll = React.useCallback(async () => {\n const vp = IModelApp.viewManager.selectedView;\n const displayStyle = vp?.displayStyle;\n if (displayStyle && vp) {\n const indexInDisplayStyle = displayStyle ? displayStyle.findMapLayerIndexByNameAndSource(mapLayer.name, mapLayer.source, mapLayer.isOverlay) : -1;\n displayStyle.changeMapSubLayerProps({ visible: false }, -1, { index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });\n const updatedMapLayer = displayStyle.mapLayerAtIndex({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });\n if (updatedMapLayer && updatedMapLayer instanceof ImageMapLayerSettings) {\n const treeVisibility = vp.getMapLayerScaleRangeVisibility({ index: indexInDisplayStyle, isOverlay: mapLayer.isOverlay });\n setMapLayer(getStyleMapLayerSettings(updatedMapLayer, mapLayer.isOverlay, indexInDisplayStyle, treeVisibility));\n }\n }\n }, [mapLayer]);\n\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n setLayerFilterString(event.target.value);\n }, []);\n\n const { width, height, ref: containerRef } = useResizeDetector();\n\n return <>\n <div className=\"map-manager-sublayer-tree\">\n <Toolbar\n searchField={\n <Input type=\"text\" className=\"map-manager-source-list-filter\"\n placeholder={placeholderLabel}\n value={layerFilterString}\n onChange={handleFilterTextChanged}\n size=\"small\" />\n }\n >\n {mapLayer.provider?.mutualExclusiveSubLayer ? undefined : [\n <Button size=\"small\" styleType=\"borderless\" key=\"show-all-btn\" title={allOnLabel} onClick={showAll}>\n <WebFontIcon iconName=\"icon-visibility\" />\n </Button>,\n <Button size=\"small\" styleType=\"borderless\" key=\"hide-all-btn\" title={allOffLabel} onClick={hideAll}>\n <WebFontIcon iconName=\"icon-visibility-hide-2\" />\n </Button>,\n ]}\n </Toolbar>\n <div ref={containerRef} className=\"map-manager-sublayer-tree-content\">\n {width !== undefined && height !== undefined && <ControlledTree\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n model={treeModel}\n treeRenderer={nodeWithEyeCheckboxTreeRenderer}\n nodeHighlightingProps={nodeHighlightingProps}\n width={width}\n height={height}\n />}\n </div>\n </div>\n </>;\n}\n\n/** TreeEventHandler derived class that handler processing changes to subLayer visibility */\nclass SubLayerCheckboxHandler extends TreeEventHandler {\n private _removeModelChangedListener: () => void;\n\n constructor(private _mapLayer: StyleMapLayerSettings, nodeLoader: AbstractTreeNodeLoaderWithProvider<TreeDataProvider>) {\n super({ modelSource: nodeLoader.modelSource, nodeLoader, collapsedChildrenDisposalEnabled: true });\n this._removeModelChangedListener = this.modelSource.onModelChanged.addListener(this.onModelChanged);\n }\n\n public override dispose() {\n this._removeModelChangedListener();\n super.dispose();\n }\n\n // Cascade state\n // Children on unnamed groups must get disabled in the tree view, because\n // they get rendered anyway.\n private cascadeStateToAllChildren(model: MutableTreeModel, parentId?: string) {\n const children = model.getChildren(parentId);\n if (children === undefined)\n return;\n\n for (const childID of children) {\n const childNode = childID ? model.getNode(childID) : undefined;\n\n if (childNode)\n this.syncNodeStateWithParent(model, childNode);\n\n // Drill down the tree.\n this.cascadeStateToAllChildren(model, childID);\n }\n }\n\n private applyMutualExclusiveState(model: MutableTreeModel, nodeId: string) {\n const changedNode = model.getNode(nodeId);\n if (changedNode?.checkbox.state === CheckBoxState.Off)\n return;\n\n for (const node of model.iterateTreeModelNodes()) {\n if (node.id === changedNode?.id)\n continue;\n\n if (node && node.checkbox.state === CheckBoxState.On)\n node.checkbox.state = CheckBoxState.Off;\n }\n }\n\n //-----------------------------------------------------------------------\n // Listen to model changes\n //------------------------------------------------------------------------\n // This is required because nodes are delay loaded in the model until\n // they are made visible (i.e. parent node is expanded). So even though\n // you might have created nodes in the data provided with a proper\n // initial state, by the time it gets loaded, their state might have became\n // out of date in the TreeView's active model. So whenever a node\n // is added, when must confirm its state matches the current model\n // (i.e. state of their parent.)\n public onModelChanged = (args: [TreeModel, TreeModelChanges]) => {\n this.modelSource.modifyModel((model) => {\n const addedNodes = args[1].addedNodeIds.map((id) => model.getNode(id));\n addedNodes.forEach((node) => {\n if (!node)\n return;\n\n this.syncNodeStateWithParent(model, node);\n });\n });\n };\n\n private static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean {\n if (!subLayer)\n return false;\n\n return (!subLayer.name || subLayer.name.length === 0) && (subLayer.children !== undefined && subLayer.children.length > 0);\n }\n\n // Ensure the state of changed node matches the state of its parent.\n private syncNodeStateWithParent(model: MutableTreeModel, changedNode: MutableTreeModelNode) {\n // Lookup node parent. If non exists, I assume thats the root node,\n // and it must have a proper initial state.\n const parentNode = changedNode.parentId ? model.getNode(changedNode.parentId) : undefined;\n if (!parentNode)\n return;\n\n if (!changedNode.checkbox)\n return; // don't see why this would happen, but if there is no checkbox, we cant do much here.\n\n const parentLayerId = undefined !== parentNode.item.extendedData?.subLayerId ? parentNode.item.extendedData?.subLayerId : parentNode.item.id;\n const parentSubLayer = this._mapLayer.subLayers?.find((subLayer) => subLayer.id === parentLayerId);\n\n // If parent is disabled, then children must be too.\n // Also, Non-visible unnamed group must have their children disabled (unamed groups have visibility inherence)\n if (parentNode.checkbox.isDisabled || (SubLayerCheckboxHandler.isUnnamedGroup(parentSubLayer) && parentNode.checkbox.state === CheckBoxState.Off)) {\n changedNode.checkbox.isDisabled = true;\n changedNode.checkbox.state = CheckBoxState.Off;\n } else {\n // Visibility state from StyleMapLayerSettings applies\n const subLayerId = undefined !== changedNode.item.extendedData?.subLayerId ? changedNode.item.extendedData?.subLayerId : changedNode.item.id;\n const foundSubLayer = this._mapLayer.subLayers?.find((subLayer) => subLayer.id === subLayerId);\n changedNode.checkbox.isDisabled = false;\n changedNode.checkbox.state = foundSubLayer?.visible ? CheckBoxState.On : CheckBoxState.Off;\n }\n }\n\n /** Changes nodes checkboxes states until event is handled or handler is disposed */\n public override onCheckboxStateChanged({ stateChanges }: TreeCheckboxStateChangeEventArgs) {\n // call base checkbox handling\n const baseHandling = super.onCheckboxStateChanged({ stateChanges });\n\n // subscribe to checkbox state changes to new checkbox states and do some additional work with them\n const selectionHandling = stateChanges.subscribe({\n next: (changes) => {\n const vp = IModelApp.viewManager.selectedView;\n const displayStyle = vp?.displayStyle;\n const indexInDisplayStyle = displayStyle ? displayStyle.findMapLayerIndexByNameAndSource(this._mapLayer.name, this._mapLayer.source, this._mapLayer.isOverlay) : -1;\n changes.forEach((change) => {\n const isSelected = (change.newState === CheckBoxState.On);\n\n const subLayerId = undefined !== change.nodeItem.extendedData?.subLayerId ? change.nodeItem.extendedData?.subLayerId : change.nodeItem.id;\n\n // Get the previously visible node if any\n let prevVisibleLayer: MapSubLayerProps | undefined;\n if (this._mapLayer.provider?.mutualExclusiveSubLayer) {\n prevVisibleLayer = this._mapLayer.subLayers?.find((subLayer) => subLayer.visible && subLayer.id !== subLayerId);\n }\n\n // Update sublayer object, otherwise state would get out of sync with DisplayStyle each time the TreeView is re-rendered\n const foundSubLayer = this._mapLayer.subLayers?.find((subLayer) => subLayer.id === subLayerId);\n if (foundSubLayer)\n foundSubLayer.visible = isSelected;\n if (prevVisibleLayer?.visible)\n prevVisibleLayer.visible = false;\n\n // Update displaystyle state\n if (-1 !== indexInDisplayStyle && displayStyle) {\n if (prevVisibleLayer && prevVisibleLayer.id !== undefined)\n displayStyle.changeMapSubLayerProps({ visible: false }, prevVisibleLayer.id, { index: indexInDisplayStyle, isOverlay: this._mapLayer.isOverlay });\n displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: indexInDisplayStyle, isOverlay: this._mapLayer.isOverlay });\n }\n\n // Cascade state\n this.modelSource.modifyModel((model) => {\n if (this._mapLayer.provider?.mutualExclusiveSubLayer)\n this.applyMutualExclusiveState(model, change.nodeItem.id);\n this.cascadeStateToAllChildren(model, change.nodeItem.id);\n });\n });\n },\n });\n // stop handling selection when checkboxes handling is stopped\n baseHandling?.add(selectionHandling);\n return baseHandling;\n }\n}\n\n/** Custom checkbox renderer that renders checkbox as an eye */\nconst eyeCheckboxRenderer = (props: NodeCheckboxRenderProps) => (\n <ImageCheckBox\n checked={props.checked}\n disabled={props.disabled}\n imageOn=\"icon-visibility\"\n imageOff=\"icon-visibility-hide-2\"\n onClick={props.onChange}\n tooltip={props.title}\n />\n);\n\n/** Custom node renderer. It uses default 'TreeNodeRenderer' but overrides default checkbox renderer to render checkbox as an eye */\nconst imageLoader = new TreeImageLoader();\nconst nodeWithEyeCheckboxRenderer = (props: TreeNodeRendererProps) => (\n <TreeNodeRenderer\n {...props}\n checkboxRenderer={eyeCheckboxRenderer}\n imageLoader={imageLoader}\n />\n);\n\n/** Custom tree renderer. It uses default `TreeRenderer` but overrides default node renderer to render node with custom checkbox */\nconst nodeWithEyeCheckboxTreeRenderer = (props: TreeRendererProps) => (\n <TreeRenderer\n {...props}\n nodeRenderer={nodeWithEyeCheckboxRenderer}\n />\n);\n\nfunction useTreeFiltering(\n dataProvider: ITreeDataProvider,\n filter: string,\n) {\n const nodeLoader = useFilteredProvider(dataProvider, filter);\n const nodeHighlightingProps = useNodeHighlightingProps(filter);\n return {\n nodeLoader,\n modelSource: nodeLoader.modelSource,\n nodeHighlightingProps,\n };\n}\n\nfunction useFilteredProvider(\n dataProvider: ITreeDataProvider,\n filter: string,\n) {\n const filteredProvider = React.useMemo(() => {\n return new FilteredTreeDataProvider(dataProvider, filter);\n }, [dataProvider, filter]);\n\n const nodeLoader = React.useMemo(() => {\n return new TreeNodeLoader(filteredProvider, new TreeModelSource());\n }, [filteredProvider]);\n\n return nodeLoader;\n}\n\nfunction useNodeHighlightingProps(\n filter: string,\n) {\n const [nodeHighlightingProps, setNodeHighlightingProps] = React.useState<HighlightableTreeProps>();\n\n React.useEffect(() => {\n if (filter === \"\") {\n setNodeHighlightingProps(undefined);\n return;\n }\n setNodeHighlightingProps({\n searchText: filter,\n activeMatch: undefined,\n });\n }, [filter]);\n\n return nodeHighlightingProps;\n}\n\nclass FullTreeHierarchy {\n private _dataProvider: ITreeDataProvider;\n private _hierarchy = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider) {\n this._dataProvider = dataProvider;\n\n this._init = (async () => {\n await this.initNode();\n })();\n }\n\n private async initNode(parent?: TreeNodeItem) {\n const nodes = await this._dataProvider.getNodes(parent);\n this._hierarchy.set(parent?.id, nodes);\n for (const node of nodes) {\n await this.initNode(node);\n }\n }\n\n public async getHierarchy() {\n await this._init;\n return this._hierarchy;\n }\n}\n\nclass FilteredTreeHierarchy {\n private _fullHierarchy: FullTreeHierarchy;\n private _filter: string;\n private _filtered = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider, filter: string) {\n this._fullHierarchy = new FullTreeHierarchy(dataProvider);\n this._filter = filter;\n\n this._init = (async () => {\n await this.init();\n })();\n }\n\n private async init() {\n const hierarchy = await this._fullHierarchy.getHierarchy();\n if (this._filter === \"\") {\n this._filtered = hierarchy;\n return;\n }\n this.filterNodes(hierarchy);\n }\n\n /** Initializes `this._filtered` field. Returns a node if it matches a filter. */\n private filterNodes(hierarchy: Map<string | undefined, DelayLoadedTreeNodeItem[]>, current?: DelayLoadedTreeNodeItem): DelayLoadedTreeNodeItem | undefined {\n const matches = current ? this.matchesFilter(current) : false;\n const children = hierarchy.get(current?.id);\n if (!children)\n return matches ? current : undefined;\n\n const matchedChildren = new Array<DelayLoadedTreeNodeItem>();\n for (const child of children) {\n const matchedChild = this.filterNodes(hierarchy, child);\n matchedChild && matchedChildren.push(matchedChild);\n }\n\n const hasChildren = matchedChildren.length > 0;\n const included = matches || hasChildren;\n let filtered: DelayLoadedTreeNodeItem | undefined;\n if (included) {\n this._filtered.set(current?.id, matchedChildren);\n\n // Return a modified copy of current node (to persist initial hierarchy when filter is cleared).\n if (current) {\n filtered = {\n ...current,\n hasChildren,\n autoExpand: hasChildren ? true : current.autoExpand,\n };\n }\n }\n return filtered;\n }\n\n private matchesFilter(node: TreeNodeItem) {\n if (node.label.value.valueFormat !== PropertyValueFormat.Primitive)\n return false;\n\n const value = node.label.value.displayValue?.toLowerCase();\n if (!value)\n return false;\n return value.includes(this._filter.toLowerCase());\n }\n\n public async getHierarchy() {\n await this._init;\n return this._filtered;\n }\n}\n\nclass FilteredTreeDataProvider implements ITreeDataProvider {\n private _hierarchy: FilteredTreeHierarchy;\n\n public constructor(\n parentDataProvider: ITreeDataProvider,\n filter: string,\n ) {\n this._hierarchy = new FilteredTreeHierarchy(parentDataProvider, filter);\n }\n\n public async getNodes(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes || [];\n }\n\n public async getNodesCount(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes?.length || 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SubLayersTree.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersTree.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/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AAqC,EACrC,MAAc;QAEd,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAqB;QACzC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,IAAI,EAAE,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAqB;QAC9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport {\n AbstractTreeNodeLoaderWithProvider, ControlledTree, DelayLoadedTreeNodeItem, HighlightableTreeProps, ITreeDataProvider,\n MutableTreeModel, MutableTreeModelNode, SelectionMode, TreeCheckboxStateChangeEventArgs, TreeDataProvider,\n TreeEventHandler, TreeImageLoader, TreeModel, TreeModelChanges, TreeModelSource, TreeNodeItem, TreeNodeLoader,\n TreeNodeRenderer, TreeNodeRendererProps, TreeRenderer, TreeRendererProps, useTreeModel,\n} from \"@itwin/components-react\";\nimport { MapSubLayerProps, SubLayerId } from \"@itwin/core-common\";\nimport { CheckBoxState, ImageCheckBox, NodeCheckboxRenderProps, ResizableContainerObserver, useDisposable, WebFontIcon } from \"@itwin/core-react\";\nimport { Button, Input } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { SubLayersDataProvider, SubLayersTreeExpandMode } from \"./SubLayersDataProvider\";\nimport \"./SubLayersTree.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\ninterface ToolbarProps {\n searchField?: React.ReactNode;\n children?: React.ReactNode[];\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction Toolbar(props: ToolbarProps) {\n return (\n <div className=\"map-manager-sublayer-tree-toolbar\">\n <div className=\"tree-toolbar-action-buttons\">\n {props.children}\n </div>\n {props.searchField && <div className=\"tree-toolbar-searchbox\">\n {props.searchField}\n </div>}\n </div>\n );\n}\n\nexport type OnSubLayerStateChangeType = (subLayerId: SubLayerId, isSelected: boolean) => void;\nexport interface SubLayersPanelProps extends Omit<SubLayersTreeProps, \"subLayers\"> {\n subLayers?: MapSubLayerProps[];\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SubLayersPanel(props: SubLayersPanelProps) {\n const [noneAvailableLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoSubLayers\"));\n if (undefined === props.subLayers || 0 === props.subLayers.length) {\n return <div className=\"map-manager-sublayer-panel\">\n <div>{noneAvailableLabel}</div>\n </div>;\n } else {\n return (\n <SubLayersTree subLayers={props.subLayers} {...props} />\n );\n }\n}\n\nexport interface SubLayersTreeProps {\n checkboxStyle: \"standard\" | \"eye\";\n expandMode: SubLayersTreeExpandMode;\n subLayers: MapSubLayerProps[];\n singleVisibleSubLayer?: boolean;\n onSubLayerStateChange?: OnSubLayerStateChangeType;\n height?: number;\n width?: number;\n}\n\n/**\n * Tree Control that displays sub-layer hierarchy\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SubLayersTree(props: SubLayersTreeProps) {\n const [width, setWidth] = React.useState<number|undefined>(props.width);\n const [height, setHeight] = React.useState<number|undefined>(props.height);\n\n const [placeholderLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.SearchPlaceholder\"));\n const [noResults] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoResults\"));\n const [allOnLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.AllOn\"));\n const [allOffLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.AllOff\"));\n const [subLayers, setSubLayers] = React.useState(props.subLayers);\n const [layerFilterString, setLayerFilterString] = React.useState<string>(\"\");\n\n // create data provider to get some nodes to show in tree\n // `React.useMemo' is used avoid creating new object on each render cycle\n const dataProvider = React.useMemo(() => new SubLayersDataProvider(subLayers, props.expandMode), [subLayers, props.expandMode]);\n\n const {\n modelSource,\n nodeLoader,\n nodeHighlightingProps,\n } = useTreeFiltering(dataProvider, layerFilterString);\n\n // create custom event handler. It handles all tree event same as `TreeEventHandler` but additionally\n // it selects/deselects node when checkbox is checked/unchecked and vice versa.\n // `useDisposable` takes care of disposing old event handler when new is created in case 'nodeLoader' has changed\n // `React.useCallback` is used to avoid creating new callback that creates handler on each render\n const eventHandler = useDisposable(React.useCallback(() => new SubLayerCheckboxHandler(subLayers, props.singleVisibleSubLayer ?? false, nodeLoader, props.onSubLayerStateChange), [nodeLoader, subLayers, props.onSubLayerStateChange, props.singleVisibleSubLayer]));\n\n // Get an immutable tree model from the model source. The model is regenerated every time the model source\n // emits the `onModelChanged` event.\n const treeModel = useTreeModel(modelSource);\n const changeAll = React.useCallback(async (visible: boolean) => {\n const tmpSubLayers = [...subLayers]; // deep copy to trigger state change\n if (tmpSubLayers) {\n tmpSubLayers?.forEach((subLayer: MapSubLayerProps) => {\n subLayer.visible = visible;\n });\n\n setSubLayers(tmpSubLayers);\n }\n\n if (props.onSubLayerStateChange)\n props.onSubLayerStateChange(-1, visible);\n }, [subLayers, props]);\n\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n setLayerFilterString(event.target.value);\n }, []);\n\n return <>\n <div className=\"map-manager-sublayer-tree\">\n <Toolbar\n searchField={\n <Input type=\"text\" className=\"map-manager-sublayer-tree-searchbox\"\n placeholder={placeholderLabel}\n value={layerFilterString}\n onChange={handleFilterTextChanged}\n size=\"small\" />\n }\n >\n {props.singleVisibleSubLayer ? undefined : [\n <Button size=\"small\" styleType=\"borderless\" key=\"show-all-btn\" title={allOnLabel} onClick={async () => changeAll(true)}>\n <WebFontIcon iconName={props.checkboxStyle === \"eye\" ? \"icon-visibility\" : \"icon-checkbox-select\" } />\n </Button>,\n <Button size=\"small\" styleType=\"borderless\" key=\"hide-all-btn\" title={allOffLabel} onClick={async () => changeAll(false)}>\n <WebFontIcon iconName={props.checkboxStyle === \"eye\" ? \"icon-visibility-hide-2\" : \"icon-checkbox-deselect\" } />\n </Button>,\n ]}\n </Toolbar>\n <div className=\"map-manager-sublayer-tree-content\" >\n {(props.width === undefined && props.height === undefined) && <ResizableContainerObserver onResize={(w, h) => {setWidth(w); setHeight(h);} }/> }\n {(width !== undefined && height !== undefined)\n && <ControlledTree\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n model={treeModel}\n treeRenderer={props.checkboxStyle === \"eye\" ? nodeWithEyeCheckboxTreeRenderer : undefined}\n nodeHighlightingProps={nodeHighlightingProps}\n width={width}\n height={height}\n noDataRenderer={()=>(<p className=\"components-controlledTree-errorMessage\">{noResults}</p>)}\n />}\n </div>\n </div >\n </>;\n}\n\n/** TreeEventHandler derived class that handler processing changes to subLayer visibility */\nclass SubLayerCheckboxHandler extends TreeEventHandler {\n private _removeModelChangedListener: () => void;\n private _onSubLayerStateChange?: OnSubLayerStateChangeType;\n private _subLayers: MapSubLayerProps[];\n private _singleVisibleSubLayer?: boolean;\n\n constructor(subLayers: MapSubLayerProps[], singleVisibleSubLayer: boolean, nodeLoader: AbstractTreeNodeLoaderWithProvider<TreeDataProvider>, onSubLayerStateChange?: OnSubLayerStateChangeType) {\n super({ modelSource: nodeLoader.modelSource, nodeLoader, collapsedChildrenDisposalEnabled: true });\n this._subLayers = subLayers;\n this._singleVisibleSubLayer = singleVisibleSubLayer;\n this._onSubLayerStateChange = onSubLayerStateChange;\n this._removeModelChangedListener = this.modelSource.onModelChanged.addListener(this.onModelChanged);\n }\n\n public override dispose() {\n this._removeModelChangedListener();\n super.dispose();\n }\n\n // Cascade state\n // Children on unnamed groups must get disabled in the tree view, because\n // they get rendered anyway.\n private cascadeStateToAllChildren(model: MutableTreeModel, parentId?: string) {\n const children = model.getChildren(parentId);\n if (children === undefined)\n return;\n\n for (const childID of children) {\n const childNode = childID ? model.getNode(childID) : undefined;\n\n if (childNode)\n this.syncNodeStateWithParent(model, childNode);\n\n // Drill down the tree.\n this.cascadeStateToAllChildren(model, childID);\n }\n }\n\n private applyMutualExclusiveState(model: MutableTreeModel, nodeId: string) {\n const changedNode = model.getNode(nodeId);\n if (changedNode?.checkbox.state === CheckBoxState.Off)\n return;\n\n for (const node of model.iterateTreeModelNodes()) {\n if (node.id === changedNode?.id)\n continue;\n\n if (node && node.checkbox.state === CheckBoxState.On)\n node.checkbox.state = CheckBoxState.Off;\n }\n }\n\n //-----------------------------------------------------------------------\n // Listen to model changes\n //------------------------------------------------------------------------\n // This is required because nodes are delay loaded in the model until\n // they are made visible (i.e. parent node is expanded). So even though\n // you might have created nodes in the data provided with a proper\n // initial state, by the time it gets loaded, their state might have became\n // out of date in the TreeView's active model. So whenever a node\n // is added, when must confirm its state matches the current model\n // (i.e. state of their parent.)\n public onModelChanged = (args: [TreeModel, TreeModelChanges]) => {\n this.modelSource.modifyModel((model) => {\n const addedNodes = args[1].addedNodeIds.map((id) => model.getNode(id));\n addedNodes.forEach((node) => {\n if (!node)\n return;\n\n this.syncNodeStateWithParent(model, node);\n });\n });\n };\n\n private static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean {\n if (!subLayer)\n return false;\n\n return (!subLayer.name || subLayer.name.length === 0) && (subLayer.children !== undefined && subLayer.children.length > 0);\n }\n\n // Ensure the state of changed node matches the state of its parent.\n private syncNodeStateWithParent(model: MutableTreeModel, changedNode: MutableTreeModelNode) {\n // Lookup node parent. If non exists, I assume thats the root node,\n // and it must have a proper initial state.\n const parentNode = changedNode.parentId ? model.getNode(changedNode.parentId) : undefined;\n if (!parentNode)\n return;\n\n if (!changedNode.checkbox)\n return; // don't see why this would happen, but if there is no checkbox, we cant do much here.\n\n const parentLayerId = undefined !== parentNode.item.extendedData?.subLayerId ? parentNode.item.extendedData?.subLayerId : parentNode.item.id;\n const parentSubLayer = this._subLayers?.find((subLayer) => subLayer.id === parentLayerId);\n\n // If parent is disabled, then children must be too.\n // Also, Non-visible unnamed group must have their children disabled (unamed groups have visibility inherence)\n if (parentNode.checkbox.isDisabled || (SubLayerCheckboxHandler.isUnnamedGroup(parentSubLayer) && parentNode.checkbox.state === CheckBoxState.Off)) {\n changedNode.checkbox.isDisabled = true;\n changedNode.checkbox.state = CheckBoxState.Off;\n } else {\n // Visibility state from StyleMapLayerSettings applies\n const subLayerId = undefined !== changedNode.item.extendedData?.subLayerId ? changedNode.item.extendedData?.subLayerId : changedNode.item.id;\n const foundSubLayer = this._subLayers?.find((subLayer) => subLayer.id === subLayerId);\n changedNode.checkbox.isDisabled = false;\n changedNode.checkbox.state = foundSubLayer?.visible ? CheckBoxState.On : CheckBoxState.Off;\n }\n }\n\n /** Changes nodes checkboxes states until event is handled or handler is disposed */\n public override onCheckboxStateChanged({ stateChanges }: TreeCheckboxStateChangeEventArgs) {\n // call base checkbox handling\n const baseHandling = super.onCheckboxStateChanged({ stateChanges });\n\n // subscribe to checkbox state changes to new checkbox states and do some additional work with them\n const selectionHandling = stateChanges.subscribe({\n next: (changes) => {\n changes.forEach((change) => {\n const isSelected = (change.newState === CheckBoxState.On);\n const subLayerId = undefined !== change.nodeItem.extendedData?.subLayerId ? change.nodeItem.extendedData?.subLayerId : change.nodeItem.id;\n\n // Get the previously visible node if we are in 'singleVisibleSubLayer' node\n let prevVisibleSubLayers: SubLayerId[] = [];\n if (this._singleVisibleSubLayer) {\n prevVisibleSubLayers = this._subLayers.reduce((filtered: SubLayerId[], subLayer) => {\n if (subLayer.visible && subLayer.id !== undefined)\n filtered.push(subLayer.id);\n return filtered;\n }, []);\n }\n\n // Inform caller that subLayer state is going to change (i.e. update display style state)\n if (this._onSubLayerStateChange) {\n for (const slId of prevVisibleSubLayers)\n this._onSubLayerStateChange(slId, false);\n\n this._onSubLayerStateChange(subLayerId, isSelected);\n }\n\n // Update sublayer object, otherwise state would get out of sync with DisplayStyle each time the TreeView is re-rendered\n this._subLayers?.forEach((curSubLayer) => {\n if (curSubLayer.id !== undefined) {\n if (curSubLayer.id === subLayerId)\n curSubLayer.visible = isSelected;\n else if (prevVisibleSubLayers.includes(curSubLayer.id))\n curSubLayer.visible = false;\n }\n });\n\n // Cascade state\n this.modelSource.modifyModel((model) => {\n if (this._singleVisibleSubLayer)\n this.applyMutualExclusiveState(model, change.nodeItem.id);\n this.cascadeStateToAllChildren(model, change.nodeItem.id);\n });\n });\n },\n });\n // stop handling selection when checkboxes handling is stopped\n baseHandling?.add(selectionHandling);\n return baseHandling;\n }\n}\n\n/** Custom checkbox renderer that renders checkbox as an eye */\nconst eyeCheckboxRenderer = (props: NodeCheckboxRenderProps) => (\n <ImageCheckBox\n checked={props.checked}\n disabled={props.disabled}\n imageOn=\"icon-visibility\"\n imageOff=\"icon-visibility-hide-2\"\n onClick={props.onChange}\n tooltip={props.title}\n />\n);\n\n/** Custom node renderer. It uses default 'TreeNodeRenderer' but overrides default checkbox renderer to render checkbox as an eye */\nconst imageLoader = new TreeImageLoader();\nconst nodeWithEyeCheckboxRenderer = (props: TreeNodeRendererProps) => (\n <TreeNodeRenderer\n {...props}\n checkboxRenderer={eyeCheckboxRenderer}\n imageLoader={imageLoader}\n />\n);\n\n/** Custom tree renderer. It uses default `TreeRenderer` but overrides default node renderer to render node with custom checkbox */\nconst nodeWithEyeCheckboxTreeRenderer = (props: TreeRendererProps) => (\n <TreeRenderer\n {...props}\n nodeRenderer={nodeWithEyeCheckboxRenderer}\n />\n);\n\nfunction useTreeFiltering(\n dataProvider: ITreeDataProvider,\n filter: string,\n) {\n const nodeLoader = useFilteredProvider(dataProvider, filter);\n const nodeHighlightingProps = useNodeHighlightingProps(filter);\n return {\n nodeLoader,\n modelSource: nodeLoader.modelSource,\n nodeHighlightingProps,\n };\n}\n\nfunction useFilteredProvider(\n dataProvider: ITreeDataProvider,\n filter: string,\n) {\n const filteredProvider = React.useMemo(() => {\n return new FilteredTreeDataProvider(dataProvider, filter);\n }, [dataProvider, filter]);\n\n const nodeLoader = React.useMemo(() => {\n return new TreeNodeLoader(filteredProvider, new TreeModelSource());\n }, [filteredProvider]);\n\n return nodeLoader;\n}\n\nfunction useNodeHighlightingProps(\n filter: string,\n) {\n const [nodeHighlightingProps, setNodeHighlightingProps] = React.useState<HighlightableTreeProps>();\n\n React.useEffect(() => {\n if (filter === \"\") {\n setNodeHighlightingProps(undefined);\n return;\n }\n setNodeHighlightingProps({\n searchText: filter,\n activeMatch: undefined,\n });\n }, [filter]);\n\n return nodeHighlightingProps;\n}\n\nclass FullTreeHierarchy {\n private _dataProvider: ITreeDataProvider;\n private _hierarchy = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider) {\n this._dataProvider = dataProvider;\n\n this._init = (async () => {\n await this.initNode();\n })();\n }\n\n private async initNode(parent?: TreeNodeItem) {\n const nodes = await this._dataProvider.getNodes(parent);\n this._hierarchy.set(parent?.id, nodes);\n for (const node of nodes) {\n await this.initNode(node);\n }\n }\n\n public async getHierarchy() {\n await this._init;\n return this._hierarchy;\n }\n}\n\nclass FilteredTreeHierarchy {\n private _fullHierarchy: FullTreeHierarchy;\n private _filter: string;\n private _filtered = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider, filter: string) {\n this._fullHierarchy = new FullTreeHierarchy(dataProvider);\n this._filter = filter;\n\n this._init = (async () => {\n await this.init();\n })();\n }\n\n private async init() {\n const hierarchy = await this._fullHierarchy.getHierarchy();\n if (this._filter === \"\") {\n this._filtered = hierarchy;\n return;\n }\n this.filterNodes(hierarchy);\n }\n\n /** Initializes `this._filtered` field. Returns a node if it matches a filter. */\n private filterNodes(hierarchy: Map<string | undefined, DelayLoadedTreeNodeItem[]>, current?: DelayLoadedTreeNodeItem): DelayLoadedTreeNodeItem | undefined {\n const matches = current ? this.matchesFilter(current) : false;\n const children = hierarchy.get(current?.id);\n if (!children)\n return matches ? current : undefined;\n\n const matchedChildren = new Array<DelayLoadedTreeNodeItem>();\n for (const child of children) {\n const matchedChild = this.filterNodes(hierarchy, child);\n matchedChild && matchedChildren.push(matchedChild);\n }\n\n const hasChildren = matchedChildren.length > 0;\n const included = matches || hasChildren;\n let filtered: DelayLoadedTreeNodeItem | undefined;\n if (included) {\n this._filtered.set(current?.id, matchedChildren);\n\n // Return a modified copy of current node (to persist initial hierarchy when filter is cleared).\n if (current) {\n filtered = {\n ...current,\n hasChildren,\n autoExpand: hasChildren ? true : current.autoExpand,\n };\n }\n }\n return filtered;\n }\n\n private matchesFilter(node: TreeNodeItem) {\n if (node.label.value.valueFormat !== PropertyValueFormat.Primitive)\n return false;\n\n const value = node.label.value.displayValue?.toLowerCase();\n if (!value)\n return false;\n return value.includes(this._filter.toLowerCase());\n }\n\n public async getHierarchy() {\n await this._init;\n return this._filtered;\n }\n}\n\nclass FilteredTreeDataProvider implements ITreeDataProvider {\n private _hierarchy: FilteredTreeHierarchy;\n\n public constructor(\n parentDataProvider: ITreeDataProvider,\n filter: string,\n ) {\n this._hierarchy = new FilteredTreeHierarchy(parentDataProvider, filter);\n }\n\n public async getNodes(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes || [];\n }\n\n public async getNodesCount(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes?.length || 0;\n }\n}\n"]}
|
|
@@ -65,7 +65,16 @@
|
|
|
65
65
|
|
|
66
66
|
.map-manager-sublayer-tree-content {
|
|
67
67
|
flex-grow: 1;
|
|
68
|
-
width:
|
|
69
|
-
height:
|
|
70
|
-
overflow:
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 100%;
|
|
70
|
+
overflow: auto;
|
|
71
|
+
}
|
|
72
|
+
.map-manager-sublayer-tree-searchbox {
|
|
73
|
+
padding-top: 3.3px;
|
|
74
|
+
padding-bottom: 3.3px;
|
|
75
|
+
|
|
76
|
+
// We override the default padding of the search box input otherwise it
|
|
77
|
+
// makes the vertical scrollbar of the tree of padded too, and doesnt look good.
|
|
78
|
+
padding-inline: 0px;
|
|
79
|
+
padding-inline-start: 4px;
|
|
71
80
|
}
|
|
@@ -95,7 +95,7 @@ export class MapLayerPreferences {
|
|
|
95
95
|
await MapLayersUI.iTwinConfig.save({
|
|
96
96
|
accessToken,
|
|
97
97
|
namespace: MapLayerPreferences._preferenceNamespace,
|
|
98
|
-
key:
|
|
98
|
+
key: newSource.name,
|
|
99
99
|
iTwinId,
|
|
100
100
|
iModelId: storeOnIModel ? iModelId : undefined,
|
|
101
101
|
content: mapLayerSetting,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,gBAAgB;AAChB,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,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jB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,IAAI;YACF,MAAM,kBAAkB,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC;gBAC3D,WAAW;gBACX,SAAS,EAAE,mBAAmB,CAAC,oBAAoB;gBACnD,GAAG,EAAE,EAAE;gBACP,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;YACH,IAAI,SAAS,KAAK,kBAAkB;gBAClC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAhTD;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,OAAO,EAA0G,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,gBAAgB;AAChB,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MA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W,CAAC,WAAW,CAAC,GAAG,CAAC;gBAC3D,WAAW;gBACX,SAAS,EAAE,mBAAmB,CAAC,oBAAoB;gBACnD,GAAG,EAAE,EAAE;gBACP,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;YACH,IAAI,SAAS,KAAK,kBAAkB;gBAClC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAhTD;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,OAAO,EAA0G,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapLayersPrefBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/MapLayersPrefBrowserStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,2BAA4B,SAAQ,yBAAyB;;CAMzE"}
|