@itwin/map-layers 5.0.0 → 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 +12 -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 +26 -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 -1
- package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
- package/lib/cjs/ui/widget/SubLayersDataProvider.js +3 -3
- package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersPopupButton.js +1 -1
- package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.d.ts +5 -0
- package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.js +12 -36
- package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.scss +12 -3
- 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 +27 -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 -1
- package/lib/esm/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
- package/lib/esm/ui/widget/SubLayersDataProvider.js +3 -3
- package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersPopupButton.js +1 -1
- package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersTree.d.ts +5 -0
- package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
- package/lib/esm/ui/widget/SubLayersTree.js +13 -37
- 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 +16 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachLayerPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/AttachLayerPopupButton.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAkB,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpI,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,E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,EAC9L,OAAO,EAAE,WAAW;gBACpB,oBAAC,MAAM,CAAC,WAAW,IAAC,QAAQ,EAAC,UAAU,GAAG,CACnC,CACV,CAAC;SACH;aAAM;YACL,MAAM,kBAAkB,GAAG,GAAG,EAAE;gBAC9B,QAAQ,KAAK,CAAC,UAAU,EAAE;oBACxB,KAAK,qBAAqB,CAAC,IAAI;wBAC7B,OAAO,iBAAiB,CAAC;oBAC3B,KAAK,qBAAqB,CAAC,OAAO,CAAC;oBACnC;wBACE,OAAO,KAAK,CAAC;iBAChB;YACH,CAAC,CAAC;YACF,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC;YACvC,MAAM,GAAG,CACP,oBAAC,MAAM,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,EACpI,OAAO,EAAE,WAAW,IAAG,yBAAyB,CAAU,CAC7D,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,CACL;QACG,YAAY,EAAE;QACf,oBAAC,MAAM,CAAC,KAAK,IACX,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,gBAAgB,CAAC,WAAW,EACtC,OAAO,EAAE,gBAAgB,EACzB,cAAc,EAAE,oBAAoB,EACpC,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,YAAY,EAAE,KAAK,EACnB,kBAAkB,EAAE,KAAK;YAEzB,6BAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,yBAAyB;gBACrD,oBAAC,gBAAgB,IACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,eAAe,EAAE,mBAAmB,EACpC,oBAAoB,EAAE,qBAAqB,GAAI,CAC7C,CACQ,CACf,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport * as React from \"react\";\r\nimport { IModelApp, MapLayerSource, MapLayerSourceStatus, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport * as UiCore from \"@itwin/core-react\";\r\nimport { UiFramework } from \"@itwin/appui-react\";\r\nimport { useSourceMapContext } from \"./MapLayerManager\";\r\nimport { MapUrlDialog } from \"./MapUrlDialog\";\r\nimport { ConfirmMessageDialog } from \"./ConfirmMessageDialog\";\r\nimport { Button, Input } from \"@itwin/itwinui-react\";\r\nimport { MapLayerPreferences } from \"../../MapLayerPreferences\";\r\nimport { MapLayersUI } from \"../../mapLayers\";\r\n\r\n// cSpell:ignore droppable Sublayer\r\n\r\nenum LayerAction {\r\n Attached,\r\n Edited\r\n}\r\n\r\ninterface AttachLayerPanelProps {\r\n isOverlay: boolean;\r\n onLayerAttached: () => void;\r\n onHandleOutsideClick?: (shouldHandle: boolean) => void;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }: AttachLayerPanelProps) {\r\n const [layerNameToAdd, setLayerNameToAdd] = React.useState<string | undefined>();\r\n const [sourceFilterString, setSourceFilterString] = React.useState<string | undefined>();\r\n\r\n const { placeholderLabel, addCustomLayerLabel, addCustomLayerToolTip, loadingMapSources, removeLayerDefButtonTitle, editLayerDefButtonTitle, removeLayerDefDialogTitle } = React.useMemo(() => {\r\n return {\r\n placeholderLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.SearchPlaceholder\"),\r\n addCustomLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.Custom\"),\r\n addCustomLayerToolTip: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AttachCustomLayer\"),\r\n loadingMapSources: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.LoadingMapSources\"),\r\n removeLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefButtonTitle\"),\r\n editLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.EditLayerDefButtonTitle\"),\r\n removeLayerDefDialogTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogTitle\"),\r\n };\r\n }, []);\r\n\r\n const [loading, setLoading] = React.useState(false);\r\n const [layerNameUnderCursor, setLayerNameUnderCursor] = React.useState<string | undefined>();\r\n\r\n const resumeOutsideClick = React.useCallback(() => {\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(true);\r\n }\r\n }, [onHandleOutsideClick]);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n\r\n // We close any open dialogs that we might have opened\r\n // This was added because the modal dialog remained remained displayed after the session expired.\r\n UiFramework.dialogs.modal.close();\r\n };\r\n }, []);\r\n\r\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSourceFilterString(event.target.value);\r\n }, []);\r\n\r\n const { loadingSources, sources, activeViewport, backgroundLayers, overlayLayers, mapLayerOptions } = useSourceMapContext();\r\n const mapTypesOptions = mapLayerOptions?.mapTypeOptions;\r\n const iTwinId = activeViewport?.iModel?.iTwinId;\r\n const iModelId = activeViewport?.iModel?.iModelId;\r\n\r\n const styleContainsLayer = React.useCallback((name: string) => {\r\n if (backgroundLayers) {\r\n if (-1 !== backgroundLayers.findIndex((layer) => layer.name === name))\r\n return true;\r\n }\r\n if (overlayLayers) {\r\n if (-1 !== overlayLayers.findIndex((layer) => layer.name === name))\r\n return true;\r\n }\r\n return false;\r\n }, [backgroundLayers, overlayLayers]);\r\n\r\n const handleModalUrlDialogOk = React.useCallback((action: LayerAction) => {\r\n if (LayerAction.Attached === action) {\r\n // close popup and refresh UI\r\n onLayerAttached();\r\n }\r\n\r\n resumeOutsideClick();\r\n }, [onLayerAttached, resumeOutsideClick]);\r\n\r\n const handleModalUrlDialogCancel = React.useCallback(() => {\r\n // close popup and refresh UI\r\n setLoading(false);\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n React.useEffect(() => {\r\n async function attemptToAddLayer(layerName: string) {\r\n if (layerName && activeViewport) {\r\n // if the layer is not in the style add it now.\r\n if (undefined === backgroundLayers?.find((layer) => layerName === layer.name) && undefined === overlayLayers?.find((layer) => layerName === layer.name)) {\r\n const mapLayerSettings = sources?.find((source) => source.name === layerName);\r\n if (mapLayerSettings === undefined) {\r\n return;\r\n }\r\n\r\n try {\r\n if (isMounted.current) {\r\n setLoading(true);\r\n }\r\n\r\n const { status, subLayers } = await mapLayerSettings.validateSource();\r\n if (status === MapLayerSourceStatus.Valid || status === MapLayerSourceStatus.RequireAuth) {\r\n\r\n if (status === MapLayerSourceStatus.Valid) {\r\n const settings = mapLayerSettings.toLayerSettings(subLayers);\r\n\r\n if (settings) {\r\n activeViewport.displayStyle.attachMapLayer({ settings, mapLayerIndex: {index: -1, isOverlay} });\r\n\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttached\", { sourceName: settings.name, sourceUrl: settings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n }\r\n\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n if (onLayerAttached) {\r\n onLayerAttached();\r\n }\r\n\r\n } else if (status === MapLayerSourceStatus.RequireAuth && isMounted.current) {\r\n UiFramework.dialogs.modal.open(\r\n <MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n layerRequiringCredentials={mapLayerSettings.toJSON()}\r\n onOkResult={() => handleModalUrlDialogOk(LayerAction.Attached)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }\r\n\r\n } else {\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerValidationFailed\", { sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n }\r\n } catch (err) {\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttachError\", { error: err, sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n }\r\n return;\r\n }\r\n\r\n if (layerNameToAdd) {\r\n attemptToAddLayer(layerNameToAdd); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n if (isMounted.current) {\r\n setLayerNameToAdd(undefined);\r\n }\r\n }\r\n }, [setLayerNameToAdd, layerNameToAdd, activeViewport, sources, backgroundLayers, isOverlay, overlayLayers, onLayerAttached, handleModalUrlDialogOk, mapTypesOptions, handleModalUrlDialogCancel, onHandleOutsideClick]);\r\n\r\n const options = React.useMemo(() => sources?.filter((source) => !styleContainsLayer(source.name)), [sources, styleContainsLayer]);\r\n const filteredOptions = React.useMemo(() => {\r\n if (undefined === sourceFilterString || 0 === sourceFilterString.length) {\r\n return options;\r\n } else {\r\n return options?.filter((option) => option.name.toLowerCase().includes(sourceFilterString?.toLowerCase()));\r\n }\r\n }, [options, sourceFilterString]);\r\n\r\n const handleAddNewMapSource = React.useCallback(() => {\r\n UiFramework.dialogs.modal.open(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n onOkResult={() => handleModalUrlDialogOk(LayerAction.Attached)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n return;\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick]);\r\n\r\n const handleAttach = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleKeypressOnSourceList = React.useCallback((event: React.KeyboardEvent<HTMLUListElement>) => {\r\n const key = event.key;\r\n if (key === \"Enter\") {\r\n event.preventDefault();\r\n const mapName = event.currentTarget?.dataset?.value;\r\n if (mapName && mapName.length) {\r\n handleAttach(mapName);\r\n }\r\n }\r\n }, [handleAttach]);\r\n\r\n const onListboxValueChange = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleNoConfirmation = React.useCallback((_layerName: string) => {\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n const handleYesConfirmation = React.useCallback(async (source: MapLayerSource) => {\r\n const layerName = source.name;\r\n if (!!iTwinId) {\r\n try {\r\n await MapLayerPreferences.deleteByName(source, iTwinId, iModelId);\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefSuccess\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n } catch (err: any) {\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefError\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [iTwinId, iModelId, resumeOutsideClick]);\r\n\r\n /*\r\n Handle Remove layer button clicked\r\n */\r\n const onItemRemoveButtonClicked = React.useCallback((source, event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const layerName = source.name;\r\n\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogMessage\", { layerName });\r\n UiFramework.dialogs.modal.open(\r\n <ConfirmMessageDialog\r\n className=\"map-sources-delete-confirmation\"\r\n title={removeLayerDefDialogTitle}\r\n message={msg}\r\n maxWidth={400}\r\n onClose={() => handleNoConfirmation(layerName)}\r\n onEscape={() => handleNoConfirmation(layerName)}\r\n onYesResult={async () => handleYesConfirmation(source)}\r\n onNoResult={() => handleNoConfirmation(layerName)}\r\n />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [handleNoConfirmation, handleYesConfirmation, onHandleOutsideClick, removeLayerDefDialogTitle]);\r\n\r\n /*\r\n Handle Edit layer button clicked\r\n */\r\n const onItemEditButtonClicked = React.useCallback((event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const targetLayerName = event?.currentTarget?.parentNode?.dataset?.value;\r\n const matchingSource = sources.find((layerSource) => layerSource.name === targetLayerName);\r\n\r\n // we expect a single layer source matching this name\r\n if (matchingSource === undefined) {\r\n return;\r\n }\r\n UiFramework.dialogs.modal.open(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n mapLayerSourceToEdit={matchingSource}\r\n onOkResult={() => handleModalUrlDialogOk(LayerAction.Edited)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick, sources]);\r\n\r\n return (\r\n <div className=\"map-manager-header\">\r\n {(loading || loadingSources) && <UiCore.LoadingSpinner message={loadingMapSources} />}\r\n <div className=\"map-manager-source-listbox-header\">\r\n <Input type=\"text\" className=\"map-manager-source-list-filter\"\r\n placeholder={placeholderLabel}\r\n value={sourceFilterString}\r\n onChange={handleFilterTextChanged}\r\n size=\"small\" />\r\n <Button className=\"map-manager-add-source-button\" title={addCustomLayerToolTip} onClick={handleAddNewMapSource}>\r\n {addCustomLayerLabel}</Button>\r\n </div>\r\n <div className=\"map-manager-sources\">\r\n <UiCore.Listbox\r\n id=\"map-sources\"\r\n selectedValue={layerNameToAdd}\r\n className=\"map-manager-source-list\"\r\n onKeyPress={handleKeypressOnSourceList}\r\n onListboxValueChange={onListboxValueChange} >\r\n {\r\n filteredOptions?.map((source) =>\r\n <UiCore.ListboxItem\r\n key={source.name}\r\n className=\"map-source-list-entry\"\r\n value={source.name}\r\n onMouseEnter={() => setLayerNameUnderCursor(source.name)}\r\n onMouseLeave={() => setLayerNameUnderCursor(undefined)}>\r\n <span className=\"map-source-list-entry-name\" title={source.name}>{source.name}</span>\r\n\r\n { // Display the delete icon only when the mouse over a specific item\r\n // otherwise list feels cluttered.\r\n (!!iTwinId && layerNameUnderCursor && layerNameUnderCursor === source.name) &&\r\n <>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={editLayerDefButtonTitle}\r\n onClick={onItemEditButtonClicked}>\r\n <UiCore.Icon iconSpec=\"icon-edit\" />\r\n </Button>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={removeLayerDefButtonTitle}\r\n onClick={(event: React.MouseEvent) => { onItemRemoveButtonClicked(source, event); }}>\r\n <UiCore.Icon iconSpec=\"icon-delete\" />\r\n </Button>\r\n </>}\r\n\r\n </UiCore.ListboxItem>\r\n )\r\n }\r\n </UiCore.Listbox>\r\n </div>\r\n </div>\r\n\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport enum AttachLayerButtonType {\r\n Primary,\r\n Blue,\r\n Icon\r\n}\r\nexport interface AttachLayerPopupButtonProps {\r\n isOverlay: boolean;\r\n buttonType?: AttachLayerButtonType;\r\n disabled?: boolean;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function AttachLayerPopupButton(props: AttachLayerPopupButtonProps) {\r\n const { showAttachLayerLabel, hideAttachLayerLabel, addCustomLayerButtonLabel } = React.useMemo(() => {\r\n return {\r\n showAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Attach\"),\r\n hideAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Close\"),\r\n addCustomLayerButtonLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AddCustomLayerButtonLabel\"),\r\n };\r\n }, []);\r\n\r\n const [handleOutsideClick, setHandleOutsideClick] = React.useState(true);\r\n const [popupOpen, setPopupOpen] = React.useState(false);\r\n const buttonRef = React.useRef<HTMLButtonElement>(null);\r\n const panelRef = React.useRef<HTMLDivElement>(null);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n };\r\n }, []);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setPopupOpen(!popupOpen);\r\n }, [popupOpen]);\r\n\r\n const handleClosePopup = React.useCallback(() => {\r\n setPopupOpen(false);\r\n }, []);\r\n\r\n const onHandleOutsideClick = React.useCallback((event: MouseEvent) => {\r\n if (!handleOutsideClick) {\r\n return;\r\n }\r\n\r\n // If clicking on button that open panel - don't trigger outside click processing\r\n if (buttonRef?.current && buttonRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If clicking the panel, this is not an outside clicked\r\n if (panelRef.current && panelRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If we reach this point, we got an outside clicked, no close the popup\r\n setPopupOpen(false);\r\n\r\n }, [handleOutsideClick]);\r\n\r\n const { refreshFromStyle } = useSourceMapContext();\r\n\r\n const handleLayerAttached = React.useCallback(() => {\r\n if (!isMounted.current) {\r\n return;\r\n }\r\n setPopupOpen(false);\r\n refreshFromStyle();\r\n }, [refreshFromStyle]);\r\n\r\n function renderButton(): React.ReactNode {\r\n let button: React.ReactNode;\r\n\r\n if (props.buttonType === undefined || props.buttonType === AttachLayerButtonType.Icon) {\r\n button = (\r\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" ref={buttonRef} className=\"map-manager-attach-layer-button\" title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>\r\n <UiCore.WebFontIcon iconName=\"icon-add\" />\r\n </Button>\r\n );\r\n } else {\r\n const determineStyleType = () => {\r\n switch (props.buttonType) {\r\n case AttachLayerButtonType.Blue:\r\n return \"high-visibility\";\r\n case AttachLayerButtonType.Primary:\r\n default:\r\n return \"cta\";\r\n }\r\n };\r\n const styleType = determineStyleType();\r\n button = (\r\n <Button disabled={props.disabled} ref={buttonRef} styleType={styleType} title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>{addCustomLayerButtonLabel}</Button>\r\n );\r\n }\r\n\r\n return button;\r\n }\r\n\r\n return (\r\n <>\r\n {renderButton()}\r\n <UiCore.Popup\r\n isOpen={popupOpen}\r\n position={RelativePosition.BottomRight}\r\n onClose={handleClosePopup}\r\n onOutsideClick={onHandleOutsideClick}\r\n target={buttonRef.current}\r\n closeOnEnter={false}\r\n closeOnContextMenu={false}\r\n >\r\n <div ref={panelRef} className=\"map-sources-popup-panel\" >\r\n <AttachLayerPanel\r\n isOverlay={props.isOverlay}\r\n onLayerAttached={handleLayerAttached}\r\n onHandleOutsideClick={setHandleOutsideClick} />\r\n </div>\r\n </UiCore.Popup >\r\n </>\r\n );\r\n}\r\n"]}
|
|
1
|
+
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,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport * as React from \"react\";\r\nimport { IModelApp, MapLayerSource, MapLayerSourceStatus, MapLayerSourceValidation, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport * as UiCore from \"@itwin/core-react\";\r\nimport { UiFramework } from \"@itwin/appui-react\";\r\nimport { useSourceMapContext } from \"./MapLayerManager\";\r\nimport { MapUrlDialog, SourceState } from \"./MapUrlDialog\";\r\nimport { ConfirmMessageDialog } from \"./ConfirmMessageDialog\";\r\nimport { Button, Input } from \"@itwin/itwinui-react\";\r\nimport { MapLayerPreferences } from \"../../MapLayerPreferences\";\r\nimport { MapLayersUI } from \"../../mapLayers\";\r\nimport { MapSelectFeaturesDialog } from \"./MapSelectFeaturesDialog\";\r\nimport { MapSubLayerProps } from \"@itwin/core-common\";\r\n\r\n// cSpell:ignore droppable Sublayer\r\n\r\nenum LayerAction {\r\n New,\r\n Edit\r\n}\r\n\r\ninterface AttachLayerPanelProps {\r\n isOverlay: boolean;\r\n onLayerAttached: () => void;\r\n onHandleOutsideClick?: (shouldHandle: boolean) => void;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }: AttachLayerPanelProps) {\r\n const [layerNameToAdd, setLayerNameToAdd] = React.useState<string | undefined>();\r\n const [sourceFilterString, setSourceFilterString] = React.useState<string | undefined>();\r\n\r\n const { placeholderLabel, addCustomLayerLabel, addCustomLayerToolTip, loadingMapSources, removeLayerDefButtonTitle, editLayerDefButtonTitle, removeLayerDefDialogTitle } = React.useMemo(() => {\r\n return {\r\n placeholderLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.SearchPlaceholder\"),\r\n addCustomLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.Custom\"),\r\n addCustomLayerToolTip: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AttachCustomLayer\"),\r\n loadingMapSources: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.LoadingMapSources\"),\r\n removeLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefButtonTitle\"),\r\n editLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.EditLayerDefButtonTitle\"),\r\n removeLayerDefDialogTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogTitle\"),\r\n };\r\n }, []);\r\n\r\n const [loading, setLoading] = React.useState(false);\r\n const [layerNameUnderCursor, setLayerNameUnderCursor] = React.useState<string | undefined>();\r\n\r\n const resumeOutsideClick = React.useCallback(() => {\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(true);\r\n }\r\n }, [onHandleOutsideClick]);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n\r\n // We close any open dialogs that we might have opened\r\n // This was added because the modal dialog remained remained displayed after the session expired.\r\n UiFramework.dialogs.modal.close();\r\n };\r\n }, []);\r\n\r\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSourceFilterString(event.target.value);\r\n }, []);\r\n\r\n const { loadingSources, sources, activeViewport, backgroundLayers, overlayLayers, mapLayerOptions } = useSourceMapContext();\r\n const mapTypesOptions = mapLayerOptions?.mapTypeOptions;\r\n const iTwinId = activeViewport?.iModel?.iTwinId;\r\n const iModelId = activeViewport?.iModel?.iModelId;\r\n\r\n const attachLayer = React.useCallback((source: MapLayerSource, subLayers: MapSubLayerProps[]|undefined, oneMapLayerPerSubLayer: boolean) => {\r\n if (activeViewport) {\r\n const generateUniqueMapLayerName = (layerName: string) => {\r\n let uniqueLayerName = layerName;\r\n let layerNameIdx = 1;\r\n while (\r\n (backgroundLayers && backgroundLayers.some((layer) => uniqueLayerName === layer.name))\r\n || (overlayLayers && overlayLayers.some((layer) => uniqueLayerName === layer.name)) ) {\r\n uniqueLayerName = `${layerName} (${layerNameIdx++})`;\r\n }\r\n return {layerNameUpdate: layerNameIdx>1, uniqueLayerName};\r\n };\r\n\r\n const doAttachLayer = (layerName: string, subLayer?: MapSubLayerProps) => {\r\n const generatedName = generateUniqueMapLayerName(layerName);\r\n let sourceToAdd = source;\r\n if (generatedName.layerNameUpdate || sourceToAdd.name !== generatedName.uniqueLayerName) {\r\n // create a source with a unique name\r\n const clonedSource = MapLayerSource.fromJSON({...source.toJSON(), name: generatedName.uniqueLayerName});\r\n if (clonedSource !== undefined) {\r\n clonedSource.userName = source.userName;\r\n clonedSource.password = source.password;\r\n sourceToAdd = clonedSource;\r\n }\r\n\r\n }\r\n\r\n const settings = sourceToAdd.toLayerSettings(subLayer ? [subLayer] : subLayers);\r\n if (settings) {\r\n activeViewport.displayStyle.attachMapLayer({ settings, mapLayerIndex: {index: -1, isOverlay} });\r\n return generatedName.uniqueLayerName;\r\n }\r\n return undefined;\r\n };\r\n\r\n if (oneMapLayerPerSubLayer && subLayers) {\r\n const layerNamesAttached: string[] = [];\r\n for (const subLayer of subLayers) {\r\n\r\n const attachedLayerName = doAttachLayer(`${source.name} - ${subLayer.name}`, subLayer);\r\n if (attachedLayerName !== undefined) {\r\n layerNamesAttached.push(attachedLayerName);\r\n }\r\n }\r\n\r\n if (layerNamesAttached.length > 0) {\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayersAttached\", { layerNames: layerNamesAttached.join(\", \") });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n }\r\n } else {\r\n const attachedLayerName = doAttachLayer(source.name);\r\n if (attachedLayerName !== undefined) {\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttached\", { sourceName: attachedLayerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n }\r\n }\r\n\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n }\r\n onLayerAttached();\r\n resumeOutsideClick();\r\n }, [activeViewport, backgroundLayers, isOverlay, onLayerAttached, overlayLayers, resumeOutsideClick]);\r\n\r\n const handleSelectFeaturesCancel = React.useCallback( () => {\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n resumeOutsideClick();\r\n UiFramework.dialogs.modal.close();\r\n\r\n }, [resumeOutsideClick, setLoading]);\r\n\r\n const handleSelectFeaturesOk = React.useCallback((source: MapLayerSource, sourceSubLayers: MapSubLayerProps[], selectedSubLayers: MapSubLayerProps[] ) => {\r\n // keep only visible subLayers\r\n const visibleSubLayers = selectedSubLayers.filter((value) => value.visible);\r\n\r\n // Re-apply default visibility from the source validation\r\n visibleSubLayers.forEach((visible) => {\r\n const found = sourceSubLayers.find((value) => {visible.name === value.name;});\r\n if (found)\r\n visible.visible = found?.visible;\r\n });\r\n attachLayer(source, visibleSubLayers, true);\r\n\r\n }, [attachLayer]);\r\n\r\n const openFeatureSelectionDialog = React.useCallback((subLayers: MapSubLayerProps[], source: MapLayerSource ) => {\r\n // Keep leafs sub-layers and force default visibility to false\r\n const noGroupLayers = subLayers.filter((value: MapSubLayerProps) => value.children === undefined);\r\n const visibleLayers = noGroupLayers.map((value: MapSubLayerProps) => {return {...value, visible: false};});\r\n UiFramework.dialogs.modal.open(\r\n <MapSelectFeaturesDialog\r\n handleOk={(selectedLayers) => {handleSelectFeaturesOk(source, subLayers, selectedLayers);}}\r\n handleCancel={handleSelectFeaturesCancel}\r\n source={source}\r\n subLayers={visibleLayers}/>);\r\n }, [handleSelectFeaturesCancel, handleSelectFeaturesOk]);\r\n\r\n const needsFeatureSelection = React.useCallback((source: MapLayerSource, validation: MapLayerSourceValidation ) => {\r\n return (source.formatId === \"ArcGISFeature\" || source.formatId === \"WMTS\") // TODO, replace this with a flag in MapLayerSourceStatus\r\n && validation.subLayers\r\n && validation.subLayers.length > 1;\r\n }, []);\r\n\r\n const handleModalUrlDialogOk = React.useCallback((action: LayerAction, sourceState?: SourceState) => {\r\n UiFramework.dialogs.modal.close();\r\n if (LayerAction.New === action\r\n && sourceState\r\n && (sourceState.validation.status === MapLayerSourceStatus.Valid)) {\r\n if (needsFeatureSelection(sourceState.source, sourceState.validation)) {\r\n openFeatureSelectionDialog(sourceState.validation.subLayers!, sourceState.source);\r\n } else {\r\n attachLayer(sourceState.source, sourceState.validation.subLayers, false);\r\n }\r\n } else {\r\n resumeOutsideClick();\r\n }\r\n }, [attachLayer, needsFeatureSelection, openFeatureSelectionDialog, resumeOutsideClick]);\r\n\r\n const handleModalUrlDialogCancel = React.useCallback(() => {\r\n // close popup and refresh UI\r\n setLoading(false);\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [setLoading, resumeOutsideClick]);\r\n\r\n React.useEffect(() => {\r\n async function attemptToAddLayer() {\r\n if (layerNameToAdd && activeViewport) {\r\n // if the layer is not in the style add it now.\r\n const mapLayerSettings = sources?.find((source) => source.name === layerNameToAdd);\r\n if (mapLayerSettings === undefined) {\r\n return;\r\n }\r\n\r\n try {\r\n if (isMounted.current) {\r\n setLoading(true);\r\n }\r\n\r\n const sourceValidation = await mapLayerSettings.validateSource();\r\n if (sourceValidation.status === MapLayerSourceStatus.Valid || sourceValidation.status === MapLayerSourceStatus.RequireAuth) {\r\n if (sourceValidation.status === MapLayerSourceStatus.Valid) {\r\n if (sourceValidation.subLayers && needsFeatureSelection(mapLayerSettings, sourceValidation)) {\r\n openFeatureSelectionDialog(sourceValidation.subLayers, mapLayerSettings);\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n } else {\r\n attachLayer(mapLayerSettings, sourceValidation.subLayers, false);\r\n }\r\n } else if (sourceValidation.status === MapLayerSourceStatus.RequireAuth && isMounted.current) {\r\n UiFramework.dialogs.modal.open(\r\n <MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n layerRequiringCredentials={mapLayerSettings.toJSON()}\r\n onOkResult={(sourceState?: SourceState) => handleModalUrlDialogOk(LayerAction.New, sourceState)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }\r\n\r\n } else {\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerValidationFailed\", { sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n }\r\n } catch (err) {\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttachError\", { error: err, sourceName: mapLayerSettings.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n return;\r\n }\r\n\r\n attemptToAddLayer(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n if (isMounted.current) {\r\n setLayerNameToAdd(undefined);\r\n }\r\n }, [attachLayer, needsFeatureSelection, setLayerNameToAdd, layerNameToAdd, activeViewport, sources, backgroundLayers, isOverlay, overlayLayers,\r\n onLayerAttached, handleModalUrlDialogOk, handleSelectFeaturesCancel, handleSelectFeaturesOk, mapTypesOptions,\r\n handleModalUrlDialogCancel, onHandleOutsideClick, openFeatureSelectionDialog]);\r\n\r\n const options = React.useMemo(() => sources, [sources]);\r\n\r\n const filteredOptions = React.useMemo(() => {\r\n if (undefined === sourceFilterString || 0 === sourceFilterString.length) {\r\n return options;\r\n } else {\r\n return options?.filter((option) => option.name.toLowerCase().includes(sourceFilterString?.toLowerCase()));\r\n }\r\n }, [options, sourceFilterString]);\r\n\r\n const handleAddNewMapSource = React.useCallback(() => {\r\n UiFramework.dialogs.modal.open(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n onOkResult={(result?: SourceState) => handleModalUrlDialogOk(LayerAction.New, result)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n return;\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick]);\r\n\r\n const handleAttach = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleKeypressOnSourceList = React.useCallback((event: React.KeyboardEvent<HTMLUListElement>) => {\r\n const key = event.key;\r\n if (key === \"Enter\") {\r\n event.preventDefault();\r\n const mapName = event.currentTarget?.dataset?.value;\r\n if (mapName && mapName.length) {\r\n handleAttach(mapName);\r\n }\r\n }\r\n }, [handleAttach]);\r\n\r\n const onListboxValueChange = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleNoConfirmation = React.useCallback((_layerName: string) => {\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n const handleYesConfirmation = React.useCallback(async (source: MapLayerSource) => {\r\n const layerName = source.name;\r\n if (!!iTwinId) {\r\n try {\r\n await MapLayerPreferences.deleteByName(source, iTwinId, iModelId);\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefSuccess\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n } catch (err: any) {\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefError\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [iTwinId, iModelId, resumeOutsideClick]);\r\n\r\n /*\r\n Handle Remove layer button clicked\r\n */\r\n const onItemRemoveButtonClicked = React.useCallback((source, event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const layerName = source.name;\r\n\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogMessage\", { layerName });\r\n UiFramework.dialogs.modal.open(\r\n <ConfirmMessageDialog\r\n className=\"map-sources-delete-confirmation\"\r\n title={removeLayerDefDialogTitle}\r\n message={msg}\r\n maxWidth={400}\r\n onClose={() => handleNoConfirmation(layerName)}\r\n onEscape={() => handleNoConfirmation(layerName)}\r\n onYesResult={async () => handleYesConfirmation(source)}\r\n onNoResult={() => handleNoConfirmation(layerName)}\r\n />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [handleNoConfirmation, handleYesConfirmation, onHandleOutsideClick, removeLayerDefDialogTitle]);\r\n\r\n /*\r\n Handle Edit layer button clicked\r\n */\r\n const onItemEditButtonClicked = React.useCallback((event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const targetLayerName = event?.currentTarget?.parentNode?.dataset?.value;\r\n const matchingSource = sources.find((layerSource) => layerSource.name === targetLayerName);\r\n\r\n // we expect a single layer source matching this name\r\n if (matchingSource === undefined) {\r\n return;\r\n }\r\n UiFramework.dialogs.modal.open(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n mapLayerSourceToEdit={matchingSource}\r\n onOkResult={(result?: SourceState) => handleModalUrlDialogOk(LayerAction.Edit, result)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick, sources]);\r\n\r\n return (\r\n <div className=\"map-manager-header\">\r\n {(loading || loadingSources) && <UiCore.LoadingSpinner message={loadingMapSources} />}\r\n <div className=\"map-manager-source-listbox-header\">\r\n <Input type=\"text\" className=\"map-manager-source-list-filter\"\r\n placeholder={placeholderLabel}\r\n value={sourceFilterString}\r\n onChange={handleFilterTextChanged}\r\n size=\"small\" />\r\n <Button className=\"map-manager-add-source-button\" title={addCustomLayerToolTip} onClick={handleAddNewMapSource}>\r\n {addCustomLayerLabel}</Button>\r\n </div>\r\n <div className=\"map-manager-sources\">\r\n <UiCore.Listbox\r\n id=\"map-sources\"\r\n selectedValue={layerNameToAdd}\r\n className=\"map-manager-source-list\"\r\n onKeyPress={handleKeypressOnSourceList}\r\n onListboxValueChange={onListboxValueChange} >\r\n {\r\n filteredOptions?.map((source) =>\r\n <UiCore.ListboxItem\r\n key={source.name}\r\n className=\"map-source-list-entry\"\r\n value={source.name}\r\n onMouseEnter={() => setLayerNameUnderCursor(source.name)}\r\n onMouseLeave={() => setLayerNameUnderCursor(undefined)}>\r\n <span className=\"map-source-list-entry-name\" title={source.name}>{source.name}</span>\r\n\r\n { // Display the delete icon only when the mouse over a specific item\r\n // otherwise list feels cluttered.\r\n (!!iTwinId && layerNameUnderCursor && layerNameUnderCursor === source.name) &&\r\n <>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={editLayerDefButtonTitle}\r\n onClick={onItemEditButtonClicked}>\r\n <UiCore.Icon iconSpec=\"icon-edit\" />\r\n </Button>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={removeLayerDefButtonTitle}\r\n onClick={(event: React.MouseEvent) => { onItemRemoveButtonClicked(source, event); }}>\r\n <UiCore.Icon iconSpec=\"icon-delete\" />\r\n </Button>\r\n </>}\r\n\r\n </UiCore.ListboxItem>\r\n )\r\n }\r\n </UiCore.Listbox>\r\n </div>\r\n </div>\r\n\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport enum AttachLayerButtonType {\r\n Primary,\r\n Blue,\r\n Icon\r\n}\r\nexport interface AttachLayerPopupButtonProps {\r\n isOverlay: boolean;\r\n buttonType?: AttachLayerButtonType;\r\n disabled?: boolean;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function AttachLayerPopupButton(props: AttachLayerPopupButtonProps) {\r\n const { showAttachLayerLabel, hideAttachLayerLabel, addCustomLayerButtonLabel } = React.useMemo(() => {\r\n return {\r\n showAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Attach\"),\r\n hideAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Close\"),\r\n addCustomLayerButtonLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AddCustomLayerButtonLabel\"),\r\n };\r\n }, []);\r\n\r\n const [handleOutsideClick, setHandleOutsideClick] = React.useState(true);\r\n const [popupOpen, setPopupOpen] = React.useState(false);\r\n const buttonRef = React.useRef<HTMLButtonElement>(null);\r\n const panelRef = React.useRef<HTMLDivElement>(null);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n };\r\n }, []);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setPopupOpen(!popupOpen);\r\n }, [popupOpen]);\r\n\r\n const handleClosePopup = React.useCallback(() => {\r\n setPopupOpen(false);\r\n }, []);\r\n\r\n const onHandleOutsideClick = React.useCallback((event: MouseEvent) => {\r\n if (!handleOutsideClick) {\r\n return;\r\n }\r\n\r\n // If clicking on button that open panel - don't trigger outside click processing\r\n if (buttonRef?.current && buttonRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If clicking the panel, this is not an outside clicked\r\n if (panelRef.current && panelRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If we reach this point, we got an outside clicked, no close the popup\r\n setPopupOpen(false);\r\n\r\n }, [handleOutsideClick]);\r\n\r\n const { refreshFromStyle } = useSourceMapContext();\r\n\r\n const handleLayerAttached = React.useCallback(() => {\r\n if (!isMounted.current) {\r\n return;\r\n }\r\n setPopupOpen(false);\r\n refreshFromStyle();\r\n }, [refreshFromStyle]);\r\n\r\n function renderButton(): React.ReactNode {\r\n let button: React.ReactNode;\r\n\r\n if (props.buttonType === undefined || props.buttonType === AttachLayerButtonType.Icon) {\r\n button = (\r\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" ref={buttonRef} className=\"map-manager-attach-layer-button\" title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>\r\n <UiCore.WebFontIcon iconName=\"icon-add\" />\r\n </Button>\r\n );\r\n } else {\r\n const determineStyleType = () => {\r\n switch (props.buttonType) {\r\n case AttachLayerButtonType.Blue:\r\n return \"high-visibility\";\r\n case AttachLayerButtonType.Primary:\r\n default:\r\n return \"cta\";\r\n }\r\n };\r\n const styleType = determineStyleType();\r\n button = (\r\n <Button disabled={props.disabled} ref={buttonRef} styleType={styleType} title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>{addCustomLayerButtonLabel}</Button>\r\n );\r\n }\r\n\r\n return button;\r\n }\r\n\r\n return (\r\n <>\r\n {renderButton()}\r\n <UiCore.Popup\r\n isOpen={popupOpen}\r\n position={RelativePosition.BottomRight}\r\n onClose={handleClosePopup}\r\n onOutsideClick={onHandleOutsideClick}\r\n closeOnWheel={false}\r\n target={buttonRef.current}\r\n closeOnEnter={false}\r\n closeOnContextMenu={false}\r\n >\r\n <div ref={panelRef} className=\"map-sources-popup-panel\" >\r\n <AttachLayerPanel\r\n isOverlay={props.isOverlay}\r\n onLayerAttached={handleLayerAttached}\r\n onHandleOutsideClick={setHandleOutsideClick} />\r\n </div>\r\n </UiCore.Popup >\r\n </>\r\n );\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasemapPanel.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BasemapPanel.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,qBAAqB,CAAC;AAY7B,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAiLpD"}
|
|
@@ -11,14 +11,14 @@ import { ColorPickerDialog, ColorSwatch } from "@itwin/imodel-components-react";
|
|
|
11
11
|
import { Button, Select } from "@itwin/itwinui-react";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { MapLayersUI } from "../../mapLayers";
|
|
14
|
-
import "./BasemapPanel.scss";
|
|
15
14
|
import { useSourceMapContext } from "./MapLayerManager";
|
|
16
15
|
import { TransparencyPopupButton } from "./TransparencyPopupButton";
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import "./BasemapPanel.scss";
|
|
17
|
+
function getBaseMapFromStyle(backgroundBase) {
|
|
18
|
+
if (!backgroundBase)
|
|
19
19
|
return undefined;
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
20
|
+
if (backgroundBase instanceof ImageMapLayerSettings || backgroundBase instanceof ColorDef)
|
|
21
|
+
return backgroundBase.toJSON();
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
24
|
/** @internal */
|
|
@@ -26,11 +26,23 @@ function getBaseMapFromStyle(displayStyle) {
|
|
|
26
26
|
export function BasemapPanel(props) {
|
|
27
27
|
const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:Basemap.ColorFill"));
|
|
28
28
|
const { activeViewport, bases } = useSourceMapContext();
|
|
29
|
-
const [selectedBaseMap, setSelectedBaseMap] = React.useState(getBaseMapFromStyle(activeViewport?.displayStyle));
|
|
29
|
+
const [selectedBaseMap, setSelectedBaseMap] = React.useState(getBaseMapFromStyle(activeViewport?.displayStyle.settings.mapImagery.backgroundBase));
|
|
30
30
|
const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {
|
|
31
|
-
if (activeViewport)
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (activeViewport) {
|
|
32
|
+
const mapImagery = activeViewport.displayStyle.settings.mapImagery;
|
|
33
|
+
if (mapImagery.backgroundBase instanceof ImageMapLayerSettings) {
|
|
34
|
+
return mapImagery.backgroundBase.transparency;
|
|
35
|
+
}
|
|
36
|
+
else if (mapImagery.backgroundBase instanceof ColorDef) {
|
|
37
|
+
return mapImagery.backgroundBase.getAlpha() / 255;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
34
46
|
});
|
|
35
47
|
const [baseMapVisible, setBaseMapVisible] = React.useState(() => {
|
|
36
48
|
if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {
|
|
@@ -38,17 +50,34 @@ export function BasemapPanel(props) {
|
|
|
38
50
|
}
|
|
39
51
|
return false;
|
|
40
52
|
});
|
|
53
|
+
const handleMapImageryChanged = React.useCallback((args) => {
|
|
54
|
+
// selectedBaseMap
|
|
55
|
+
const baseMap = getBaseMapFromStyle(args.backgroundBase);
|
|
56
|
+
if (JSON.stringify(baseMap) !== JSON.stringify(selectedBaseMap))
|
|
57
|
+
setSelectedBaseMap(baseMap);
|
|
58
|
+
// baseMapTransparencyValue
|
|
59
|
+
if (args.backgroundBase instanceof ImageMapLayerSettings && args.backgroundBase.transparency !== baseMapTransparencyValue) {
|
|
60
|
+
setBaseMapTransparencyValue(args.backgroundBase.transparency);
|
|
61
|
+
}
|
|
62
|
+
else if (args.backgroundBase instanceof ColorDef && args.backgroundBase.getAlpha() !== baseMapTransparencyValue) {
|
|
63
|
+
setBaseMapTransparencyValue(args.backgroundBase.getAlpha() / 255);
|
|
64
|
+
}
|
|
65
|
+
// baseMapVisible
|
|
66
|
+
if (args.backgroundBase instanceof ImageMapLayerSettings && args.backgroundBase.visible !== baseMapVisible) {
|
|
67
|
+
setBaseMapVisible(args.backgroundBase.visible);
|
|
68
|
+
}
|
|
69
|
+
}, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap, setBaseMapTransparencyValue, setBaseMapVisible, setSelectedBaseMap]);
|
|
70
|
+
// Monitor display style's onMapImageryChanged event
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);
|
|
73
|
+
}, [activeViewport, handleMapImageryChanged]);
|
|
41
74
|
// Monitor viewport updates, and refresh the widget accordingly.
|
|
42
75
|
// Note: This is needed for multiple viewport applications.
|
|
43
76
|
React.useEffect(() => {
|
|
44
77
|
if (activeViewport) {
|
|
45
|
-
|
|
46
|
-
setSelectedBaseMap(getBaseMapFromStyle(activeViewport.displayStyle));
|
|
47
|
-
if (activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {
|
|
48
|
-
setBaseMapVisible(activeViewport.displayStyle.backgroundMapBase.visible);
|
|
49
|
-
}
|
|
78
|
+
handleMapImageryChanged(activeViewport.displayStyle.settings.mapImagery);
|
|
50
79
|
}
|
|
51
|
-
}, [activeViewport]);
|
|
80
|
+
}, [activeViewport, handleMapImageryChanged]);
|
|
52
81
|
const handleBasemapTransparencyChange = React.useCallback((transparency) => {
|
|
53
82
|
if (activeViewport) {
|
|
54
83
|
activeViewport.displayStyle.changeBaseMapTransparency(transparency);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C,2CAA2C;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,qBAAqB,EAAiB,MAAM,oBAAoB,CAAC;AAEvH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAgB,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,SAAS,mBAAmB,CAAC,YAA2C;IACtE,IAAI,CAAC,YAAY;QACf,OAAO,SAAS,CAAC;IAEnB,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,YAAY,qBAAqB,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,YAAY,QAAQ;QACzJ,OAAO,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;IAElE,OAAO,SAAS,CAAC;AACnB,CAAC;AAMD,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,CAAC,aAAa,CAAC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;gBACX,oBAAC,WAAW,IAAC,SAAS,EAAC,6BAA6B,EAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,GAAI;YAE9I,oBAAC,uBAAuB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,CAChJ,CACL,CACJ,CAAC;AACJ,CAAC","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/* eslint-disable deprecation/deprecation */\n// cSpell:ignore droppable Sublayer Basemap\n\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings, MapLayerProps } from \"@itwin/core-common\";\nimport { DisplayStyleState } from \"@itwin/core-frontend\";\nimport { WebFontIcon } from \"@itwin/core-react\";\nimport { ColorPickerDialog, ColorSwatch } from \"@itwin/imodel-components-react\";\nimport { Button, Select, SelectOption } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport \"./BasemapPanel.scss\";\nimport { useSourceMapContext } from \"./MapLayerManager\";\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\n\nfunction getBaseMapFromStyle(displayStyle: DisplayStyleState | undefined) {\n if (!displayStyle)\n return undefined;\n\n if (displayStyle.settings.mapImagery.backgroundBase instanceof ImageMapLayerSettings || displayStyle.settings.mapImagery.backgroundBase instanceof ColorDef)\n return displayStyle.settings.mapImagery.backgroundBase.toJSON();\n\n return undefined;\n}\n\ninterface BasemapPanelProps {\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function BasemapPanel(props: BasemapPanelProps) {\n const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\n const { activeViewport, bases } = useSourceMapContext();\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<MapLayerProps | number | undefined>(getBaseMapFromStyle(activeViewport?.displayStyle));\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\n if (activeViewport)\n return activeViewport.displayStyle.baseMapTransparency;\n return 0;\n });\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n return activeViewport.displayStyle.backgroundMapBase.visible;\n }\n return false;\n });\n\n // Monitor viewport updates, and refresh the widget accordingly.\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n if (activeViewport) {\n setBaseMapTransparencyValue(activeViewport.displayStyle.baseMapTransparency);\n setSelectedBaseMap(getBaseMapFromStyle(activeViewport.displayStyle));\n if (activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n setBaseMapVisible(activeViewport.displayStyle.backgroundMapBase.visible);\n }\n }\n }, [activeViewport]);\n\n const handleBasemapTransparencyChange = React.useCallback((transparency: number) => {\n if (activeViewport) {\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\n setBaseMapTransparencyValue(transparency);\n }\n }, [activeViewport]);\n\n const baseMapOptions = React.useMemo<SelectOption<string>[]>(() => {\n const baseOptions: SelectOption<string>[] = [];\n\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\n\n if (bases)\n baseOptions.push(...bases.map((value) => ({ value: value.name, label: value.name })));\n return baseOptions;\n }, [bases, useColorLabel]);\n\n const [presetColors] = React.useState([\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ]);\n\n const baseIsColor = React.useMemo(() => typeof selectedBaseMap === \"number\", [selectedBaseMap]);\n const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);\n const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap as number : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);\n const [colorDialogTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:ColorDialog.Title\"));\n const selectedBaseMapValue = React.useMemo(() => {\n if (baseIsMap) {\n const mapName = (selectedBaseMap! as MapLayerProps).name;\n const foundItem = baseMapOptions.find((value) => value.label === mapName);\n if (foundItem)\n return foundItem;\n }\n return baseMapOptions[0];\n }, [selectedBaseMap, baseMapOptions, baseIsMap]);\n\n const handleBackgroundColorDialogOk = React.useCallback((bgColorDef: ColorDef) => {\n UiFramework.dialogs.modal.close();\n if (activeViewport) {\n // change color and make sure previously set transparency is not lost.\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef.toJSON());\n }\n }, [activeViewport]);\n\n const handleBackgroundColorDialogCancel = React.useCallback(() => {\n UiFramework.dialogs.modal.close();\n }, []);\n\n const handleBgColorClick = React.useCallback((newColor: ColorDef, e: React.MouseEvent<Element, MouseEvent>) => {\n e.preventDefault();\n UiFramework.dialogs.modal.open(<ColorPickerDialog dialogTitle={colorDialogTitle} color={newColor} colorPresets={presetColors} colorInputType={\"rgb\"}\n onOkResult={handleBackgroundColorDialogOk} onCancelResult={handleBackgroundColorDialogCancel} />);\n }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleBaseMapSelection = React.useCallback((value: string) => {\n if (bases && activeViewport && value) {\n const baseMap = bases.find((map) => map.name === value);\n if (baseMap) {\n const baseProps: MapLayerProps = baseMap.toJSON();\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone(baseProps);\n } else {\n activeViewport.displayStyle.backgroundMapBase = BaseMapLayerSettings.fromJSON(baseProps);\n }\n setSelectedBaseMap(baseProps);\n } else {\n const bgColorDef = ColorDef.fromJSON(bgColor);\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef.toJSON());\n }\n }\n }, [bases, activeViewport, bgColor]);\n\n const handleVisibilityChange = React.useCallback(() => {\n if (activeViewport) {\n const newState = !baseMapVisible;\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\n }\n setBaseMapVisible(newState);\n }\n }, [baseMapVisible, activeViewport]);\n\n const [baseLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\n const [selectBaseMapLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n\n return (\n <>\n <div className=\"map-manager-base-item\" >\n <Button size=\"small\" styleType=\"borderless\" title={toggleVisibility} onClick={handleVisibilityChange} disabled={props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings)}>\n <WebFontIcon iconName={baseMapVisible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\n <Select className=\"map-manager-base-item-select\"\n options={baseMapOptions}\n placeholder={selectBaseMapLabel}\n value={selectedBaseMapValue.value}\n onChange={handleBaseMapSelection} size=\"small\"\n disabled={props.disabled}\n />\n {\n baseIsColor &&\n <ColorSwatch className=\"map-manager-base-item-color\" colorDef={ColorDef.fromJSON(bgColor)} round={false} onColorPick={handleBgColorClick} />\n }\n <TransparencyPopupButton disabled={props.disabled} transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\n </div>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C,2CAA2C;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAqC,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,qBAAqB,EAAqC,MAAM,oBAAoB,CAAC;AAC9K,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAgB,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,qBAAqB,CAAC;AAE7B,SAAS,mBAAmB,CAAC,cAA6C;IACxE,IAAI,CAAC,cAAc;QACjB,OAAO,SAAS,CAAC;IAEnB,IAAI,cAAc,YAAY,qBAAqB,IAAI,cAAc,YAAY,QAAQ;QACvF,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC;IAEjC,OAAO,SAAS,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,IAAC,SAAS,EAAC,8BAA8B,EAC9C,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,oBAAoB,CAAC,KAAK,EACjC,QAAQ,EAAE,sBAAsB,EAAE,IAAI,EAAC,OAAO,EAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB;YAEA,WAAW;gBACX,oBAAC,WAAW,IAAC,SAAS,EAAC,6BAA6B,EAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,GAAI;YAE9I,oBAAC,uBAAuB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,CAChJ,CACL,CACJ,CAAC;AACJ,CAAC","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/* eslint-disable deprecation/deprecation */\n// cSpell:ignore droppable Sublayer Basemap\n\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { BaseLayerProps, BaseLayerSettings, BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings, MapImagerySettings, MapLayerProps } from \"@itwin/core-common\";\nimport { WebFontIcon } from \"@itwin/core-react\";\nimport { ColorPickerDialog, ColorSwatch } from \"@itwin/imodel-components-react\";\nimport { Button, Select, SelectOption } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { useSourceMapContext } from \"./MapLayerManager\";\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\nimport \"./BasemapPanel.scss\";\n\nfunction getBaseMapFromStyle(backgroundBase: BaseLayerSettings | undefined) {\n if (!backgroundBase)\n return undefined;\n\n if (backgroundBase instanceof ImageMapLayerSettings || backgroundBase instanceof ColorDef)\n return backgroundBase.toJSON();\n\n return undefined;\n}\n\ninterface BasemapPanelProps {\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function BasemapPanel(props: BasemapPanelProps) {\n const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\n const { activeViewport, bases } = useSourceMapContext();\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<BaseLayerProps | undefined>(getBaseMapFromStyle(activeViewport?.displayStyle.settings.mapImagery.backgroundBase));\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\n if (activeViewport) {\n const mapImagery = activeViewport.displayStyle.settings.mapImagery;\n if (mapImagery.backgroundBase instanceof ImageMapLayerSettings) {\n return mapImagery.backgroundBase.transparency;\n } else if (mapImagery.backgroundBase instanceof ColorDef ) {\n return mapImagery.backgroundBase.getAlpha()/255;\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n });\n\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n return activeViewport.displayStyle.backgroundMapBase.visible;\n }\n return false;\n });\n\n const handleMapImageryChanged = React.useCallback((args: Readonly<MapImagerySettings>) => {\n // selectedBaseMap\n const baseMap = getBaseMapFromStyle(args.backgroundBase);\n if (JSON.stringify(baseMap) !== JSON.stringify(selectedBaseMap))\n setSelectedBaseMap(baseMap);\n\n // baseMapTransparencyValue\n if (args.backgroundBase instanceof ImageMapLayerSettings && args.backgroundBase.transparency !== baseMapTransparencyValue) {\n setBaseMapTransparencyValue(args.backgroundBase.transparency);\n } else if (args.backgroundBase instanceof ColorDef && args.backgroundBase.getAlpha() !== baseMapTransparencyValue ) {\n setBaseMapTransparencyValue(args.backgroundBase.getAlpha()/255);\n }\n\n // baseMapVisible\n if (args.backgroundBase instanceof ImageMapLayerSettings && args.backgroundBase.visible !== baseMapVisible) {\n setBaseMapVisible(args.backgroundBase.visible);\n }\n }, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap, setBaseMapTransparencyValue, setBaseMapVisible, setSelectedBaseMap]);\n\n // Monitor display style's onMapImageryChanged event\n React.useEffect(() => {\n return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly.\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n if (activeViewport) {\n handleMapImageryChanged(activeViewport.displayStyle.settings.mapImagery);\n }\n }, [activeViewport, handleMapImageryChanged]);\n\n const handleBasemapTransparencyChange = React.useCallback((transparency: number) => {\n if (activeViewport) {\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\n setBaseMapTransparencyValue(transparency);\n }\n }, [activeViewport]);\n\n const baseMapOptions = React.useMemo<SelectOption<string>[]>(() => {\n const baseOptions: SelectOption<string>[] = [];\n\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\n\n if (bases)\n baseOptions.push(...bases.map((value) => ({ value: value.name, label: value.name })));\n return baseOptions;\n }, [bases, useColorLabel]);\n\n const [presetColors] = React.useState([\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ]);\n\n const baseIsColor = React.useMemo(() => typeof selectedBaseMap === \"number\", [selectedBaseMap]);\n const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);\n const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap as number : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);\n const [colorDialogTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:ColorDialog.Title\"));\n const selectedBaseMapValue = React.useMemo(() => {\n if (baseIsMap) {\n const mapName = (selectedBaseMap! as MapLayerProps).name;\n const foundItem = baseMapOptions.find((value) => value.label === mapName);\n if (foundItem)\n return foundItem;\n }\n return baseMapOptions[0];\n }, [selectedBaseMap, baseMapOptions, baseIsMap]);\n\n const handleBackgroundColorDialogOk = React.useCallback((bgColorDef: ColorDef) => {\n UiFramework.dialogs.modal.close();\n if (activeViewport) {\n // change color and make sure previously set transparency is not lost.\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef.toJSON());\n }\n }, [activeViewport]);\n\n const handleBackgroundColorDialogCancel = React.useCallback(() => {\n UiFramework.dialogs.modal.close();\n }, []);\n\n const handleBgColorClick = React.useCallback((newColor: ColorDef, e: React.MouseEvent<Element, MouseEvent>) => {\n e.preventDefault();\n UiFramework.dialogs.modal.open(<ColorPickerDialog dialogTitle={colorDialogTitle} color={newColor} colorPresets={presetColors} colorInputType={\"rgb\"}\n onOkResult={handleBackgroundColorDialogOk} onCancelResult={handleBackgroundColorDialogCancel} />);\n }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleBaseMapSelection = React.useCallback((value: string) => {\n if (bases && activeViewport && value) {\n const baseMap = bases.find((map) => map.name === value);\n if (baseMap) {\n const baseProps: MapLayerProps = baseMap.toJSON();\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone(baseProps);\n } else {\n activeViewport.displayStyle.backgroundMapBase = BaseMapLayerSettings.fromJSON(baseProps);\n }\n setSelectedBaseMap(baseProps);\n } else {\n const bgColorDef = ColorDef.fromJSON(bgColor);\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef.toJSON());\n }\n }\n }, [bases, activeViewport, bgColor]);\n\n const handleVisibilityChange = React.useCallback(() => {\n if (activeViewport) {\n const newState = !baseMapVisible;\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\n }\n setBaseMapVisible(newState);\n }\n }, [baseMapVisible, activeViewport]);\n\n const [baseLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\n const [selectBaseMapLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n\n return (\n <>\n <div className=\"map-manager-base-item\" >\n <Button size=\"small\" styleType=\"borderless\" title={toggleVisibility} onClick={handleVisibilityChange} disabled={props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings)}>\n <WebFontIcon iconName={baseMapVisible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\n <Select className=\"map-manager-base-item-select\"\n options={baseMapOptions}\n placeholder={selectBaseMapLabel}\n value={selectedBaseMapValue.value}\n onChange={handleBaseMapSelection} size=\"small\"\n disabled={props.disabled}\n />\n {\n baseIsColor &&\n <ColorSwatch className=\"map-manager-base-item-color\" colorDef={ColorDef.fromJSON(bgColor)} round={false} onColorPick={handleBgColorClick} />\n }\n <TransparencyPopupButton disabled={props.disabled} transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\n </div>\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerDroppable.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAWA,OAAO,
|
|
1
|
+
{"version":3,"file":"MapLayerDroppable.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAyI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO7L,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,wBAAwB,CAAC;AAIhC,gBAAgB;AAChB,UAAU,sBAAsB;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACrC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,EAAE,MAAM,WAAW,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;IAC/B,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACtF,6BAA6B,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjF,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA4J9D"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { Draggable, Droppable } from "react-beautiful-dnd";
|
|
10
|
-
import { MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility } from "@itwin/core-frontend";
|
|
10
|
+
import { IModelApp, MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility, NotifyMessageDetails, OutputMessagePriority } from "@itwin/core-frontend";
|
|
11
11
|
import { Icon } from "@itwin/core-react";
|
|
12
12
|
import { assert } from "@itwin/core-bentley";
|
|
13
13
|
import { UiFramework } from "@itwin/appui-react";
|
|
@@ -35,6 +35,28 @@ export function MapLayerDroppable(props) {
|
|
|
35
35
|
if (mapLayerStyleIdx !== -1 && activeLayer.subLayers)
|
|
36
36
|
props.activeViewport.displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: mapLayerStyleIdx, isOverlay: activeLayer.isOverlay });
|
|
37
37
|
};
|
|
38
|
+
const handleOk = React.useCallback((index, sourceState) => {
|
|
39
|
+
UiFramework.dialogs.modal.close();
|
|
40
|
+
const source = sourceState?.source;
|
|
41
|
+
const vp = props?.activeViewport;
|
|
42
|
+
if (vp === undefined || sourceState === undefined || source === undefined) {
|
|
43
|
+
const error = MapLayersUI.localization.getLocalizedString("mapLayers:Messages.MapLayerAttachMissingViewOrSource");
|
|
44
|
+
const msg = MapLayersUI.localization.getLocalizedString("mapLayers:Messages.MapLayerAttachError", { error, sourceName: source?.name ?? "" });
|
|
45
|
+
IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const validation = sourceState.validation;
|
|
49
|
+
// Layer is already attached,
|
|
50
|
+
// This calls invalidateRenderPlan()
|
|
51
|
+
vp.displayStyle.changeMapLayerProps({ subLayers: validation.subLayers }, index);
|
|
52
|
+
vp.displayStyle.changeMapLayerCredentials(index, source.userName, source.password);
|
|
53
|
+
// Either initial attach/initialize failed or the layer failed to load at least one tile
|
|
54
|
+
// because of an invalid token; in both cases tile tree needs to be fully reset
|
|
55
|
+
const provider = vp.getMapLayerImageryProvider(index);
|
|
56
|
+
provider?.resetStatus();
|
|
57
|
+
vp.resetMapLayer(index);
|
|
58
|
+
props.onItemEdited();
|
|
59
|
+
}, [props]);
|
|
38
60
|
const renderItem = (dragProvided, _, rubric) => {
|
|
39
61
|
assert(props.layersList !== undefined);
|
|
40
62
|
const activeLayer = props.layersList[rubric.source.index];
|
|
@@ -44,14 +66,15 @@ export function MapLayerDroppable(props) {
|
|
|
44
66
|
React.createElement(Icon, { iconSpec: activeLayer.visible ? "icon-visibility" : "icon-visibility-hide-2" })),
|
|
45
67
|
React.createElement("span", { className: props.disabled || outOfRange ? "map-manager-item-label-disabled" : "map-manager-item-label", title: outOfRange ? outOfRangeTitle : undefined, ...dragProvided.dragHandleProps }, activeLayer.name),
|
|
46
68
|
React.createElement("div", { className: "map-manager-item-sub-layer-container" }, activeLayer.subLayers && activeLayer.subLayers.length > 1 &&
|
|
47
|
-
React.createElement(SubLayersPopupButton, { subLayers: props.activeViewport ? activeLayer.subLayers : undefined, singleVisibleSubLayer: activeLayer.provider?.mutualExclusiveSubLayer, onSubLayerStateChange: (subLayerId, isSelected) => { onSubLayerStateChange(activeLayer, subLayerId, isSelected); } })),
|
|
69
|
+
React.createElement(SubLayersPopupButton, { checkboxStyle: "eye", expandMode: "rootGroupOnly", subLayers: props.activeViewport ? activeLayer.subLayers : undefined, singleVisibleSubLayer: activeLayer.provider?.mutualExclusiveSubLayer, onSubLayerStateChange: (subLayerId, isSelected) => { onSubLayerStateChange(activeLayer, subLayerId, isSelected); } })),
|
|
48
70
|
activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&
|
|
49
71
|
React.createElement(Button, { disabled: props.disabled, size: "small", styleType: "borderless", onClick: () => {
|
|
50
72
|
const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);
|
|
51
73
|
if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {
|
|
52
|
-
const
|
|
74
|
+
const index = { index: indexInDisplayStyle, isOverlay: activeLayer.isOverlay };
|
|
75
|
+
const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(index);
|
|
53
76
|
if (layerSettings instanceof ImageMapLayerSettings) {
|
|
54
|
-
UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: props.activeViewport, isOverlay: props.isOverlay, layerRequiringCredentials: layerSettings?.toJSON(), onOkResult:
|
|
77
|
+
UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: props.activeViewport, isOverlay: props.isOverlay, layerRequiringCredentials: layerSettings?.toJSON(), onOkResult: (sourceState) => handleOk(index, sourceState), onCancelResult: () => { UiFramework.dialogs.modal.close(); }, mapTypesOptions: props.mapTypesOptions }));
|
|
55
78
|
}
|
|
56
79
|
}
|
|
57
80
|
}, title: requireAuthTooltip },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerDroppable.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,2CAA2C;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAuB,SAAS,EAA6C,MAAM,qBAAqB,CAAC;AAC3H,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAkB,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,E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K,EAAE,KAAK,EAAE,SAAS,EAAC,iCAAiC,IAC3D,QAAQ,CAAC,cAAc,CAAC,CAAC;oBACxB,8BAAM,SAAS,EAAC,6BAA6B,IAAE,cAAc,CAAQ;oBACrE,CAAC;wBACD;4BACE,8BAAM,SAAS,EAAC,6BAA6B,IAAE,KAAK,CAAQ;4BAC5D,oBAAC,sBAAsB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAI,CACvH,CAED,CAAC;SACV;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,eAAe,CAAC,YAA+B,EAAE,YAAoC;QAC5F,OAAO,CACL,6BAAK,SAAS,EAAE,0BAA0B,YAAY,CAAC,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC,QAAQ,KAAM,YAAY,CAAC,cAAc;YAEjL,sBAAsB,CAAC,YAAY,CAAC;YAOrC,6BAAK,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,YAAY,CAAC,WAAW,CAAO,CACzF,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CACL,oBAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,IAEtD,eAAe,CACN,CACb,CAAC;AACJ,CAAC","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// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { ImageMapLayerSettings, SubLayerId } from \"@itwin/core-common\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.layerOutOfRange\"));\n\n const onSubLayerStateChange = (activeLayer: StyleMapLayerSettings, subLayerId: SubLayerId, isSelected: boolean) => {\n const mapLayerStyleIdx = props.activeViewport.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (mapLayerStyleIdx !== -1 && activeLayer.subLayers)\n props.activeViewport.displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: mapLayerStyleIdx, isOverlay: activeLayer.isOverlay });\n };\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n {/* Visibility icon */}\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n {/* Label */}\n <span className={props.disabled || outOfRange ? \"map-manager-item-label-disabled\" : \"map-manager-item-label\"}\n title={outOfRange ? outOfRangeTitle : undefined}\n {...dragProvided.dragHandleProps}\n\n >\n {activeLayer.name}\n </span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton\n subLayers={props.activeViewport ? activeLayer.subLayers : undefined}\n singleVisibleSubLayer={activeLayer.provider?.mutualExclusiveSubLayer}\n onSubLayerStateChange={(subLayerId: SubLayerId, isSelected: boolean) => { onSubLayerStateChange(activeLayer, subLayerId, isSelected); }} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n disabled={props.disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex({ index: indexInDisplayStyle, isOverlay: activeLayer.isOverlay });\n if (layerSettings instanceof ImageMapLayerSettings) {\n UiFramework.dialogs.modal.open(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={props.onItemEdited}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon className=\"map-layer-source-item-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} disabled={props.disabled} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable isDragDisabled={props.disabled} key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton disabled={props.disabled} buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MapLayerDroppable.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,2CAA2C;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAuB,SAAS,EAA6C,MAAM,qBAAqB,CAAC;AAC3H,OAAO,EAAE,SAAS,EAAE,6BAA6B,EAAiB,+BAA+B,EAAE,oBAAoB,EAAE,qBAAqB,EAAkB,MAAM,sBAAsB,CAAC;AAC7L,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO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CAAC,cAAc;YAEjL,sBAAsB,CAAC,YAAY,CAAC;YAOrC,6BAAK,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,YAAY,CAAC,WAAW,CAAO,CACzF,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CACL,oBAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,IAEtD,eAAe,CACN,CACb,CAAC;AACJ,CAAC","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// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { IModelApp, MapLayerImageryProviderStatus, MapLayerIndex, MapTileTreeScaleRangeVisibility, NotifyMessageDetails, OutputMessagePriority, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog, SourceState } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { ImageMapLayerSettings, SubLayerId } from \"@itwin/core-common\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.layerOutOfRange\"));\n\n const onSubLayerStateChange = (activeLayer: StyleMapLayerSettings, subLayerId: SubLayerId, isSelected: boolean) => {\n const mapLayerStyleIdx = props.activeViewport.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (mapLayerStyleIdx !== -1 && activeLayer.subLayers)\n props.activeViewport.displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: mapLayerStyleIdx, isOverlay: activeLayer.isOverlay });\n };\n\n const handleOk = React.useCallback((index: MapLayerIndex, sourceState?: SourceState) => {\n UiFramework.dialogs.modal.close();\n\n const source = sourceState?.source;\n const vp = props?.activeViewport;\n if (vp === undefined || sourceState === undefined || source === undefined) {\n const error = MapLayersUI.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttachMissingViewOrSource\");\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttachError\", { error, sourceName: source?.name ?? \"\" });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\n return;\n }\n\n const validation = sourceState.validation;\n\n // Layer is already attached,\n // This calls invalidateRenderPlan()\n vp.displayStyle.changeMapLayerProps({subLayers: validation.subLayers}, index);\n vp.displayStyle.changeMapLayerCredentials(index, source.userName, source.password);\n\n // Either initial attach/initialize failed or the layer failed to load at least one tile\n // because of an invalid token; in both cases tile tree needs to be fully reset\n const provider = vp.getMapLayerImageryProvider(index);\n provider?.resetStatus();\n vp.resetMapLayer(index);\n\n props.onItemEdited();\n }, [props]);\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n {/* Visibility icon */}\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n {/* Label */}\n <span className={props.disabled || outOfRange ? \"map-manager-item-label-disabled\" : \"map-manager-item-label\"}\n title={outOfRange ? outOfRangeTitle : undefined}\n {...dragProvided.dragHandleProps}\n\n >\n {activeLayer.name}\n </span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton\n checkboxStyle=\"eye\"\n expandMode=\"rootGroupOnly\"\n subLayers={props.activeViewport ? activeLayer.subLayers : undefined}\n singleVisibleSubLayer={activeLayer.provider?.mutualExclusiveSubLayer}\n onSubLayerStateChange={(subLayerId: SubLayerId, isSelected: boolean) => { onSubLayerStateChange(activeLayer, subLayerId, isSelected); }} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n disabled={props.disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const index = { index: indexInDisplayStyle, isOverlay: activeLayer.isOverlay };\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(index);\n if (layerSettings instanceof ImageMapLayerSettings) {\n UiFramework.dialogs.modal.open(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={(sourceState?: SourceState) => handleOk(index, sourceState)}\n onCancelResult={() => {UiFramework.dialogs.modal.close();}}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon className=\"map-layer-source-item-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} disabled={props.disabled} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable isDragDisabled={props.disabled} key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton disabled={props.disabled} buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerManager.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerManager.tsx"],"names":[],"mappings":"AAWA,OAAO,EACiF,cAAc,EACpG,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAIvE,OAAO,wBAAwB,CAAC;AAIhC,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CA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