@arcgis/core 4.34.0-next.2 → 4.34.0-next.4
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/Map.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{bf3555f91492a1a3b613.js → 09f76ca9b47b465c934f.js} +1 -1
- package/assets/esri/core/workers/chunks/{397b15d46f22718c9f38.js → 0d78fc2c2bc1152f84db.js} +1 -1
- package/assets/esri/core/workers/chunks/{ead5d4e271effc04def3.js → 1415d4e2f5f3193be004.js} +1 -1
- package/assets/esri/core/workers/chunks/17e43a050fbf8dc87588.js +1 -0
- package/assets/esri/core/workers/chunks/{ac2607f1e8cd2e99907c.js → 1bc4cb6366e733a7c7ef.js} +2 -2
- package/assets/esri/core/workers/chunks/1ee6e9a88f0676032e91.js +1 -0
- package/assets/esri/core/workers/chunks/{ece68a25651ef03fc95d.js → 342f61e784c9364a493b.js} +1 -1
- package/assets/esri/core/workers/chunks/3adcf78ed1e7cd82666d.js +1 -0
- package/assets/esri/core/workers/chunks/{07e58dff44fcbb3b3539.js → 562800b0af52a38a311b.js} +1 -1
- package/assets/esri/core/workers/chunks/{32ee2708edd307954125.js → 7174150bf7595c22f976.js} +1 -1
- package/assets/esri/core/workers/chunks/{e77371ddbaf4b2d9be8d.js → 74c0db9e3a62e9839b23.js} +1 -1
- package/assets/esri/core/workers/chunks/{aba19485b6cdcb70dac6.js → 8008f5479f4d16964088.js} +1 -1
- package/assets/esri/core/workers/chunks/{40f54c4f8ae63c6f3df9.js → a32dcd5bc4680374d30c.js} +1 -1
- package/assets/esri/core/workers/chunks/ad4f65d764654c70a117.js +1 -0
- package/assets/esri/core/workers/chunks/{d7b640f7a181bd26c7c7.js → bac5e1d50b69f0d94694.js} +1 -1
- package/assets/esri/core/workers/chunks/{9ca480eb8b2312381ccf.js → bcadcb709e622f2aaaf9.js} +1 -1
- package/assets/esri/core/workers/chunks/{677af0281e4fc9f3bd98.js → c6cd8784a3e222eb2d4a.js} +1 -1
- package/assets/esri/core/workers/chunks/{54f4a1131f99468db076.js → d33a5d79f2163ad62b1d.js} +1 -1
- package/assets/esri/core/workers/chunks/{e3c1aea34ece8336dae1.js → e9aa1d9ded8a52a40c57.js} +1 -1
- package/assets/esri/core/workers/chunks/f2aa8090827086c62dde.js +1 -0
- package/assets/esri/core/workers/chunks/fd4c020297badcb81947.js +1 -0
- package/assets/esri/core/workers/chunks/{b160dcbea6256e0cf689.js → feaf79b69d2e2a1f2aa2.js} +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_no.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
- package/chunks/Laserlines.glsl.js +2 -2
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/vec42.js +1 -1
- package/config.js +1 -1
- package/core/accessorSupport/ensureType.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec4.js +1 -1
- package/effects/FocusArea.js +5 -0
- package/{views → effects}/FocusAreaOutline.js +1 -1
- package/{views → effects}/FocusAreas.js +1 -1
- package/geometry/support/frustum.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +137 -66
- package/kernel.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/networks/support/UNTraceConfiguration.js +1 -1
- package/networks/support/typeUtils.js +1 -1
- package/package.json +1 -1
- package/rest/knowledgeGraph/GraphAddFieldIndexResult.js +5 -0
- package/rest/knowledgeGraph/GraphAddNamedTypesResult.js +1 -1
- package/rest/knowledgeGraph/GraphAddPropertyResult.js +1 -1
- package/rest/knowledgeGraph/GraphDataModelOperationResult.js +5 -0
- package/rest/knowledgeGraph/GraphDeleteFieldIndexResult.js +5 -0
- package/rest/knowledgeGraph/GraphDeleteNamedTypeResult.js +1 -1
- package/rest/knowledgeGraph/GraphDeletePropertyResult.js +1 -1
- package/rest/knowledgeGraph/GraphUpdateNamedTypesResult.js +1 -1
- package/rest/knowledgeGraph/GraphUpdatePropertyResult.js +1 -1
- package/rest/knowledgeGraph/GraphUpdateSearchIndexResult.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/networks/support/CircuitPath.js +5 -0
- package/rest/networks/support/CircuitPathConnectivityElement.js +5 -0
- package/rest/networks/support/TraceLocation.js +1 -1
- package/rest/networks/support/TraceResult.js +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/smartMapping/renderers/predominance.js +1 -1
- package/smartMapping/renderers/support/rendererUtils.js +1 -1
- package/smartMapping/renderers/support/spikeUtils.d.ts +4 -0
- package/support/revision.js +1 -1
- package/views/2d/engine/Bitmap.js +1 -1
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/vectorTiles/GlyphMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightGradient.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Colorize.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/DropShadow.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Opacity.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/blend/BlendTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/magnifier/MagnifierTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
- package/views/2d/layers/VideoLayerView2D.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/environment/LocalAtmosphere.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/geometryUtils/sphere.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaOutlineItem.js +5 -0
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
- package/views/3d/webgl-engine/shaders/CompositingTechniqueConfiguration.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/rasterUtils.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/components/Notices.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
- package/assets/esri/core/workers/chunks/094e8aae6dada24c8115.js +0 -1
- package/assets/esri/core/workers/chunks/24327d01cb2c5c55a4b7.js +0 -1
- package/assets/esri/core/workers/chunks/62b2d3720693c93a60f2.js +0 -1
- package/assets/esri/core/workers/chunks/a0f2df8ca7cd14bfa013.js +0 -1
- package/assets/esri/core/workers/chunks/b06cb23048c32940f5de.js +0 -1
- package/assets/esri/core/workers/chunks/d3d98ea5b5e56fc60a31.js +0 -1
- package/views/FocusArea.js +0 -5
- package/views/FocusAreaOutlineItem.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{unique as e,isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{unique as e,isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as i}from"../../core/handleUtils.js";import o from"../../core/Promise.js";import{throwIfAborted as a,isAbortError as l}from"../../core/promiseUtils.js";import n from"../../core/ReactiveMap.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"./Edits.js";import{groupFeaturesByLayer as f,fetchFullFeatures as c}from"./workflowUtils.js";let h=class extends o{constructor(t){super(t),this.editorItems=[],this.features=[],this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new n,this._fullFeatures=new Map,this._pendingEdits=new n}initialize(){const t=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(t.signal).then((e=>{a(t.signal),this._initializeEdits(e)})).catch((t=>{if(l(t))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw t}))),this.addHandles(i(t)),this._initializeEditorItemsByLayer()}get fullFeatures(){return Array.from(this._fullFeatures.values())}get layers(){return e(this.features.map((t=>t.sourceLayer)).filter(r))}set timeZone(t){this._set("timeZone",t),this._pendingEdits.forEach((e=>{e.timeZone=t}))}getEditorItemForLayer(t){return this._editorItemsByLayer.get(t)}getFeatureTitle(t){return this._pendingEdits.get(t)?.displayTitle}getPendingEditsForFeature(t){return this._pendingEdits.get(this._fullFeatures.get(t)??t)}isSubmittable(t){const e=this._pendingEdits.get(t);return!!e&&(e.submittable||e.isAssociation)}stageDelete(){for(const t of this._pendingEdits.values())t.stageDelete()}_initializeEditorItemsByLayer(){for(const t of this.editorItems)this._editorItemsByLayer.set(t.layer,t)}_initializeEdits(t){const{timeZone:e}=this;for(const r of t){const t=new d({feature:r,timeZone:e});t.trackChanges(),this._pendingEdits.set(r,t)}}async _initializeFullFeatures(t){const{spatialReference:e}=this.viewModel.view,r=this._fullFeatures,i=f(this.features),o=Array.from(i.entries()).map((async([i,o])=>{const a=await c(o,i,e,t);if(a.length!==o.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const l=i.objectIdField,n=(t,e)=>t.attributes[l]>e.attributes[l]?1:-1,u=o.sort(n),p=a.sort(n);for(let t=0;t<u.length;t++)r.set(u[t],p[t]);return a}));return(await Promise.all(o)).flat()}};t([u({constructOnly:!0})],h.prototype,"editorItems",void 0),t([u({constructOnly:!0})],h.prototype,"features",void 0),t([u()],h.prototype,"fullFeatures",null),t([u()],h.prototype,"layers",null),t([u()],h.prototype,"parent",void 0),t([u()],h.prototype,"selectedFeature",void 0),t([u({constructOnly:!0})],h.prototype,"sketchOptions",void 0),t([u()],h.prototype,"snappingManager",void 0),t([u()],h.prototype,"timeZone",null),t([u()],h.prototype,"viewModel",void 0),t([u()],h.prototype,"_fullFeatures",void 0),h=t([p("esri.widgets.Editor.UpdateFeaturesWorkflowData")],h);const m=h;export{m as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as h,sync as w,when as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as b,isTable as A}from"../../layers/support/layerUtils.js";import{createFeatureServices as C}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as M}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as F}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as V}from"./UpdateRecordWorkflow.js";import j from"./UpdateWorkflowData.js";import U from"./Workflow.js";import{createWorkflowSteps as P,fetchCandidates as R}from"./workflowUtils.js";import{findUtilityNetwork as L,isGraphicForRelatableFeatureSupportedLayer as O}from"../Feature/support/featureUtils.js";var x;let T=x=class extends U{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack((e=>e.cancel({force:!0})))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!y(a?.sourceLayer)&&!W(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(a?.activeRelationshipInput){const e=a.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=a.relationshipId)return void(a.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits&&!a?.disabled){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new S,l=new x({data:new j({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){const{activeFeatureFormViewModel:e}=this;if(e){if(e.submit(),!e.submittable||e.pendingSubtypeChoice)return;const t=e.getValues();if(e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0)return}this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t,i=!1){try{const a=await this._createNestedUpdateWorkflow(e,i,t);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");N(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=C([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=L(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const h=u?.generateDeleteAssociations([i]);if(!h)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=u?.gdbVersion??void 0;await r(c,[h],{gdbVersion:w,globalIdUsed:!0})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!m(i)||b(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t,a){const i=A(e.sourceLayer)?V:E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,d="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,c=await i.create({association:a,feature:e,parent:d,sketchOptions:s,snappingManager:n,viewModel:l,readOnly:t,applyEdits:o,applyEditsFeatureService:r,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e,readOnly:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,void 0,t)),selectAssociatedFeature:async({feature:e,association:a})=>await this._updatingHandles.addPromise(this.startUpdating(e,a,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u((()=>!c.updating)),c}async _createNestedAddAssociationWorkflow(e,t,a){const{AddAssociationWorkflow:i}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!O(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=H(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=H(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!A(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return P(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let s=null;e.addHandles(i((()=>{s=r(s)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=n();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await i.defer((()=>new Promise(((e,t)=>{l(s?.signal,(()=>t(d()))),e(R(r,a,i,s?.signal))}))));if(c(s),o.candidates=n.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),M.TOOL),u=f((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:F});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),w),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=s((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),w)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){o.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function H(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],T.prototype,"activeEditorItem",null),e([v()],T.prototype,"activeFeatureFormViewModel",null),e([v()],T.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],T.prototype,"activeSketchViewModel",null),e([v()],T.prototype,"canDeleteAssociation",null),e([v()],T.prototype,"activeWorkflow",null),e([v()],T.prototype,"updating",null),e([v()],T.prototype,"data",void 0),e([v()],T.prototype,"hasPreviousStep",null),e([v()],T.prototype,"hasUpdatableCandidates",null),e([v()],T.prototype,"nestedWorkflowCount",null),e([v()],T.prototype,"shouldShowAttachments",null),e([v()],T.prototype,"shouldAllowAttachmentEditing",null),e([v()],T.prototype,"hasPendingEdits",null),e([v()],T.prototype,"helpMessage",null),e([v()],T.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],T.prototype,"hasInvalidFormTemplate",null),T=x=e([k("esri.widgets.Editor.UpdateWorkflow")],T);const N=e=>!!e&&/update-/.test(e.type),D=T;export{D as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as h,sync as w,when as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as b,isTable as A}from"../../layers/support/layerUtils.js";import{createFeatureServices as C}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as M}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as F}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as V}from"./UpdateRecordWorkflow.js";import j from"./UpdateWorkflowData.js";import U from"./Workflow.js";import{isUpdateRecordWorkflow as P,createWorkflowSteps as R,fetchCandidates as L}from"./workflowUtils.js";import{findUtilityNetwork as O,isGraphicForRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";var T;let H=T=class extends U{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack((e=>e.cancel({force:!0})))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!y(a?.sourceLayer)&&!W(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(a?.activeRelationshipInput){const e=a.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=a.relationshipId)return void(a.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits&&!a?.disabled){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new S,l=new T({data:new j({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){const{activeFeatureFormViewModel:e}=this;if(e){if(e.submit(),!e.submittable||e.pendingSubtypeChoice)return;const t=e.getValues();if(e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0)return}this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t,i=!1){try{const a=await this._createNestedUpdateWorkflow(e,i,t);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");P(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=C([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=O(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const h=u?.generateDeleteAssociations([i]);if(!h)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=u?.gdbVersion??void 0;await r(c,[h],{gdbVersion:w,globalIdUsed:!0})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!m(i)||b(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t,a){const i=A(e.sourceLayer)?V:E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,d="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,c=await i.create({association:a,feature:e,parent:d,sketchOptions:s,snappingManager:n,viewModel:l,readOnly:t,applyEdits:o,applyEditsFeatureService:r,featureFormCallbacks:{addRelatedRecord:async e=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(e)),editRelatedRecord:async({relatedFeature:e,readOnly:t})=>await this._updatingHandles.addPromise(this.startUpdating(e,void 0,t)),selectAssociatedFeature:async({feature:e,association:a})=>await this._updatingHandles.addPromise(this.startUpdating(e,a,t)),addAssociation:async e=>await this._updatingHandles.addPromise(this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType))}});return await u((()=>!c.updating)),c}async _createNestedAddAssociationWorkflow(e,t,a){const{AddAssociationWorkflow:i}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!x(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=N(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=N(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!A(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return R(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let s=null;e.addHandles(i((()=>{s=r(s)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=n();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await i.defer((()=>new Promise(((e,t)=>{l(s?.signal,(()=>t(d()))),e(L(r,a,i,s?.signal))}))));if(c(s),o.candidates=n.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),M.TOOL),u=f((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:F});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),w),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=s((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),w)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){o.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function N(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],H.prototype,"activeEditorItem",null),e([v()],H.prototype,"activeFeatureFormViewModel",null),e([v()],H.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],H.prototype,"activeSketchViewModel",null),e([v()],H.prototype,"canDeleteAssociation",null),e([v()],H.prototype,"activeWorkflow",null),e([v()],H.prototype,"updating",null),e([v()],H.prototype,"data",void 0),e([v()],H.prototype,"hasPreviousStep",null),e([v()],H.prototype,"hasUpdatableCandidates",null),e([v()],H.prototype,"nestedWorkflowCount",null),e([v()],H.prototype,"shouldShowAttachments",null),e([v()],H.prototype,"shouldAllowAttachmentEditing",null),e([v()],H.prototype,"hasPendingEdits",null),e([v()],H.prototype,"helpMessage",null),e([v()],H.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],H.prototype,"hasInvalidFormTemplate",null),H=T=e([k("esri.widgets.Editor.UpdateWorkflow")],H);const D=H;export{D as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{loadCalciteComponents as e}from"../../support/componentsUtils.js";import{iconByKind as t}from"../../support/iconUtils.js";import"../../support/widgetUtils.js";import{tsx as o,tsxFragment as s}from"../../support/jsxFactory.js";const
|
|
5
|
+
import{loadCalciteComponents as e}from"../../support/componentsUtils.js";import{iconByKind as t}from"../../support/iconUtils.js";import"../../support/widgetUtils.js";import{tsx as o,tsxFragment as s}from"../../support/jsxFactory.js";const r={notice:"esri-editor__notice"},i=()=>e({notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")});function n({activeFeatureCount:e,workflow:t,messages:r}){const i=[],n="content-start";if(t?.reliesOnOwnerAdminPrivileges){const e=r.ownerAdminNotice;i.push(o(c,{key:"owner-admin-notice",message:e,slot:n}))}if(t?.hasInvalidFormTemplate){const t=e>1?r.multiFeature.formFieldUpdateError:r.singleFeature.formFieldUpdateError;i.push(o(c,{key:"form-field-error",kind:"warning",message:t,slot:n}))}if("create-features"===t?.type&&"georeferenced-reprojected"===t.data.upload?.result?.type){const e=r.helpMessages3d.meshReprojected;i.push(o(c,{key:"mesh-reprojected",kind:"warning",message:e,slot:n}))}return o(s,null,i)}function c(e){const s=e.kind??"brand";return o("calcite-notice",{class:r.notice,icon:t[s],key:e.key,kind:s,open:!0,scale:"s"},e.title?o("div",{slot:"title"},e.title):null,o("div",{slot:"message"},e.message))}export{c as Notice,n as Notices,r as css,i as loadNoticesComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{substitute as e}from"../../../intl/substitute.js";import{isUpdateFeaturesWorkflow as t,isBatchAttributeFormViewModel as o}from"../workflowUtils.js";import{loadFooterActionsComponents as i,FooterActions as a}from"./FooterActions.js";import{loadNoticesComponents as n,Notices as s}from"./Notices.js";import{loadPanelContentComponents as l,PanelContentSection as r,PanelContentSectionGroup as
|
|
5
|
+
import{substitute as e}from"../../../intl/substitute.js";import{isUpdateFeaturesWorkflow as t,isBatchAttributeFormViewModel as o}from"../workflowUtils.js";import{loadFooterActionsComponents as i,FooterActions as a}from"./FooterActions.js";import{loadNoticesComponents as n,Notices as s}from"./Notices.js";import{loadPanelContentComponents as l,PanelContentSection as r,PanelContentSectionGroup as u,PanelContent as d}from"./PanelContent.js";import c from"./PendingFeatureList.js";import{Heading as p,incrementHeadingLevel as m}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{tsx as f,tsxFragment as h}from"../../support/jsxFactory.js";const v=()=>Promise.all([i(),n(),l()]);function w({editorViewModel:i,headingLevel:n,messages:l,messagesCommon:v,onDelete:w,onDeleteAssociation:b,onSave:g,renderAttachments:y,renderFeatureForm:k,renderBatchAttributeForm:F,renderSketchToolbar:A}){const{activeFeatureCount:j,activeLeafWorkflow:C,activeWorkflow:S,formViewModel:L,syncing:D}=i;if(!C||!S||!L)return null;const I=C.type.includes("update"),P=o(L),B=j>1?l.multiFeature:l.singleFeature,H=I&&!C.hasPendingEdits||D||L.updating||L.disabled,T=e(I?B.update:B.create,{count:j}),x="create-features"!==C?.type||!!C.data.selectedPendingFeature,M="shouldShowAttachments"in C&&C.shouldShowAttachments&&!P&&!L.activeRelationshipInput&&!L.activeAssociationInput,V=(P?L.activeForm.inputs:L.inputs).every((e=>!e.visible))&&!M,U=t(C)?F:k,W=V?f(r,null,"create-features"===C.type?f(c,{headingLevel:n,key:"pending-feature-list",workflow:C}):void 0):f(r,{key:"panel-content-section"},f(s,{activeFeatureCount:j,messages:l,workflow:S}),f(u,null,x||"create-features"!==C.type?U():f(c,{headingLevel:n,key:"pending-feature-list",workflow:C}),M?f("div",{key:"attachments"},f(p,{level:m(n)},l.attachments),y()):null)),E=()=>{const{featureFormViewModel:e}=i;null!=e?.associationId&&(e.associationId=null)},N={appearance:"solid",onClick:g,disabled:H,label:T,type:"button"},R={appearance:"outline",onClick:w,disabled:D,kind:"danger",label:e(B.delete,{count:j}),type:"button"},q={...R,onClick:b,label:l.deleteAssociationTitle,type:"button"},z={...R,primaryLabel:v.delete,primaryText:v.delete,dropdownItems:[{onClick:b,label:l.deleteAssociationTitle}],type:"split-button"},G={appearance:"outline",onClick:E,disabled:D,label:v.cancel,type:"button"},J="viewing-associated-features"===i.page||"viewing-associated-layers"===i.page?[G]:[N,i.shouldShowDeleteButton&&!i.featureFormHasAssociation?R:void 0,i.shouldShowDeleteButton&&i.featureFormHasAssociation?z:void 0,!i.shouldShowDeleteButton&&i.featureFormHasAssociation?q:void 0];return f(h,null,V?A?.():void 0,f(d,{key:"attribute-panel-content"},W),f(a,{buttons:J}))}export{w as UpdateFeaturePanelContent,v as loadUpdateFeaturePanelContentComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as a}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedTemplate as j,isSharedPresetTemplate as F,isStandardFeatureTemplate as k,isSharedFeatureTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E,TransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import R from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as J,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return!!e&&"features"in e}function ee(e){return"update"===e.type}function te(e){return"update-features"===e.type}function re(e){if(!(e&&"renderer"in e&&ce(e.renderer)))return{rotation:null,size:null};const t=e.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression)),r=e.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&E(e)===C.RealWorldSize));return{rotation:1===t.length?t[0]:null,size:1===r.length?r[0]:null}}function ne(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ce(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=re(t);let a=null,o=null;if(r){const e=t.fields?.filter((e=>e.name===r.field)),n=1===e?.length?e[0]:null;a=ae(r,n)}if(n){const e=t.fields?.filter((e=>e.name===n.field)),r=1===e?.length?e[0]:null;o=se(n,r)}return{rotation:a,size:o}}function ae(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",a={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,le((a.current+360)%360,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function oe(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ie(e,t,r){if(null==t)return 0;const{symbol:n}=B(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const a=n.symbolLayers.at(0);if(!a)return 0;switch(a.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(He.icon,(await e(a,He.icon))[0])||He.icon}case"text":return He.text;case"line":return He.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return oe(await t(a,e.scale/He.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/He.viewScaleSizeFactor;default:return 0}}function se(e,t){const r=e.axis,n=t?.type??"double",a={initial:0,current:0},o=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>le(i(await ie(t,e,r)),n),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,le(a.current,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:Ye(e.valueUnit),axis:e.axis}}function le(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ce(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function ue(e,t,r){const n=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,n)&&(e.symbol=n)}function pe(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:Q,optionsPerTool:r};if(T(t)){const a=t.defaultTool,o=S(t)?t.definition?.inputGeometryType??e:e;switch(a){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const a=t.drawingTool;if("circle"===a||"ellipse"===a)return r.get("circle").preserveAspectRatio="circle"===a,{tool:"circle",createOptions:n};if("rectangle"===a)return{tool:"rectangle",createOptions:n};if("freehand"===a)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function de(e,t,r){const{creationInfo:n,fullTemplate:a}=t;if(!n)throw new i("featureworkflow","No creation info provided.");const o=n.layer,s=Le(a,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(a)||F(a)||await Me(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=pe(o.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function fe(e){return s([await ye(e),await me(e)])}async function ye({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:a}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==n?.type||S(i)||F(i))return null;const s=f((t=>Me(r,o.layer,e,a,t)));return g((()=>n.scale),(e=>s(e)))}async function me({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:a}=t;if(!a)return null;const o=r.activeComponent;if(!n||!X(o))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=a,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>o),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=o.graphic?.geometry;if(!e||!he(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=ge(e,d);t&&c.add(t)}}})),l((()=>{n.map.remove(c),c.destroy()}))])}function he(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function ge(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new G({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new R({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function be(e,t){const r=await Z(t).load(),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function we(e,t){const r=await be(e,t);if(!r)return new Map;const n=new Map;for(const a of r.layersAndTables)d(n,a.layerId,(()=>[])).push(a);return n}function ve(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Ie(e){const{edits:t,serviceInfo:n,view:a,findOriginalFeature:o}=e,i=Te(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=je(t,i,o),p=Fe(l,Se(s,c),c);if(a&&Ue(l,p,a),0===p.length)return t;const d=K(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=ve(e):h.id!==e.layerId&&(m.push(h),h=ve(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??ve(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Te(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Se(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(ke(n,e),""),t.has(e.relatedTableId)){const a=t.get(e.relatedTableId);if(a.length>0)for(const t of a[0].layer.relationships??[])if(t.id===e.id){r.set(ke(n,e),t.keyField);break}}return r}function je(e,t,r){const n=new Map,a=[],o=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)a.push(t),o.set(t.uniqueId,t)}return{allEditData:a,editDataByIdMap:o,editDataByLayerIdMap:n}}function Fe(e,t,r){const n=[];for(const a of e){const e=a.layer.relationships??[],{uniqueId:o}=a;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=ke(a.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(a.operationType){case"add":for(const t of s)t!==a&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===a.after.attributes[e]&&n.push([o,t.uniqueId]));break;case"modify":if(a.before.attributes[e]!==a.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==a&&("delete"===t.operationType?t.before.attributes[c]===a.before.attributes[e]?n.push([r,o]):t.before.attributes[c]===a.after.attributes[e]&&n.push([o,r]):"add"===t.operationType?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):t.after.attributes[c]===a.before.attributes[e]&&n.push([r,o]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):n.push([r,o]):n.push([o,r])))}break;case"delete":for(const t of s)t!==a&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===a.before.attributes[e]&&n.push([t.uniqueId,o]))}}}}return n}function ke(e,t){return`${e.layerId}:${t.id}`}function Ae(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function Ue(e,t,r){const n=[];for(const o of e)Ae(o.layer,r)&&n.push(o);if(0===n.length)return;let a=[];for(const o of n){const r=o.layer;switch(o.operationType){case"delete":a=[...Ve(o.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ve(o.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([o.uniqueId,e.uniqueId]);break;case"add":a=[...Ve(o.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ve(o.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([e.uniqueId,o.uniqueId])}}}function Ve(e,t){const r=[],n=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const a of n){const t=a.layer.globalIdField;("before"in a&&a.before?.attributes[t]===e||"after"in a&&a.after?.attributes[t]===e)&&r.push(a)}return r}function Le(e,t={}){return S(e)||F(e)?{}:k(e)?{...e.prototype.attributes,...t}:A(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Me(e,r,n,a,o){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=ne(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:a,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:a,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Oe(e.tooltipOptions,l,s)}function Oe(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function xe(e,t){return e?.find((e=>e.layer===t))}async function ze(e,t,r,n){switch(t.type){case"3d":return qe(e,t,r,n);case"2d":return Pe(e,t,r,n)}}async function qe(e,t,r,n){if(0===e.length)return[];const{updatable:o,graphicsByLayer:i}=await r.defer((async()=>{const{results:a}=await h(H(t,r),n),o=new Map,i=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};J(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return h(Promise.allSettled(o.map((async({layer:e})=>{const t=i.get(e),r=Ee(e);if(t.every((e=>L(r,e))))return t;const o=[];for(const n of t){o.push(n.getObjectId());const e=Object.keys(n.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Pe(e,t,r,n){if(0===e.length)return[];const{mapPoint:a}=r;if(null==a)return[];let o=null;const i=await r.defer((async()=>{const{results:a}=await h(t.hitTest(r),n);if(0===a.length)return[];const i=new Set;o=J(a),o.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return h(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Ee(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(a,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function Ee(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ce(e,t,n,a){const o=t.createQuery();o.objectIds=e.map((e=>e.getObjectId())).filter(r),o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=n);const i=await t.queryFeatures(o,{signal:a});return m(a),i.features}function Re(e){const t=new Map;for(const r of e){const e=r.sourceLayer,n=x(e)?e.parent:e;d(t,n,(()=>[])).push(r)}return t}async function De(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a}=e;await Ge(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=a.rotation,o.enableScaling=null!=a.size),r.update(t,o)}async function Ge(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a,webStyleCache:o}=e;let i=!1;const{rotation:s,size:l}=a;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await ue(t,o,e)}Oe(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Be(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ne(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function Ze(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const a=t.attributes;let o=!1;const i=n.rotation,s=Be(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==a[r]&&(t.setAttribute(r,l),o=!0)}}const l=n.size,c=Ne(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==a[r]&&(t.setAttribute(r,i),o=!0)}}return o}async function We({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:a,onUpdate:o,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await ue(t,i,"2d"===a.type?a.scale:null);let d=null;if("2d"===n?.view?.type){const e=f((e=>ue(t,i,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=tt(a,y);await De({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const a=e[n];a!==t.getAttribute(n)&&(t.setAttribute(n,a),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(a),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(a),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await ue(t,i,"2d"===a.type?a.scale:null)})),T=n.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===a.activeTool)return De(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===a.activeTool),e.signal).then((async()=>{if(!e.signal.aborted)return e.abort(),De(s)})))}Ze(a,t,e,r)&&await ue(t,i,"2d"===a.type?a.scale:null),o(nt(t),e)})),S=n.on(["undo","redo"],(async e=>{o(nt(e.graphics[0]),e)}));return s([S,T,l((()=>n.cancel())),I,d])}async function Qe(e,t,r){const n=e.view;e.layer.add(r);const a=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=o((async t=>{const r=await tt(n,a);m(t),r.setVisibility?.(c,e)}))}return await Je(n,r),p(!1),s([$e(n,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await tt(n,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function $e(e,t,r){if("3d"===e.type){const n=new W({graphic:t});return s([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function Je(e,t){if("3d"===e.type){const r=new W({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const He={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Ke(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function Xe(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,a=e.viewModel.getTemplatesForLayer(n);1===a.length&&"scene"!==n.type&&(r.template=a[0],t.shift())}return t}function Ye(e){return"unknown"===e?null:e}function _e(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const et=e=>/-stop/.test(e)||/vertex-/.test(e),tt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function rt(e){return"createInteractiveEditSession"in e}function nt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function at(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function ot(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),a=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===a.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return a[0].load()}return r}function it(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:a}=t;e.setAttribute(r,n.getAttribute(a))}}function st(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>it(e.relationships))),t.flatMap((e=>e.edits))):null}function lt(e){if(null==e)return[];if(te(e))return e.data.layers;const t=ee(e)?e.activeWorkflow:e,r=t?.layer;return r?[r]:[]}export{Ue as appendAllUtilityNetworkAssociationRelationships,Xe as avoidFeatureTemplateSelectionWithOnlyOneItem,rt as canCreateInteractiveEditSession,nt as cloneGraphicExceptMesh,Te as createLayerIdMap,Se as createRelationshipKeyMap,pe as createToolFromGeometryType,Ke as createWorkflowSteps,ze as fetchCandidates,Ce as fetchFullFeatures,Fe as findAllDependencies,Ve as findChangesByGlobalId,xe as findLayerInfo,ke as generateHashForRelationship,Le as getCreationAttributes,ot as getFullTemplateForCreationInfo,lt as getLayersFromWorkflow,ae as getRotationVariableAttribute,st as getServiceEditsFromWorkflowData,be as getServiceInfoForLayer,we as getServiceLayersById,se as getSizeVariableAttribute,ne as getVisualVariableAttributes,re as getVisualVariablesForLayer,Re as groupFeaturesByLayer,_ as isBatchAttributeFormViewModel,et as isTerminalUpdateEventType,te as isUpdateFeaturesWorkflow,ee as isUpdateWorkflow,Ae as isUtilityNetworkAssociationsTable,Ie as orderEditsByRelationshipDependencies,_e as prepareAttachmentsForCreateFeaturesWorkflow,it as setRelationshipFields,We as setUpGeometryUpdate,fe as setUpSketchCreateWatchers,Ge as setVisualVariablesAndElevationInfoForUpdate,at as showProgressCursor,He as sizeDefaults,Ye as sizeVariableUnitToLengthUnit,de as startCreatingNewFeature,De as startUpdatingFeatureGeometry,Qe as swapForEditingSession,ue as updateGraphicSymbolWhenRequired,Ze as visualVariableInteractiveUpdate,tt as whenEditorLayerView,Je as whenGraphicDisplayed};
|
|
5
|
+
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as a}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedTemplate as j,isSharedPresetTemplate as F,isStandardFeatureTemplate as k,isSharedFeatureTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E,TransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import R from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as J,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return!!e&&"features"in e}function ee(e){return null!=e&&"create-features"===e.type}function te(e){return null!=e&&"update-features"===e.type}function re(e){return null!=e&&/update-/.test(e.type)&&"fullFeature"in e}function ne(e){return null!=e&&"update"===e.type}function ae(e){if(!(e&&"renderer"in e&&pe(e.renderer)))return{rotation:null,size:null};const t=e.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression)),r=e.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&E(e)===C.RealWorldSize));return{rotation:1===t.length?t[0]:null,size:1===r.length?r[0]:null}}function oe(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&pe(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ae(t);let a=null,o=null;if(r){const e=t.fields?.filter((e=>e.name===r.field)),n=1===e?.length?e[0]:null;a=ie(r,n)}if(n){const e=t.fields?.filter((e=>e.name===n.field)),r=1===e?.length?e[0]:null;o=ce(n,r)}return{rotation:a,size:o}}function ie(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",a={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,ue((a.current+360)%360,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function se(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function le(e,t,r){if(null==t)return 0;const{symbol:n}=B(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const a=n.symbolLayers.at(0);if(!a)return 0;switch(a.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Xe.icon,(await e(a,Xe.icon))[0])||Xe.icon}case"text":return Xe.text;case"line":return Xe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return se(await t(a,e.scale/Xe.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Xe.viewScaleSizeFactor;default:return 0}}function ce(e,t){const r=e.axis,n=t?.type??"double",a={initial:0,current:0},o=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>ue(i(await le(t,e,r)),n),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,ue(a.current,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:et(e.valueUnit),axis:e.axis}}function ue(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function pe(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function de(e,t,r){const n=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,n)&&(e.symbol=n)}function fe(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:Q,optionsPerTool:r};if(T(t)){const a=t.defaultTool,o=S(t)?t.definition?.inputGeometryType??e:e;switch(a){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const a=t.drawingTool;if("circle"===a||"ellipse"===a)return r.get("circle").preserveAspectRatio="circle"===a,{tool:"circle",createOptions:n};if("rectangle"===a)return{tool:"rectangle",createOptions:n};if("freehand"===a)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function ye(e,t,r){const{creationInfo:n,fullTemplate:a}=t;if(!n)throw new i("featureworkflow","No creation info provided.");const o=n.layer,s=Oe(a,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(a)||F(a)||await xe(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=fe(o.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function me(e){return s([await he(e),await ge(e)])}async function he({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:a}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==n?.type||S(i)||F(i))return null;const s=f((t=>xe(r,o.layer,e,a,t)));return g((()=>n.scale),(e=>s(e)))}async function ge({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:a}=t;if(!a)return null;const o=r.activeComponent;if(!n||!X(o))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=a,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>o),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=o.graphic?.geometry;if(!e||!be(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=we(e,d);t&&c.add(t)}}})),l((()=>{n.map.remove(c),c.destroy()}))])}function be(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function we(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new G({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new R({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function ve(e,t){const r=await Z(t).load(),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function Ie(e,t){const r=await ve(e,t);if(!r)return new Map;const n=new Map;for(const a of r.layersAndTables)d(n,a.layerId,(()=>[])).push(a);return n}function Te(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Se(e){const{edits:t,serviceInfo:n,view:a,findOriginalFeature:o}=e,i=je(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=ke(t,i,o),p=Ae(l,Fe(s,c),c);if(a&&Le(l,p,a),0===p.length)return t;const d=K(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=Te(e):h.id!==e.layerId&&(m.push(h),h=Te(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??Te(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function je(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Fe(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Ue(n,e),""),t.has(e.relatedTableId)){const a=t.get(e.relatedTableId);if(a.length>0)for(const t of a[0].layer.relationships??[])if(t.id===e.id){r.set(Ue(n,e),t.keyField);break}}return r}function ke(e,t,r){const n=new Map,a=[],o=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)a.push(t),o.set(t.uniqueId,t)}return{allEditData:a,editDataByIdMap:o,editDataByLayerIdMap:n}}function Ae(e,t,r){const n=[];for(const a of e){const e=a.layer.relationships??[],{uniqueId:o}=a;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Ue(a.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(a.operationType){case"add":for(const t of s)t!==a&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===a.after.attributes[e]&&n.push([o,t.uniqueId]));break;case"modify":if(a.before.attributes[e]!==a.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==a&&("delete"===t.operationType?t.before.attributes[c]===a.before.attributes[e]?n.push([r,o]):t.before.attributes[c]===a.after.attributes[e]&&n.push([o,r]):"add"===t.operationType?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):t.after.attributes[c]===a.before.attributes[e]&&n.push([r,o]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):n.push([r,o]):n.push([o,r])))}break;case"delete":for(const t of s)t!==a&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===a.before.attributes[e]&&n.push([t.uniqueId,o]))}}}}return n}function Ue(e,t){return`${e.layerId}:${t.id}`}function Ve(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function Le(e,t,r){const n=[];for(const o of e)Ve(o.layer,r)&&n.push(o);if(0===n.length)return;let a=[];for(const o of n){const r=o.layer;switch(o.operationType){case"delete":a=[...Me(o.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Me(o.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([o.uniqueId,e.uniqueId]);break;case"add":a=[...Me(o.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Me(o.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([e.uniqueId,o.uniqueId])}}}function Me(e,t){const r=[],n=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const a of n){const t=a.layer.globalIdField;("before"in a&&a.before?.attributes[t]===e||"after"in a&&a.after?.attributes[t]===e)&&r.push(a)}return r}function Oe(e,t={}){return S(e)||F(e)?{}:k(e)?{...e.prototype.attributes,...t}:A(e)?{...e.definition?.defaultValues,...t}:{...t}}async function xe(e,r,n,a,o){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=oe(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:a,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:a,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}ze(e.tooltipOptions,l,s)}function ze(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function qe(e,t){return e?.find((e=>e.layer===t))}async function Pe(e,t,r,n){switch(t.type){case"3d":return Ee(e,t,r,n);case"2d":return Ce(e,t,r,n)}}async function Ee(e,t,r,n){if(0===e.length)return[];const{updatable:o,graphicsByLayer:i}=await r.defer((async()=>{const{results:a}=await h(H(t,r),n),o=new Map,i=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};J(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return h(Promise.allSettled(o.map((async({layer:e})=>{const t=i.get(e),r=Re(e);if(t.every((e=>L(r,e))))return t;const o=[];for(const n of t){o.push(n.getObjectId());const e=Object.keys(n.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Ce(e,t,r,n){if(0===e.length)return[];const{mapPoint:a}=r;if(null==a)return[];let o=null;const i=await r.defer((async()=>{const{results:a}=await h(t.hitTest(r),n);if(0===a.length)return[];const i=new Set;o=J(a),o.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return h(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Re(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(a,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function Re(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function De(e,t,n,a){const o=t.createQuery();o.objectIds=e.map((e=>e.getObjectId())).filter(r),o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=n);const i=await t.queryFeatures(o,{signal:a});return m(a),i.features}function Ge(e){const t=new Map;for(const r of e){const e=r.sourceLayer,n=x(e)?e.parent:e;d(t,n,(()=>[])).push(r)}return t}async function Be(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a}=e;await Ne(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=a.rotation,o.enableScaling=null!=a.size),r.update(t,o)}async function Ne(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a,webStyleCache:o}=e;let i=!1;const{rotation:s,size:l}=a;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await de(t,o,e)}ze(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ze(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function We(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function Qe(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const a=t.attributes;let o=!1;const i=n.rotation,s=Ze(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==a[r]&&(t.setAttribute(r,l),o=!0)}}const l=n.size,c=We(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==a[r]&&(t.setAttribute(r,i),o=!0)}}return o}async function $e({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:a,onUpdate:o,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await de(t,i,"2d"===a.type?a.scale:null);let d=null;if("2d"===n?.view?.type){const e=f((e=>de(t,i,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=nt(a,y);await Be({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const a=e[n];a!==t.getAttribute(n)&&(t.setAttribute(n,a),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(a),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(a),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await de(t,i,"2d"===a.type?a.scale:null)})),T=n.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===a.activeTool)return Be(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===a.activeTool),e.signal).then((async()=>{if(!e.signal.aborted)return e.abort(),Be(s)})))}Qe(a,t,e,r)&&await de(t,i,"2d"===a.type?a.scale:null),o(ot(t),e)})),S=n.on(["undo","redo"],(async e=>{o(ot(e.graphics[0]),e)}));return s([S,T,l((()=>n.cancel())),I,d])}async function Je(e,t,r){const n=e.view;e.layer.add(r);const a=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=o((async t=>{const r=await nt(n,a);m(t),r.setVisibility?.(c,e)}))}return await Ke(n,r),p(!1),s([He(n,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await nt(n,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function He(e,t,r){if("3d"===e.type){const n=new W({graphic:t});return s([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function Ke(e,t){if("3d"===e.type){const r=new W({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const Xe={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Ye(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function _e(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,a=e.viewModel.getTemplatesForLayer(n);1===a.length&&"scene"!==n.type&&(r.template=a[0],t.shift())}return t}function et(e){return"unknown"===e?null:e}function tt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const rt=e=>/-stop/.test(e)||/vertex-/.test(e),nt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function at(e){return"createInteractiveEditSession"in e}function ot(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function it(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function st(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),a=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===a.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return a[0].load()}return r}function lt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:a}=t;e.setAttribute(r,n.getAttribute(a))}}function ct(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>lt(e.relationships))),t.flatMap((e=>e.edits))):null}function ut(e){if(null==e)return[];if(te(e))return e.data.layers;const t=ne(e)?e.activeWorkflow:e,r=t?.layer;return r?[r]:[]}export{Le as appendAllUtilityNetworkAssociationRelationships,_e as avoidFeatureTemplateSelectionWithOnlyOneItem,at as canCreateInteractiveEditSession,ot as cloneGraphicExceptMesh,je as createLayerIdMap,Fe as createRelationshipKeyMap,fe as createToolFromGeometryType,Ye as createWorkflowSteps,Pe as fetchCandidates,De as fetchFullFeatures,Ae as findAllDependencies,Me as findChangesByGlobalId,qe as findLayerInfo,Ue as generateHashForRelationship,Oe as getCreationAttributes,st as getFullTemplateForCreationInfo,ut as getLayersFromWorkflow,ie as getRotationVariableAttribute,ct as getServiceEditsFromWorkflowData,ve as getServiceInfoForLayer,Ie as getServiceLayersById,ce as getSizeVariableAttribute,oe as getVisualVariableAttributes,ae as getVisualVariablesForLayer,Ge as groupFeaturesByLayer,_ as isBatchAttributeFormViewModel,ee as isCreateFeaturesWorkflow,rt as isTerminalUpdateEventType,te as isUpdateFeaturesWorkflow,re as isUpdateRecordWorkflow,ne as isUpdateWorkflow,Ve as isUtilityNetworkAssociationsTable,Se as orderEditsByRelationshipDependencies,tt as prepareAttachmentsForCreateFeaturesWorkflow,lt as setRelationshipFields,$e as setUpGeometryUpdate,me as setUpSketchCreateWatchers,Ne as setVisualVariablesAndElevationInfoForUpdate,it as showProgressCursor,Xe as sizeDefaults,et as sizeVariableUnitToLengthUnit,ye as startCreatingNewFeature,Be as startUpdatingFeatureGeometry,Je as swapForEditingSession,de as updateGraphicSymbolWhenRequired,Qe as visualVariableInteractiveUpdate,nt as whenEditorLayerView,Ke as whenGraphicDisplayed};
|
package/widgets/Editor.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,abortMaybe as s,mappedFind as i}from"../core/maybe.js";import{createResolver as o}from"../core/promiseUtils.js";import{watch as a,on as r,when as n,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../core/support/UpdatingHandles.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import p from"./Attachments.js";import u from"./BatchAttributeForm.js";import g from"./FeatureForm.js";import w from"./FeatureTemplates.js";import _ from"./Spinner.js";import v from"./Widget.js";import{VisibleElements as f}from"./BatchAttributeForm/VisibleElements.js";import{css as y}from"./Editor/css.js";import b from"./Editor/EditorViewModel.js";import{isModelUpload as k}from"./Editor/modelUploadUtils.js";import A from"./Editor/VisibleElements.js";import{isBatchAttributeFormViewModel as F}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as M,CreateFeaturesPanelContent as T}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as C,FeatureList as L}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as S,FooterActions as E}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as W,Notice as P}from"./Editor/components/Notices.js";import{loadPanelContentComponents as I,PanelContent as j,PanelContentSection as U,PanelContentMessage as V}from"./Editor/components/PanelContent.js";import{PanelToolbar as D,loadPanelToolbarComponents as B}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as O,Prompt as x}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as N,UpdateFeaturePanelContent as z}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as H,UploadDetails as G}from"./Editor/components/UploadDetails.js";import{VisibleElements as R,SelectionToolVisibilityMap as q,CreateToolVisibilityMap as Z}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as K}from"./support/componentsUtils.js";import{globalCss as $}from"./support/globalCss.js";import{incrementHeadingLevel as J,Heading as Q}from"./support/Heading.js";import{renderItem as X}from"./support/ItemList.js";import{connectDelayedLoading as Y}from"./support/loaderUtils.js";import ee from"./support/SelectionList.js";import te from"./support/SelectionToolbar.js";import"./support/widgetUtils.js";import{messageBundle as se}from"./support/decorators/messageBundle.js";import{vmEvent as ie}from"./support/decorators/vmEvent.js";import{tsx as oe}from"./support/jsxFactory.js";import ae from"./support/SelectionList/VisibleElements.js";import re from"./support/SelectionToolbar/VisibleElements.js";import{substitute as ne}from"../intl/substitute.js";const le=Symbol("sketch-setup-handles");let ce=class extends v{constructor(e,t){super(e,t),this._batchAttributeForm=new u({visibleElements:new f({loadingIndicator:!1})}),this._featureForm=new g,this._sketchToolbar=null,this._attachments=new p({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new w({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?oe("calcite-icon",{class:y.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this._loading=!1,this._selectionList=new ee({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new ae({header:!1})}),this._selectionToolbar=new te({persistSelection:!1,returnGeometry:!1,visibleElements:new re({chip:!1})}),this._updatingHandles=new h,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new b,this.visibleElements=new A,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?oe("div",{class:y.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>oe("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...i)=>{const{visibleElements:o}=this;return oe("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},o.zoomToButton&&this.viewModel.canZoomTo?oe("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,o.settingsMenu?oe(D,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...i)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&k(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>J(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),r((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),n((()=>this.viewModel.formViewModel),(e=>{F(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e}),l),n((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),l),n((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel]),(([e,t,s,i,o,a])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=s,this._spinner.viewModel=i,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=a,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),l),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),l),n((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),n((()=>this._selectionListItemActionConfigs),(()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs})),n((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:i,cancel:o}]=e;this._showPrompt({title:t.errorWarningTitle,message:ne(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{o(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),l),Y({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=t(this._sketchToolbar),this._sketchImportAbortController=s(this._sketchImportAbortController)}loadDependencies(){return Promise.all([K({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),M(),C(),S(),W(),I(),B(),O(),N(),H()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)},{label:e?.batchEditing?.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)}]}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}startUpdateWorkflowWithActiveSelection(){return this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(y.base,$.widget,$.panel);if(!t)return oe("div",{class:s,key:"empty"});const{pageStack:i}=t,o=i.length-1,a=i.map(((e,t)=>this._renderPage(e,t===o)));return oe("div",{class:s,key:"base"},e.flow?oe("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?oe(x,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"viewing-selection-list":return this._renderSelectionListPage(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-features":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return oe("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return oe(t,{heading:s.selectTemplate,key:"templates-panel",...e},oe(j,{key:"feature-templates"},oe(U,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:i}=this;if("create-features"!==s?.type)return null;const o=s.data.upload;return o?oe(t,{heading:i.createFeatures,key:"upload-details-panel",...e},oe(G,{helpMessage:this._helpMessage,messages:i,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:i,messagesCommon:o,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return oe(t,{heading:i.createFeatures,key:"create-features-panel",...e},n?oe(z,{editorViewModel:r,headingLevel:a,messages:i,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):oe(T,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:i,headingLevel:o,viewModel:a}=this;return oe(t,{heading:s.editFeature,key:"update-feature-panel",...e},oe(z,{editorViewModel:a,headingLevel:o,messages:s,messagesCommon:i,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:i,headingLevel:o,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return oe(t,{heading:n,key:"viewing-associated-layers-panel",...e},oe(z,{editorViewModel:a,headingLevel:o,messages:s,messagesCommon:i,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:i,messagesCommon:o}=this,a=i.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state||this.viewModel.featureFormDisabled;return t?oe(s,{heading:r,key:"add-association-select-feature",...e},oe(j,{key:"select-feature"},oe(U,null,t.render())),oe(E,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===i.activeWorkflow?.type&&(a?.reset(),i.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):oe(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,i="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=i?i.activeWorkflow:null,a="add-association"===o?.type?o.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:i,messagesCommon:o}=this;if(!t)return null;const a=i.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return oe(s,{heading:r,key:"add-association",...e},oe(j,{key:"add-association-content"},oe(U,null,t.render())),oe(E,{buttons:[{label:o.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===i.activeWorkflow?.type&&i.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this,o=i(e.group.items,(e=>s.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return o?oe(P,{kind:"warning",message:o}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:i,messagesCommon:o}=this;return oe(t,{heading:i.addAttachment,key:"attachment-adding-panel",...e},oe(j,{key:"attachments"},this._renderAttachments()),oe(E,{buttons:[{label:s.submitting?o.cancel:o.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_selectionList:t,messages:s,EditorPanel:i}=this,{batchUpdateActions:o}=this.visibleElements;return oe(i,{heading:s.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?oe("div",{class:y.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,oe(j,{key:"selection-list"},oe(U,null,this._renderSelectionList())),oe(E,{buttons:[o?{label:ne(s.batchEditing.editCount,{count:t.visibleFeatureCount}),disabled:t.visibleLayerCount>1,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:o&&t.visibleLayerCount>1?{text:s.batchEditing.selectOneLayer,icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:i,messages:o,messagesCommon:a}=this;return i?oe(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},oe(j,{key:"attachments"},this._renderAttachments()),i.shouldAllowAttachmentEditing?oe(E,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:i,visibleElements:o}=this,a=this._helpMessage;return oe(t,{heading:s.widgetLabel,key:"landing-panel",...e},oe(j,{key:"landing-content"},i.editorItems.length?[o.editFeaturesSection?oe(U,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&i.canCreateVisible?oe(U,{key:"create-actions"},this._renderCreateActions()):null]:oe(V,{key:"no-content"},s.noEditableLayers)),a?oe("div",{class:y.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,i=e?.helpMessage;return i?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[i]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,i={id:"select",label:t.select};return oe("div",{class:y.updateActions,key:"update-actions"},oe(Q,{level:J(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?oe("div",{class:y.selectionToolbarContainer},this._renderSelectionToolbar()):oe("calcite-list",{class:y.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},X({disabled:!s.canUpdateVisible,grouped:!1,item:i,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?i:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return oe("div",{key:"create-actions"},oe(Q,{level:J(this.headingLevel)},this.messages.createFeatures),oe("div",{class:y.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:i}=s;if("update"!==i?.type)return null;const o=i.data.candidates,a=ne(this.messages.multipleFeaturesTemplate,{total:o.length});return oe(t,{heading:a,key:"feature-list",...e},oe(L,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:i,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:i}){const a=o(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:i,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e){await this.viewModel.onSelectionListMenuItemSelect(e)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=s(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(le);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const i=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new i.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new Z({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new q({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),l),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),l),n((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),l)],le)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],ce.prototype,"_batchAttributeForm",void 0),e([c()],ce.prototype,"_featureForm",void 0),e([c()],ce.prototype,"_sketchToolbar",void 0),e([c()],ce.prototype,"_attachments",void 0),e([c()],ce.prototype,"_associationItemList",void 0),e([c()],ce.prototype,"_associationSettings",void 0),e([c()],ce.prototype,"_featureTemplates",void 0),e([c()],ce.prototype,"_filterText",void 0),e([c()],ce.prototype,"_prompt",void 0),e([c()],ce.prototype,"_spinner",void 0),e([c()],ce.prototype,"_deleteButtonCommonInfo",null),e([c()],ce.prototype,"_loading",void 0),e([c()],ce.prototype,"_selectionList",void 0),e([c()],ce.prototype,"_selectionListItemActionConfigs",null),e([c()],ce.prototype,"_selectionToolbar",void 0),e([c({readOnly:!0})],ce.prototype,"activeWorkflow",null),e([c()],ce.prototype,"effectiveSelectionManager",null),e([c()],ce.prototype,"headingLevel",void 0),e([c()],ce.prototype,"hideTemplatesForInactiveLayers",null),e([c()],ce.prototype,"icon",null),e([c()],ce.prototype,"label",null),e([c()],ce.prototype,"labelOptions",null),e([c()],ce.prototype,"layerInfos",null),e([c(),se("esri/widgets/Editor/t9n/Editor")],ce.prototype,"messages",void 0),e([c(),se("esri/t9n/common")],ce.prototype,"messagesCommon",void 0),e([c(),se("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ce.prototype,"messagesTemplates",void 0),e([c(),se("esri/widgets/Feature/t9n/Feature")],ce.prototype,"messagesFeature",void 0),e([c()],ce.prototype,"snappingOptions",null),e([c()],ce.prototype,"tooltipOptions",null),e([c()],ce.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],ce.prototype,"valueOptions",null),e([c()],ce.prototype,"view",null),e([c(),ie(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ce.prototype,"viewModel",void 0),e([c({type:A,nonNullable:!0})],ce.prototype,"visibleElements",void 0),e([c()],ce.prototype,"_helpMessage",null),ce=e([d("esri.widgets.Editor")],ce);const de=ce;export{de as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedFunction as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as i,abortMaybe as o,mappedFind as a}from"../core/maybe.js";import{createResolver as r}from"../core/promiseUtils.js";import{watch as n,on as l,when as c,initial as d}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../core/support/UpdatingHandles.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import g from"./Attachments.js";import w from"./BatchAttributeForm.js";import _ from"./FeatureForm.js";import v from"./FeatureTemplates.js";import f from"./Spinner.js";import y from"./Widget.js";import{VisibleElements as b}from"./BatchAttributeForm/VisibleElements.js";import{css as k}from"./Editor/css.js";import A from"./Editor/EditorViewModel.js";import{isModelUpload as F}from"./Editor/modelUploadUtils.js";import M from"./Editor/VisibleElements.js";import{isBatchAttributeFormViewModel as T}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as C,CreateFeaturesPanelContent as L}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as S,FeatureList as E}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as W,FooterActions as P}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as I,Notice as j}from"./Editor/components/Notices.js";import{loadPanelContentComponents as U,PanelContent as V,PanelContentSection as D,PanelContentMessage as B}from"./Editor/components/PanelContent.js";import{PanelToolbar as O,loadPanelToolbarComponents as x}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as N,Prompt as z}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as H,UpdateFeaturePanelContent as G}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as R,UploadDetails as q}from"./Editor/components/UploadDetails.js";import{VisibleElements as Z,SelectionToolVisibilityMap as K,CreateToolVisibilityMap as $}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as J}from"./support/componentsUtils.js";import{globalCss as Q}from"./support/globalCss.js";import{incrementHeadingLevel as X,Heading as Y}from"./support/Heading.js";import{renderItem as ee}from"./support/ItemList.js";import{connectDelayedLoading as te}from"./support/loaderUtils.js";import se from"./support/SelectionList.js";import ie from"./support/SelectionToolbar.js";import"./support/widgetUtils.js";import{messageBundle as oe}from"./support/decorators/messageBundle.js";import{vmEvent as ae}from"./support/decorators/vmEvent.js";import{tsx as re}from"./support/jsxFactory.js";import ne from"./support/SelectionList/VisibleElements.js";import le from"./support/SelectionToolbar/VisibleElements.js";import{substitute as ce}from"../intl/substitute.js";const de=Symbol("sketch-setup-handles");let he=class extends y{constructor(e,t){super(e,t),this._batchAttributeForm=new w({visibleElements:new b({loadingIndicator:!1})}),this._featureForm=new _,this._sketchToolbar=null,this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new v({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?re("calcite-icon",{class:k.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new f,this._loading=!1,this._selectionList=new se({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new ne({header:!1})}),this._selectionToolbar=new ie({persistSelection:!1,returnGeometry:!1,visibleElements:new le({chip:!1})}),this._updatingHandles=new p,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new A,this.visibleElements=new M,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?re("div",{class:k.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>re("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...i)=>{const{visibleElements:o}=this;return re("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},o.zoomToButton&&this.viewModel.canZoomTo?re("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,o.settingsMenu?re(O,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...i)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&F(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,t=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:t.deleteWarningTitle,message:t.deleteWarningMessage,context:"danger",actions:{primary:{label:ce(t.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:t.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([n((()=>X(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),d),l((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),c((()=>this.viewModel.formViewModel),(e=>{T(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e}),d),c((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),d),c((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),n((()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel]),(([e,t,s,i,o,a])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=s,this._spinner.viewModel=i,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=a,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),d),n((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),d),n((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),d),c((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),c((()=>this._selectionListItemActionConfigs),(()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs})),c((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:i,cancel:o}]=e;this._showPrompt({title:t.errorWarningTitle,message:ce(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{o(),this._clearPrompt()}}}})})),n((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),n((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),n((()=>this.visibleElements.sketch),(()=>this._setupSketch()),d),te({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=i(this._sketchToolbar),this._sketchImportAbortController=o(this._sketchImportAbortController)}loadDependencies(){return Promise.all([J({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),C(),S(),W(),I(),U(),x(),N(),H(),R()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)},{label:e?.batchEditing?.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)}]}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}startUpdateWorkflowWithActiveSelection(){return this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return t(s.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(k.base,Q.widget,Q.panel);if(!t)return re("div",{class:s,key:"empty"});const{pageStack:i}=t,o=i.length-1,a=i.map(((e,t)=>this._renderPage(e,t===o)));return re("div",{class:s,key:"base"},e.flow?re("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?re(z,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"viewing-selection-list":return this._renderSelectionListPage(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-features":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return re("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return re(t,{heading:s.selectTemplate,key:"templates-panel",...e},re(V,{key:"feature-templates"},re(D,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:i}=this;if("create-features"!==s?.type)return null;const o=s.data.upload;return o?re(t,{heading:i.createFeatures,key:"upload-details-panel",...e},re(q,{helpMessage:this._helpMessage,messages:i,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:i,messagesCommon:o,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return re(t,{heading:i.createFeatures,key:"create-features-panel",...e},n?re(G,{editorViewModel:r,headingLevel:a,messages:i,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):re(L,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:i,headingLevel:o,viewModel:a}=this,r=a.activeFeatureCount>1?s.multiFeature.editPanelTitle:s.singleFeature.editPanelTitle;return re(t,{heading:r,key:"update-feature-panel",...e},re(G,{editorViewModel:a,headingLevel:o,messages:s,messagesCommon:i,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:i,headingLevel:o,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return re(t,{heading:n,key:"viewing-associated-layers-panel",...e},re(G,{editorViewModel:a,headingLevel:o,messages:s,messagesCommon:i,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:i,messagesCommon:o}=this,a=i.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state||this.viewModel.featureFormDisabled;return t?re(s,{heading:r,key:"add-association-select-feature",...e},re(V,{key:"select-feature"},re(D,null,t.render())),re(P,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===i.activeWorkflow?.type&&(a?.reset(),i.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):re(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,i="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=i?i.activeWorkflow:null,a="add-association"===o?.type?o.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:i,messagesCommon:o}=this;if(!t)return null;const a=i.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return re(s,{heading:r,key:"add-association",...e},re(V,{key:"add-association-content"},re(D,null,t.render())),re(P,{buttons:[{label:o.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===i.activeWorkflow?.type&&i.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this,i=a(e.group.items,(e=>s.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?re(j,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:i,messagesCommon:o}=this;return re(t,{heading:i.addAttachment,key:"attachment-adding-panel",...e},re(V,{key:"attachments"},this._renderAttachments()),re(P,{buttons:[{label:s.submitting?o.cancel:o.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_selectionList:t,messages:s,EditorPanel:i}=this,{batchUpdateActions:o}=this.visibleElements;return re(i,{heading:s.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?re("div",{class:k.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,re(V,{key:"selection-list"},re(D,null,this._renderSelectionList())),re(P,{buttons:[o?{label:ce(s.batchEditing.editCount,{count:t.visibleFeatureCount}),disabled:t.visibleLayerCount>1,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:o&&t.visibleLayerCount>1?{text:s.batchEditing.selectOneLayer,icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:i,messages:o,messagesCommon:a}=this;return i?re(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},re(V,{key:"attachments"},this._renderAttachments()),i.shouldAllowAttachmentEditing?re(P,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:i,visibleElements:o}=this,a=this._helpMessage;return re(t,{heading:s.widgetLabel,key:"landing-panel",...e},re(V,{key:"landing-content"},i.editorItems.length?[o.editFeaturesSection?re(D,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&i.canCreateVisible?re(D,{key:"create-actions"},this._renderCreateActions()):null]:re(B,{key:"no-content"},s.noEditableLayers)),a?re("div",{class:k.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,i=e?.helpMessage;return i?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[i]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,i={id:"select",label:t.select};return re("div",{class:k.updateActions,key:"update-actions"},re(Y,{level:X(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?re("div",{class:k.selectionToolbarContainer},this._renderSelectionToolbar()):re("calcite-list",{class:k.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},ee({disabled:!s.canUpdateVisible,grouped:!1,item:i,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?i:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return re("div",{key:"create-actions"},re(Y,{level:X(this.headingLevel)},this.messages.createFeatures),re("div",{class:k.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:i}=s;if("update"!==i?.type)return null;const o=i.data.candidates,a=ce(this.messages.multipleFeaturesTemplate,{total:o.length});return re(t,{heading:a,key:"feature-list",...e},re(E,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:i,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:i}){const o=r(),{view:a}=this,n=a?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>o.resolve(!0)},secondary:{label:i,action:()=>o.resolve(!1)}}}),o.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e){await this.viewModel.onSelectionListMenuItemSelect(e)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=i(this._sketchToolbar),void this.removeHandles(de);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new Z({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new $({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new K({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([n((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),d),n((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),d),c((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),d)],de)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([h()],he.prototype,"_batchAttributeForm",void 0),e([h()],he.prototype,"_featureForm",void 0),e([h()],he.prototype,"_sketchToolbar",void 0),e([h()],he.prototype,"_attachments",void 0),e([h()],he.prototype,"_associationItemList",void 0),e([h()],he.prototype,"_associationSettings",void 0),e([h()],he.prototype,"_featureTemplates",void 0),e([h()],he.prototype,"_filterText",void 0),e([h()],he.prototype,"_prompt",void 0),e([h()],he.prototype,"_spinner",void 0),e([h()],he.prototype,"_deleteButtonCommonInfo",null),e([h()],he.prototype,"_loading",void 0),e([h()],he.prototype,"_selectionList",void 0),e([h()],he.prototype,"_selectionListItemActionConfigs",null),e([h()],he.prototype,"_selectionToolbar",void 0),e([h({readOnly:!0})],he.prototype,"activeWorkflow",null),e([h()],he.prototype,"effectiveSelectionManager",null),e([h()],he.prototype,"headingLevel",void 0),e([h()],he.prototype,"hideTemplatesForInactiveLayers",null),e([h()],he.prototype,"icon",null),e([h()],he.prototype,"label",null),e([h()],he.prototype,"labelOptions",null),e([h()],he.prototype,"layerInfos",null),e([h(),oe("esri/widgets/Editor/t9n/Editor")],he.prototype,"messages",void 0),e([h(),oe("esri/t9n/common")],he.prototype,"messagesCommon",void 0),e([h(),oe("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],he.prototype,"messagesTemplates",void 0),e([h(),oe("esri/widgets/Feature/t9n/Feature")],he.prototype,"messagesFeature",void 0),e([h()],he.prototype,"snappingOptions",null),e([h()],he.prototype,"tooltipOptions",null),e([h()],he.prototype,"supportingWidgetDefaults",void 0),e([h({type:u,nonNullable:!0})],he.prototype,"valueOptions",null),e([h()],he.prototype,"view",null),e([h(),ae(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],he.prototype,"viewModel",void 0),e([h({type:M,nonNullable:!0})],he.prototype,"visibleElements",void 0),e([h()],he.prototype,"_helpMessage",null),he=e([m("esri.widgets.Editor")],he);const me=he;export{me as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Logger.js";import{renderingSanitizer as i}from"../../core/sanitizerUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{convertDateFormatToIntlOptions as l}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as r,formatNumber as a}from"../../intl/number.js";import{isEditableLayer as s}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as u}from"../../layers/support/featureLayerUtils.js";import p from"../../layers/support/Field.js";import{validateFieldValue as d,isDateField as c,isTimeOnlyField as m,isIntegerField as f,isNumericField as h,isStringField as g,isDateOnlyField as y,isTimestampOffsetField as v}from"../../layers/support/fieldUtils.js";import{isAnyDateField as F}from"../../smartMapping/support/utils.js";import{system as _}from"../../time/constants.js";import{getTimeZoneFormattingOptions as C}from"../../time/timeZoneUtils.js";import b from"../FeatureForm/FieldInput.js";import D from"./Grid/EditorColumn.js";import{isEmptyStringOrWhitespace as x}from"./support/tableUtils.js";import{dateFieldsWithStringFieldValue as I,getLabelForDateFieldValue as E,valueIsInRange as w,dateTimeIsInRange as T,getUnixFieldValueFromDateComponents as V,getISOFieldValueFromDateComponents as L,normalizeTimeOnlyString as O,prepareISOFieldValueForDateComponents as Z,prepareUnixFieldValueForDateComponents as j}from"../support/dateUtils.js";import{setFocus as R}from"../support/widgetUtils.js";const S={cancelEdit:"Escape"},N="esri-column",A={input:`${N}__cell-input`,inputContainer:`${N}__cell__input-container`},U=l("short-date-short-time"),q=l("short-date"),k={useGrouping:!0,maximumFractionDigits:20};let z=class extends D{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:n})=>{const{formatFunction:o}=this;if(o&&t){const{index:l,item:{attachments:r,feature:a,relatedRecords:s}}=t;return o({attachments:r,column:this,feature:a,field:this.field,index:l,relatedRecords:s,value:i.sanitize(n),virtualIndex:this.getVirtualRowIndex(e)})}if(null===n)return" ";const{field:l}=this,s=this._getDomainForFeature(t?.item?.feature);if(s){const e=this._getComputedDomain(n,s);if("date"===l.type&&"range"===s.type)return this._formatDateValueForDisplay(l,e);if(this._isNumericField&&"range"===s.type){const e=this.template?.format,t=e?r(e):k;return a(parseFloat(n),t)}return I.has(l.type)?"range"===s.type?i.sanitize(E(l,e)):i.sanitize(e):e}if("date"===l.type||I.has(l.type))return this._formatDateValueForDisplay(l,n);if(this._isNumericField){const e=this.template?.format,t=e?r(e):k;return a(parseFloat(n),t)}return i.sanitize(n)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(d(o,i)||!w({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!T({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&d(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const a=document.createElement("div");a.classList.add(A.inputContainer);const s=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach((t=>e.appendChild(t))),a.appendChild(e),a.appendChild(i),s.push(...t)}else{const e=this.createInputElement({value:o});a.appendChild(e),s.push(e)}this._set("editInfo",{column:i,inputs:s,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(a),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=s[0];await R(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value)return null;const e=String(o.value);return c(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=O(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return L({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return V({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return F(e)||m(e)}get _isIntegerField(){return f(this.field)}get _isNumericField(){return h(this.field)}get _isStringField(){return g(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,n=t.description,o=x(e)?x(n)?null:n:e;return null==o?null:i.sanitize(o)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=s(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return i.sanitize(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return C(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??_,l("short-time"),t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:i,minLength:n,effectiveRequired:o}=this;let l;if("coded-value"===t?.type)l=this.createCalciteSelect(e,t.codedValues.map((({code:e,name:t})=>({value:e,name:t})))),l.addEventListener("calciteSelectChange",(()=>this.onInputBlur(l)));else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;l=document.createElement("calcite-input"),l.type="number",this._isIntegerField&&(l.step=1),null!=t&&(l.max=t),null!=i&&(l.min=i),l.status=w({max:t,min:i,value:e})?"idle":"invalid"}else l=document.createElement("calcite-input"),l.addEventListener("calciteInputChange",(()=>this.onInputBlur(l))),i>-1&&(l.maxLength=i),n>0&&(l.minLength=n);return l.classList.add(A.input),l.required=o,l.value=null!=e?e.toString():"",l.onkeydown=e=>{e.key===S.cancelEdit&&this.onInputBlur(l,!0)},l.onblur=()=>this.onInputBlur(l),l}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}_clearActiveEditValues(){this.editInfo?.inputs?.forEach((e=>e.value=""))}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?E(e,t,{...this._getDateFormatOptions(),timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:i,rawMax:n,rawMin:o},field:l,effectiveRequired:r}=this,a=this._getDateFieldValuesForComponents(l,e),s=[];if(F(l)){const e=this.createDateComponent(),u=y(l)||v(l)?n:t,p=y(l)||v(l)?o:i,d=this._getDateFieldValuesForComponents(l,u??null),c=this._getDateFieldValuesForComponents(l,p??null);e.value=a.date??"",e.max=d.date??"",e.min=c.date??"",e.required=r,e.addEventListener("calciteInputDatePickerOpen",(()=>this._onDateComponentOpen(e))),s.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=a.time??"",e.required=r,e.addEventListener("calciteInputTimePickerOpen",(()=>this._onDateComponentOpen(e))),s.push(e)}if("timestamp-offset"===l.type){const e=this.createTimeZoneComponent();e.value=a.timeZoneOffset??"0",e.addEventListener("calciteInputTimeZoneOpen",(()=>this._onDateComponentOpen(e))),s.push(e)}return s}_onDateComponentOpen(e){this.editInfo?.inputs.forEach((t=>{t!==e&&"open"in t&&(t.open=!1)}))}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return j(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return Z(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new b({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type||"knowledge-graph-sublayer"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=u(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return i&&i.length?i[0].name:e}return null}_getDateFormatOptions(){const{template:e}=this,t=e?.format?.dateFormat;return t?l(t):e?.input&&"includeTime"in e.input&&!1===e.input.includeTime?q:U}};e([n()],z.prototype,"_effectiveDomain",null),e([n()],z.prototype,"_activeFieldInput",void 0),e([n()],z.prototype,"_effectiveRange",null),e([n()],z.prototype,"_isAnyDateOrTimeField",null),e([n()],z.prototype,"_isIntegerField",null),e([n()],z.prototype,"_isNumericField",null),e([n()],z.prototype,"_isStringField",null),e([n()],z.prototype,"_isSubtypeField",null),e([n({readOnly:!0})],z.prototype,"alias",null),e([n()],z.prototype,"cellValueFormatFunction",void 0),e([n()],z.prototype,"cellValueValidatorFunction",void 0),e([n({readOnly:!0})],z.prototype,"defaultValue",null),e([n()],z.prototype,"effectiveDescription",null),e([n()],z.prototype,"effectiveEditable",null),e([n()],z.prototype,"effectiveLabel",null),e([n()],z.prototype,"effectiveRequired",null),e([n()],z.prototype,"effectiveTimeZoneOptions",null),e([n({type:p})],z.prototype,"field",void 0),e([n()],z.prototype,"formatFunction",void 0),e([n()],z.prototype,"includeTime",null),e([n()],z.prototype,"inputRenderFunction",void 0),e([n()],z.prototype,"layer",void 0),e([n({readOnly:!0})],z.prototype,"loadingMessage",null),e([n()],z.prototype,"maxLength",null),e([n()],z.prototype,"minLength",null),e([n({readOnly:!0})],z.prototype,"name",null),e([n({readOnly:!0})],z.prototype,"nullable",null),e([n()],z.prototype,"parseInputValueFunction",void 0),e([n()],z.prototype,"shouldShowPrompt",null),e([n()],z.prototype,"sortable",void 0),e([n()],z.prototype,"store",void 0),e([n()],z.prototype,"template",void 0),e([n()],z.prototype,"view",void 0),z=e([o("esri.widgets.FeatureTable.FieldColumn")],z);const B=z;export{B as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Logger.js";import{on as i,sync as n}from"../../core/reactiveUtils.js";import{renderingSanitizer as o}from"../../core/sanitizerUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{convertDateFormatToIntlOptions as s}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as u}from"../../intl/number.js";import{isEditableLayer as p}from"../../layers/support/editableLayers.js";import{computeDomainFromTypes as d}from"../../layers/support/featureLayerUtils.js";import c from"../../layers/support/Field.js";import{validateFieldValue as m,isDateField as f,isTimeOnlyField as h,isIntegerField as g,isNumericField as y,isStringField as v,isDateOnlyField as F,isTimestampOffsetField as _}from"../../layers/support/fieldUtils.js";import{isAnyDateField as C}from"../../smartMapping/support/utils.js";import{system as b}from"../../time/constants.js";import{getTimeZoneFormattingOptions as D}from"../../time/timeZoneUtils.js";import I from"../FeatureForm/FieldInput.js";import x from"./Grid/EditorColumn.js";import{isEmptyStringOrWhitespace as w}from"./support/tableUtils.js";import{dateFieldsWithStringFieldValue as T,getLabelForDateFieldValue as V,valueIsInRange as E,dateTimeIsInRange as O,getUnixFieldValueFromDateComponents as Z,getISOFieldValueFromDateComponents as j,normalizeTimeOnlyString as L,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as S}from"../support/dateUtils.js";import{setFocus as N}from"../support/widgetUtils.js";const U={cancelEdit:"Escape"},A=Symbol(),q="esri-column",k={input:`${q}__cell-input`,inputContainer:`${q}__cell__input-container`},z=s("short-date-short-time"),B=s("short-date"),H={useGrouping:!0,maximumFractionDigits:20};let P=class extends x{constructor(e){super(e),this._activeFieldInput=null,this.cellValueFormatFunction=({root:e,rowData:t,value:i})=>{const{formatFunction:n}=this;if(n&&t){const{index:l,item:{attachments:r,feature:s,relatedRecords:a}}=t;return n({attachments:r,column:this,feature:s,field:this.field,index:l,relatedRecords:a,value:o.sanitize(i),virtualIndex:this.getVirtualRowIndex(e)})}if(null===i)return" ";const{field:l}=this,r=this._getDomainForFeature(t?.item?.feature);if(r){const e=this._getComputedDomain(i,r);if("date"===l.type&&"range"===r.type)return this._formatDateValueForDisplay(l,e);if(this._isNumericField&&"range"===r.type){const e=this.template?.format,t=e?a(e):H;return u(parseFloat(i),t)}return T.has(l.type)?"range"===r.type?o.sanitize(V(l,e)):o.sanitize(e):e}if("date"===l.type||T.has(l.type))return this._formatDateValueForDisplay(l,i);if(this._isNumericField){const e=this.template?.format,t=e?a(e):H;return u(parseFloat(i),t)}return o.sanitize(i)},this.cellValueValidatorFunction=({oldValue:e,value:i})=>{const{_effectiveRange:n,field:o}=this,{max:l,min:r}=n;if(this.effectiveRequired&&(null==i||""===i))return!1;if(this._isNumericField&&(m(o,i)||!E({max:l,min:r,value:i})))return t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1;if(this._isAnyDateOrTimeField){const e=o.type;if(!O({type:e,range:n,value:i}))return!1}return e!==i},this.field=null,this.formatFunction=null,this.inputRenderFunction=async({root:e,column:i,rowData:n})=>{if(this.editInfo||!this.effectiveEditable)return;const o=this.getCellValue(n),{field:l}=this;if("big-integer"===l.type&&m(l,o))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=n?.item.feature;if(!r)return;this._activeFieldInput=this._setUpFieldInput(r,o);const s=document.createElement("div");s.classList.add(k.inputContainer);const a=[],u="coded-value"===this._effectiveDomain?.type;if(this._isAnyDateOrTimeField&&!u){const e=document.createElement("div"),t=this._setUpDateComponents(o),i=this._setUpDateActionBar();t.forEach((t=>e.appendChild(t))),s.appendChild(e),s.appendChild(i),a.push(...t)}else{const e=this.createInputElement({value:o});s.appendChild(e),a.push(e)}this._set("editInfo",{column:i,inputs:a,root:e,rowData:n,oldValue:o}),this.removeCellContent(e),e.appendChild(s),this._syncRowEditingState(e,!0),this.grid?.generateCellPartNames();const p=a[0];await N(p),"selectText"in p&&await p.selectText()},this.layer=null,this.parseInputValueFunction=({inputs:e})=>{const{editInfo:t,field:i,includeTime:n}=this;if(!t||!e.length)return null;const o=e[0];if(this._isAnyDateOrTimeField){if("coded-value"===this._effectiveDomain?.type){if(null==o.value||""===o.value)return null;const e=String(o.value);return f(i)?parseFloat(e):e}const{timeZone:l}=this.effectiveTimeZoneOptions,r=t.oldValue??void 0;switch(i.type){case"date-only":{const e=o.value;return""!==e?e:null}case"time-only":{const e=L(o.value);return""!==e?e:null}case"timestamp-offset":{const t=n?e[1]:void 0,i=e.at(-1);return j({oldValue:r,dateComponent:o,timeComponent:t,timeZoneComponent:i,defaultTimeZone:l})}case"date":{const{max:t,min:i}=this._effectiveRange;return Z({oldValue:r,dateComponent:o,timeComponent:e[1],timeZone:l,max:t,min:i})}}return null}const l=o.value,{effectiveRequired:r}=this;return r||null!=l&&""!==l?this._isNumericField?parseFloat(l):this._isStringField?l.trim():l:null},this.sortable=!0,this.store=null,this.template=null,this.view=null}get _effectiveDomain(){const e=this._activeFieldInput?.feature;return e?this._getDomainForFeature(e):null}get _effectiveRange(){return this._activeFieldInput?.range??{max:null,min:null}}get _isAnyDateOrTimeField(){const{field:e}=this;return C(e)||h(e)}get _isIntegerField(){return g(this.field)}get _isNumericField(){return y(this.field)}get _isStringField(){return v(this.field)}get _isSubtypeField(){const{layer:e}=this;if(e?.subtypeField){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get effectiveDescription(){const{description:e,field:t}=this,i=t.description,n=w(e)?w(i)?null:i:e;return null==n?null:o.sanitize(n)}get effectiveEditable(){const{editable:e,field:t,layer:i,tableEditingEnabled:n}=this;if(!t||!i)return!1;const o=p(i),l=i.effectiveCapabilities??i.capabilities,r=l?.operations?.supportsUpdate;return!!(t.editable&&o&&r&&"oid"!==t.type&&n)&&e}get effectiveLabel(){return o.sanitize(this.label||this.alias||this.fieldName)}get effectiveRequired(){return!this.nullable||this._isSubtypeField||this._activeFieldInput?.required||this.required}get effectiveTimeZoneOptions(){const{layer:e,field:t}=this;if(!e||"date"!==t?.type&&"timestamp-offset"!==t?.type)return{timeZone:void 0,timeZoneName:void 0};const{tableTimeZone:i,timeZone:n,view:o}=this;return D(e.preferredTimeZone||null,!!e.datesInUnknownTimezone,n??i??o?.timeZone??b,s("short-time"),t.type)}get includeTime(){const{field:e,template:t}=this;return"time-only"===e.type||"date-only"!==e.type&&(!t?.input||"includeTime"in t.input&&!1!==t.input.includeTime)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,i=e?.length??-1,n=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=n&&!isNaN(n)&&n>=-1&&(-1===i||n<=i)?n:i}get minLength(){const{template:e,maxLength:t}=this,i=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&i<=t?i:null}get name(){return this.field?.name}get nullable(){return!1!==this.field.nullable}get shouldShowPrompt(){return this._isSubtypeField}createInputElement({value:e}){const{_effectiveDomain:t,maxLength:o,minLength:l,effectiveRequired:r}=this;let s;if("coded-value"===t?.type)s=this.createCalciteSelect(e,t.codedValues.map((({code:e,name:t})=>({value:e,name:t})))),this.addHandles([i((()=>s),"calciteSelectChange",(()=>this.onInputBlur()),n)],A);else if(this._isNumericField){const{_effectiveRange:{max:t,min:i}}=this;s=document.createElement("calcite-input"),s.type="number",this._isIntegerField&&(s.step=1),null!=t&&(s.max=t),null!=i&&(s.min=i),s.status=E({max:t,min:i,value:e})?"idle":"invalid"}else s=document.createElement("calcite-input"),this.addHandles([i((()=>s),"calciteInputChange",(()=>this.onInputBlur()),n)],A),o>-1&&(s.maxLength=o),l>0&&(s.minLength=l);return s.classList.add(k.input),s.required=r,s.value=null!=e?e.toString():"",this.addHandles([i((()=>s),"keydown",(e=>{e.key===U.cancelEdit&&this.onInputBlur(!0)}),n),i((()=>s),"blur",(()=>this.onInputBlur()),n)],A),s}onInputBlur(e=!1){this.removeHandles(A),super.onInputBlur(e)}onEditComplete(){const e=this.editInfo?.root;e&&this._syncRowEditingState(e,!1),this._activeFieldInput=null,super.onEditComplete()}_clearActiveEditValues(){this.editInfo?.inputs?.forEach((e=>e.value=""))}_setUpDateActionBar(){const{messagesCommon:e}=this,t=e?.cancel??"",i=e?.clear??"",n=e?.save??"",o=document.createElement("calcite-action-bar");return o.expandDisabled=!0,o.layout="horizontal",o.appendChild(this.createCalciteAction({text:n,icon:"save",onclick:()=>this.submit()})),this.effectiveRequired||o.appendChild(this.createCalciteAction({text:i,icon:"trash",onclick:()=>{this._clearActiveEditValues(),this.submit()}})),o.appendChild(this.createCalciteAction({text:t,icon:"x",onclick:()=>this.cancel()})),o}_formatDateValueForDisplay(e,t){const{timeZone:i,timeZoneName:n}=this.effectiveTimeZoneOptions;return null!=t?V(e,t,{...this._getDateFormatOptions(),timeZone:i,timeZoneName:n}):null}_setUpDateComponents(e){const{_effectiveRange:{max:t,min:n,rawMax:o,rawMin:l},field:r,effectiveRequired:s}=this,a=this._getDateFieldValuesForComponents(r,e),u=[];if(C(r)){const e=this.createDateComponent(),p=F(r)||_(r)?o:t,d=F(r)||_(r)?l:n,c=this._getDateFieldValuesForComponents(r,p??null),m=this._getDateFieldValuesForComponents(r,d??null);e.value=a.date??"",e.max=c.date??"",e.min=m.date??"",e.required=s,this.addHandles([i((()=>e),"calciteInputDatePickerOpen",(()=>this._onDateComponentOpen(e)))],A),u.push(e)}if(this.includeTime){const e=this.createTimeComponent();e.value=a.time??"",e.required=s,this.addHandles([i((()=>e),"calciteInputTimePickerOpen",(()=>this._onDateComponentOpen(e)))],A),u.push(e)}if("timestamp-offset"===r.type){const e=this.createTimeZoneComponent();e.value=a.timeZoneOffset??"0",this.addHandles([i((()=>e),"calciteInputTimeZoneOpen",(()=>this._onDateComponentOpen(e)))],A),u.push(e)}return u}_onDateComponentOpen(e){this.editInfo?.inputs.forEach((t=>{t!==e&&"open"in t&&(t.open=!1)}))}_syncRowEditingState(e,t=!1){const i=this.grid?.getRowContainingNode(e);i&&(t?i.setAttribute("editing","true"):i.removeAttribute("editing"))}_getDateFieldValuesForComponents(e,t){switch(e.type){case"date":return S(t,this.effectiveTimeZoneOptions.timeZone);case"date-only":return{date:t};case"time-only":return{time:t};case"timestamp-offset":return R(t);default:return{}}}_setUpFieldInput(e,t){const{field:i,layer:n,effectiveTimeZoneOptions:{timeZone:o}}=this,l=new I({feature:e,field:i,initialFeature:e.clone(),layer:n,timeZone:o});return l.set("value",t),l}_isDomainCompatible(e){if(!e)return!1;const{_isNumericField:t,_isStringField:i}=this,{type:n}=e;if("coded-value"===n){const n=typeof e.codedValues[0].code;if("string"===n&&i||"number"===n&&t)return!0}return!("range"!==n||!t)}_getDomainForFeature(e){const{fieldName:t,layer:i,template:n}=this;if(!e||!i?.getFieldDomain)return null;if("wfs"===i.type||"geojson"===i.type||"csv"===i.type||"knowledge-graph-sublayer"===i.type)return null;if(n?.domain&&this._isDomainCompatible(n.domain))return n.domain;if("feature"!==i.type&&"subtype-group"!==i.type&&null==i.getField(t)?.domain){const e=d(i,t);if(e)return e}return i.getFieldDomain(t,{feature:e})}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const i=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return i&&i.length?i[0].name:e}return null}_getDateFormatOptions(){const{template:e}=this,t=e?.format?.dateFormat;return t?s(t):e?.input&&"includeTime"in e.input&&!1===e.input.includeTime?B:z}};e([l()],P.prototype,"_effectiveDomain",null),e([l()],P.prototype,"_activeFieldInput",void 0),e([l()],P.prototype,"_effectiveRange",null),e([l()],P.prototype,"_isAnyDateOrTimeField",null),e([l()],P.prototype,"_isIntegerField",null),e([l()],P.prototype,"_isNumericField",null),e([l()],P.prototype,"_isStringField",null),e([l()],P.prototype,"_isSubtypeField",null),e([l({readOnly:!0})],P.prototype,"alias",null),e([l()],P.prototype,"cellValueFormatFunction",void 0),e([l()],P.prototype,"cellValueValidatorFunction",void 0),e([l({readOnly:!0})],P.prototype,"defaultValue",null),e([l()],P.prototype,"effectiveDescription",null),e([l()],P.prototype,"effectiveEditable",null),e([l()],P.prototype,"effectiveLabel",null),e([l()],P.prototype,"effectiveRequired",null),e([l()],P.prototype,"effectiveTimeZoneOptions",null),e([l({type:c})],P.prototype,"field",void 0),e([l()],P.prototype,"formatFunction",void 0),e([l()],P.prototype,"includeTime",null),e([l()],P.prototype,"inputRenderFunction",void 0),e([l()],P.prototype,"layer",void 0),e([l({readOnly:!0})],P.prototype,"loadingMessage",null),e([l()],P.prototype,"maxLength",null),e([l()],P.prototype,"minLength",null),e([l({readOnly:!0})],P.prototype,"name",null),e([l({readOnly:!0})],P.prototype,"nullable",null),e([l()],P.prototype,"parseInputValueFunction",void 0),e([l()],P.prototype,"shouldShowPrompt",null),e([l()],P.prototype,"sortable",void 0),e([l()],P.prototype,"store",void 0),e([l()],P.prototype,"template",void 0),e([l()],P.prototype,"view",void 0),P=e([r("esri.widgets.FeatureTable.FieldColumn")],P);const M=P;export{M as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import{
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import{on as e,sync as n}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import l from"./Column.js";import{autoLink as r}from"../../support/uriUtils.js";const s={showInput:"Enter",cancelEdit:"Escape"},a=Symbol();let c=class extends l{constructor(t){super(t),this.editInfo=null,this.cellValueValidatorFunction=({oldValue:t,value:e})=>t!==e,this.editable=!0,this.headerRenderFunction=t=>{const{root:e}=t,n=this.createHeaderContent();this.tableEditingEnabled&&!this.effectiveEditable&&n.prepend(this._lockIconNode),this.removeCellContent(e),e.appendChild(n)},this.inputRenderFunction=({root:t,column:e,rowData:n})=>{if(this.editInfo||!this.effectiveEditable||!n)return;const o=this.getCellValue(n),i=this.createInputElement({value:o});this._set("editInfo",{column:e,inputs:[i],root:t,rowData:n,oldValue:o});const l=document.createElement("div");l.appendChild(i),this.removeCellContent(t),t.appendChild(l),i.focus(),i instanceof HTMLInputElement&&i.select()},this.loadingMessage="",this.inputType="text",this.maxLength=null,this.onShowPromptCallback=()=>{},this.parseInputValueFunction=({inputs:t})=>t?.length||1!==t.length||Array.isArray(t[0].value)?null:t[0].value,this.renderFunction=t=>{const{root:e,rowData:n}=t,{editInfo:o}=this;if(o)return;const i=this.getCellValue(n),l=this.cellValueFormatFunction({root:e,rowData:n,value:i});let a=null;e.onclick=()=>e.focus(),e.ondblclick=()=>this.inputRenderFunction(t),e.ontouchend=()=>this.inputRenderFunction(t);const c=this.grid?.getSlotElementByName(e.slot),u=c?.parentElement;u&&!u.onkeydown&&(u.onkeydown=e=>{e.key!==s.showInput||this.editInfo||this.inputRenderFunction(t),e.key===s.cancelEdit&&this.editInfo&&this.cancel()}),null!=i&&null!=l?e.title=l.toString():e.title&&e.removeAttribute("title"),a=l instanceof HTMLElement?l:r(this.messagesURIUtils,l),this.removeCellContent(e),a instanceof HTMLElement?e.appendChild(a):null!=a&&(e.innerHTML=a.toString())},this.required=!1,this.tableEditingEnabled=!1}get _lockIconNode(){return this.createCalciteIcon({icon:"lock",textLabel:this.messages?.editingPreventedColumn})}get effectiveEditable(){return this.tableEditingEnabled&&this.editable}get effectiveRequired(){return this.required}get editing(){return!!this.editInfo}get shouldShowPrompt(){return!1}cancel(){this.onEditComplete()}createCalciteOption(t,e,n=!1){const o=document.createElement("calcite-option");return o.label=t,o.value=`${e}`,o.selected=n,o}createCalciteSelect(t,e){const{effectiveRequired:n,messages:o}=this;let i=!1;const l=e.map((({name:e,value:n})=>{const o=n===t;return o&&(i=!0),this.createCalciteOption(e,n,o)}));if(null!=t&&""!==t&&!i){const e=t.toString(),n=this.createCalciteOption(e,e);l.unshift(n)}n||l.unshift(this.createCalciteOption(`<${o?.noValue}>`,""));const r=document.createElement("calcite-select");return l.forEach((t=>r.appendChild(t))),r}createInputElement({value:t}){const{effectiveRequired:o,maxLength:i}=this,l=document.createElement("calcite-input");return null!=i&&(l.maxLength=i),l.required=o,l.value=null!=t?t.toString():"",this.addHandles([e((()=>l),"calciteInputChange",(()=>this.onInputBlur()),n),e((()=>l),"keydown",(t=>{t.key===s.cancelEdit&&this.onInputBlur(!0)}),n),e((()=>l),"blur",(()=>this.onInputBlur()),n)],a),l}createDateComponent(){const t=document.createElement("calcite-input-date-picker");return t.focusTrapDisabled=!0,t.overlayPositioning="fixed",t}createTimeComponent(){const t=document.createElement("calcite-input-time-picker");return t.overlayPositioning="fixed",t.placement="auto-start",t.step=1,t}createTimeZoneComponent(){const t=document.createElement("calcite-input-time-zone");return t.maxItems=4,t.overlayPositioning="fixed",t}onEditComplete(){this._set("editInfo",null),this.grid?.generateCellPartNames(),this.grid?.requestContentUpdate()}onInputBlur(t=!1){this.removeHandles(a),t?this.cancel():this.submit()}async submit(){const{editInfo:t}=this;if(!t)return void this.cancel();const{inputs:e,rowData:n,oldValue:o}=t,i=this.parseInputValueFunction({inputs:e});if(!this.cellValueValidatorFunction({value:i,oldValue:o}))return void this.cancel();const{root:l}=t,r=n.item.objectId,{fieldName:s}=this;l.textContent=this.loadingMessage,this.shouldShowPrompt?this.onShowPromptCallback({column:this,objectId:r,oldValue:o,value:i}):await this.updateItems({objectId:r,updates:[{fieldName:s,value:i}]})}async updateItems(t){const{store:e}=this;if(e)try{await e.updateItem(t),this.onEditComplete()}catch{this.cancel()}else this.cancel()}};t([o()],c.prototype,"_lockIconNode",null),t([o({readOnly:!0})],c.prototype,"editInfo",void 0),t([o()],c.prototype,"cellValueValidatorFunction",void 0),t([o()],c.prototype,"editable",void 0),t([o()],c.prototype,"effectiveEditable",null),t([o()],c.prototype,"effectiveRequired",null),t([o()],c.prototype,"editing",null),t([o()],c.prototype,"headerRenderFunction",void 0),t([o()],c.prototype,"inputRenderFunction",void 0),t([o({constructOnly:!0})],c.prototype,"loadingMessage",void 0),t([o()],c.prototype,"inputType",void 0),t([o()],c.prototype,"maxLength",void 0),t([o()],c.prototype,"onShowPromptCallback",void 0),t([o()],c.prototype,"parseInputValueFunction",void 0),t([o()],c.prototype,"renderFunction",void 0),t([o()],c.prototype,"required",void 0),t([o()],c.prototype,"shouldShowPrompt",null),t([o()],c.prototype,"tableEditingEnabled",void 0),c=t([i("esri.widgets.FeatureTable.Grid.EditorColumn")],c);const u=c;export{u as default};
|