@arcgis/core 5.2.0-next.21 → 5.2.0-next.23
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/Graphic.d.ts +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{eccbddaec4be44c86f79.js → 1040bce57ea63a6dbca4.js} +2 -2
- package/assets/esri/core/workers/chunks/1a7c0a1dc6ecc93ea03a.js +1 -0
- package/assets/esri/core/workers/chunks/292498a9c7d462d215c6.js +1 -0
- package/assets/esri/core/workers/chunks/2d6d01913096f7cb5ff8.js +1 -0
- package/assets/esri/core/workers/chunks/30298f84bd414f9dea64.js +1 -0
- package/assets/esri/core/workers/chunks/353c67da4b25c29360db.js +2 -0
- package/assets/esri/core/workers/chunks/3b4fc67f6cb7393fbd97.js +1 -0
- package/assets/esri/core/workers/chunks/47948c72bc01bd173c20.js +2 -0
- package/assets/esri/core/workers/chunks/{f0519b06987471456b69.js → 502464c4eab7667f6566.js} +1 -1
- package/assets/esri/core/workers/chunks/{d7acbc2ddff4cee8a465.js → 5ee887fc6e1e0e70e02f.js} +1 -1
- package/assets/esri/core/workers/chunks/6c0c77de1934f35dc45f.js +1 -0
- package/assets/esri/core/workers/chunks/{f7f820483e45c05ab9e4.js → 75df436e6e9773bdcfc2.js} +1 -1
- package/assets/esri/core/workers/chunks/780519b60aa674a61a74.js +1 -0
- package/assets/esri/core/workers/chunks/7dbaa089c7472825b80c.js +1 -0
- package/assets/esri/core/workers/chunks/7dec8c453fdee1968d12.js +1 -0
- package/assets/esri/core/workers/chunks/{a2247f4c3116efb16c4f.js → 7e23de8d9b2d938808f6.js} +1 -1
- package/assets/esri/core/workers/chunks/7e4093f42795ba2f8cfd.js +1 -0
- package/assets/esri/core/workers/chunks/{6649acaceab00ad30e7f.js → 8ba3e0462a9bdaae5f40.js} +1 -1
- package/assets/esri/core/workers/chunks/928b18e13e015330d44b.js +1 -0
- package/assets/esri/core/workers/chunks/9434c76ad39c936dba90.js +1 -0
- package/assets/esri/core/workers/chunks/{909e67dee8c30e391d69.js → a8310f55de4749f973d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{ac16016964be3b684e98.js → aded4e704e09a28edc8f.js} +1 -1
- package/assets/esri/core/workers/chunks/{7175f0c6a6e56b685d20.js → b419fd36337e76e2d4a3.js} +6 -6
- package/assets/esri/core/workers/chunks/{05d597dd117766beadd8.js → b91a15522692781560b4.js} +1 -1
- package/assets/esri/core/workers/chunks/c86d388d216adbb15a05.js +1 -0
- package/assets/esri/core/workers/chunks/{f1ff33584680d8718400.js → c9ce408675dae6a0edd1.js} +1 -1
- package/assets/esri/core/workers/chunks/{0b522e05668bef729b1b.js → ceb5bd9f2afaa2ea0808.js} +1 -1
- package/assets/esri/core/workers/chunks/d07068c44d560e4ce02e.js +1 -0
- package/assets/esri/core/workers/chunks/{da47fdffb5969694a2ae.js → d41eed41916ed0422059.js} +1 -1
- package/assets/esri/core/workers/chunks/{19493c9c7e1d2ac0f80f.js → d4e0346209fabc58f929.js} +1 -1
- package/assets/esri/core/workers/chunks/{b375abfb2a2d9c63e20a.js → db90fb8ac96579259566.js} +1 -1
- package/assets/esri/core/workers/chunks/{44b30bce8e9a75b9e1b3.js → dd0acd0f8b96839b4f24.js} +2 -2
- package/assets/esri/core/workers/chunks/{5809e70a8e57e9b05959.js → dd795c95cdc3812b5b49.js} +1 -1
- package/assets/esri/core/workers/chunks/f7344d855f1092383abe.js +1 -0
- package/assets/esri/core/workers/chunks/{2dbd88566abac030e965.js → f859c53432f258af77e3.js} +2 -2
- package/assets/esri/core/workers/chunks/{ecbf84a1f42e6188faab.js → fd629872b5c07853f695.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +5 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/GaussianSplat.glsl.js +4 -4
- package/chunks/GaussianSplatShadow.glsl.js +1 -1
- package/config.d.ts +9 -2
- package/config.js +1 -1
- package/core/date.js +1 -1
- package/form/FormTemplate.d.ts +15 -20
- package/form/elements/AttachmentElement.d.ts +38 -11
- package/form/elements/Element.d.ts +9 -6
- package/form/elements/FieldElement.d.ts +0 -1
- package/form/elements/GroupElement.d.ts +4 -6
- package/form/elements/RelationshipElement.d.ts +8 -8
- package/form/elements/inputs/attachments/AttachmentInput.d.ts +34 -18
- package/form/elements/inputs/attachments/AudioInput.d.ts +4 -3
- package/form/elements/inputs/attachments/DocumentInput.d.ts +2 -6
- package/form/elements/inputs/attachments/ImageInput.d.ts +4 -3
- package/form/elements/inputs/attachments/Input.d.ts +6 -3
- package/form/elements/inputs/attachments/SignatureInput.d.ts +3 -3
- package/form/elements/inputs/attachments/VideoInput.d.ts +4 -3
- package/form/elements.d.ts +6 -12
- package/form/types.d.ts +0 -4
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.d.ts +2 -1
- package/layers/DimensionFeatureLayer.d.ts +2 -1
- package/layers/OrientedImageryLayer.d.ts +20 -2
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/graphics/sources/parquet/FileProvider.js +1 -1
- package/layers/graphics/sources/parquet/PortalParquetLayerFileProvider.js +1 -1
- package/layers/graphics/sources/parquet/fileProviderChangedError.js +2 -0
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/mixins/EditBusLayer.js +1 -1
- package/layers/orientedImagery/core/utils.js +1 -1
- package/layers/orientedImagery/types.d.ts +4 -1
- package/layers/support/RasterBandInfo.js +1 -1
- package/layers/types.d.ts +1 -0
- package/package.json +3 -3
- package/rest/support/AttachmentQuery.d.ts +13 -1
- package/rest/support/AttachmentQuery.js +1 -1
- package/rest/support/OutDistance.d.ts +5 -1
- package/rest/support/PrintParameters.d.ts +2 -1
- package/rest/support/Query.d.ts +2 -0
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/SimpleMarkerSymbol.d.ts +2 -2
- package/views/2d/engine/AFeatureContainer.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/glsl.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
- package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedComputedData.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerViewPerformanceInfo.js +1 -1
- package/views/3d/layers/graphics/tessellationUtils.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatAtlasPages.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatHeaderTexture.js +2 -0
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +4 -4
- package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatTextureFetch.glsl.js +13 -12
- package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatShadowRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +1 -1
- package/views/PopupView.d.ts +3 -0
- package/views/View2D.d.ts +2 -2
- package/views/layers/AnnotationFeatureLayerView.d.ts +9 -1
- package/views/layers/DimensionFeatureLayerView.d.ts +9 -1
- package/views/layers/FeatureLikeLayerView.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/BatchAttributeForm/attachmentUtils.js +1 -1
- package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
- package/widgets/BatchAttributeForm/css.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
- package/widgets/BatchAttributeForm/types.d.ts +0 -7
- package/widgets/BatchAttributeForm.d.ts +7 -9
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +12 -2
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/compatibilityAdapters.js +2 -0
- package/widgets/Editor/components/PendingFeatureList.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/legacy/AddAssociationWorkflow.js +2 -0
- package/widgets/Editor/legacy/AddAssociationWorkflowData.js +2 -0
- package/widgets/Editor/legacy/CreateFeaturesWorkflow.js +2 -0
- package/widgets/Editor/legacy/CreateFeaturesWorkflowData.js +2 -0
- package/widgets/Editor/legacy/MergeFeaturesWorkflow.js +2 -0
- package/widgets/Editor/legacy/MergeFeaturesWorkflowData.js +2 -0
- package/widgets/Editor/legacy/SplitFeatureWorkflow.js +2 -0
- package/widgets/Editor/legacy/SplitFeatureWorkflowData.js +2 -0
- package/widgets/Editor/legacy/UpdateFeatureWorkflow.js +2 -0
- package/widgets/Editor/legacy/UpdateFeatureWorkflowData.js +2 -0
- package/widgets/Editor/legacy/UpdateFeaturesWorkflow.js +2 -0
- package/widgets/Editor/legacy/UpdateFeaturesWorkflowData.js +2 -0
- package/widgets/Editor/legacy/UpdateRecordWorkflow.js +2 -0
- package/widgets/Editor/legacy/UpdateRecordWorkflowData.js +2 -0
- package/widgets/Editor/legacy/UpdateWorkflow.js +2 -0
- package/widgets/Editor/legacy/UpdateWorkflowData.js +2 -0
- package/widgets/Editor/legacy/Workflow.js +2 -0
- package/widgets/Editor/legacy/workflowUtils.js +2 -0
- package/widgets/Editor/types.d.ts +12 -0
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.d.ts +16 -12
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm.d.ts +14 -16
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +2 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.d.ts +3 -0
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/types.d.ts +20 -0
- package/widgets/FeatureTable.d.ts +14 -2
- package/widgets/FeatureTable.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
- package/widgets/OrientedImageryViewer/support/panConstraint.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/057d288d795b853295f1.js +0 -2
- package/assets/esri/core/workers/chunks/26aa8190ac439f634c5b.js +0 -1
- package/assets/esri/core/workers/chunks/3192586ec7fc73ed1165.js +0 -1
- package/assets/esri/core/workers/chunks/33866e6e6de1bab64599.js +0 -1
- package/assets/esri/core/workers/chunks/360fd810d70d21c092d9.js +0 -1
- package/assets/esri/core/workers/chunks/3e89f487c5851c954d8b.js +0 -1
- package/assets/esri/core/workers/chunks/5aa375b0c6a205134703.js +0 -1
- package/assets/esri/core/workers/chunks/5f0bc019add4aff3130c.js +0 -1
- package/assets/esri/core/workers/chunks/630ad47857de3cf726d1.js +0 -1
- package/assets/esri/core/workers/chunks/754f7ed62afc4e0a1972.js +0 -2
- package/assets/esri/core/workers/chunks/7ee76504e7fea389a1c9.js +0 -1
- package/assets/esri/core/workers/chunks/8331e04ebe0a54b04ab6.js +0 -1
- package/assets/esri/core/workers/chunks/8c64c6b8d7376a9d1c91.js +0 -1
- package/assets/esri/core/workers/chunks/c30ca771dd3f7198142b.js +0 -1
- package/assets/esri/core/workers/chunks/e5fcd8e7a4a660ef6ad6.js +0 -1
- package/assets/esri/core/workers/chunks/f47319d36f1527277923.js +0 -1
- package/assets/esri/core/workers/chunks/ff00ac01f0baaecaa890.js +0 -1
- /package/assets/esri/core/workers/chunks/{eccbddaec4be44c86f79.js.LICENSE.txt → 1040bce57ea63a6dbca4.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{057d288d795b853295f1.js.LICENSE.txt → 353c67da4b25c29360db.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{44b30bce8e9a75b9e1b3.js.LICENSE.txt → 47948c72bc01bd173c20.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{754f7ed62afc4e0a1972.js.LICENSE.txt → dd0acd0f8b96839b4f24.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{2dbd88566abac030e965.js.LICENSE.txt → f859c53432f258af77e3.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedFunction as a}from"../../core/deprecate.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import c from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{watch as f,syncAndInitial as m,initial as y,on as g,when as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W,subclass as M}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as b}from"../../editing/templateUtils.js";import{getGraphicLayer as S}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as A,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as E}from"../../portal/support/urlUtils.js";import C from"../../views/SelectionManager.js";import{fetchFullFeaturesByObjectId as U}from"../../views/draw/support/editingSessionUtils.js";import O from"../../views/interactive/sketch/SketchLabelOptions.js";import j from"../../views/interactive/sketch/SketchOptions.js";import P from"../../views/interactive/sketch/SketchTooltipOptions.js";import R from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as H}from"../../views/interactive/snapping/SnappingManager.js";import q from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as x}from"../../views/support/selectionUtils.js";import G from"../Attachments/AttachmentsViewModel.js";import D from"./CreateFeaturesWorkflow.js";import B from"./UpdateWorkflow.js";import{getLayersFromWorkflow as N,isCreateFeaturesWorkflow as Q,isUpdateRecordWorkflow as z,isUpdateFeaturesWorkflow as Z,isMergeFeaturesWorkflow as $,isSplitFeatureWorkflow as J,isUpdateWorkflow as K,findEditorItemForLayerOrThrow as X,toFeatureInfos as Y,fetchFullFeatures as ee,findEditorItemForLayer as te,whenEditorLayerView as ie}from"./workflowUtils.js";import oe from"./support/EditorItem.js";import{assertViewNot3D as ae,MultipleSourceLayersError as re,InsufficientFeatureCountError as se,MissingOriginLayerError as ne,assertMergeWorkflowCapabilities as le,FetchFullFeatureError as ce,assertSplitWorkflowCapabilities as de}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as pe}from"../FeatureTemplates/featureTemplatesUtils.js";import he from"../FeatureTemplates/FeatureTemplatesViewModel.js";import ue from"../Sketch/SketchViewModel.js";import we from"../Spinner/SpinnerViewModel.js";import{goTo as fe}from"../support/goToUtils.js";import{isFeatureItem as me,isLayerItem as ye}from"../support/SelectionList/selectionListUtils.js";import ge from"../support/SelectionList/SelectionListViewModel.js";import ke from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ve(e,t){return e?.find(e=>e.layer===t)}let _e=class extends s{constructor(e){super(e),this._defaultSelectionManager=new C,this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new T,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new o,this.editorItems=new o,this.editorItemsLayerMap=new w,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new G({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new he({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new ue({layer:this._sketchGraphicsLayer,useLegacyCreateTools:this._get("useLegacyCreateTools")??!0}),this.selectionListViewModel=new ge,this.selectionManager=null,this.selectionToolbarViewModel=new ke({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new j,this.snappingOptions=new q({attributeRulesEnabled:!0}),this.spinnerViewModel=new we,this.syncViewSelection=!1,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this.showConfirmationPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save(this.showConfirmationPrompt)),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:o}=i.data;o.removeAll(),e&&o.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,o=i?.filter(e=>!!t?.includes(e.layer));return[t,o,this.layerInfos]},()=>this._updateEditorItems(),m),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),y),g(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),g(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),g(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),k(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this._defaultSelectionManager.highlightEnabled=!e),k(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),y),g(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},m),k(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),g(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const o={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(o);await this.startCreateFeaturesWorkflowAtFeatureCreation(o)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},m),g(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),g(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=N(t),o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=d(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new H({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},m),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},m),g(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:o})=>{t.view=e,i.view=e,o.view=e},m),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this._defaultSelectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new o;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new o;if(this.syncViewSelection||this.selectionManager)return e;for(const t of this.editorItems)x(t.layer)&&t.supportsUpdateWorkflow&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return Q(e)?e.pendingFeatures.length:z(e)&&e.data.edits.feature?1:Z(e)?e.data.fullFeatures.length:$(e)?e.data.features.length:J(e)?2:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&K(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){const e=this.view;return e&&this.syncViewSelection?e.selectionManager:this.selectionManager??this._defaultSelectionManager}get featureFormViewModel(){return null}get formViewModel(){return this.activeWorkflow?.formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get useLegacyCreateTools(){return this.ownSketchViewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.ownSketchViewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){return this._getWorkingFeatures().some(e=>e.geometry)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&e.formViewModel?.activeAssociationsInput)return e.formViewModel.activeAssociationsInput.associatedLayer?"viewing-associated-features":"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get formDisabled(){const{activeLeafWorkflow:e}=this;if(z(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled||!0===e.formViewModel.readOnly;if(Z(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get formHasAssociation(){return!!this.formViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(z(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!Z(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}activateSelectionTool(e){return this.selectionToolbarViewModel.activateTool(e)}cancelSelectionTool(){this.selectionToolbarViewModel.cancel()}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,o=i?X(this.editorItems,i):void 0;if(!o?.supportsCreateFeaturesWorkflow)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow({initialFeature:t,layer:o.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",a),await a.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ae(this,"merge-features");const i=Array.isArray(e)?Y(e):[e];if(i.length>1)throw new re;if(0===i.length||i[0].objectIds.length<2)throw new se(2);const a=i[0],r=a.layer;if(!r)throw new ne;const s=X(this.editorItems,r);le(s);const l=this._createUpdatingResolver(),c=new AbortController;this.addHandles(n(c));try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=await U(a.objectIds,r,this.view?.spatialReference,c.signal);if(e.length!==a.objectIds.length)throw new ce;let i;if(t.keyFeature){const o=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===o)??t.keyFeature}const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(e),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:i}}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(d){this._logErrorAndCancelWorkflow(d)}finally{l.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating),ae(this,"split-feature");const i=S(e);if(!i)throw new ne;const a=X(this.editorItems,i);de(a);const r=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow(),this.cancelSelectionTool();const a=await ee([e],i,this.view?.spatialReference,s.signal);if(1!==a.length)throw new ce;const r=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(a),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",r),this.addHandles(this._destroyWorkflowOnCommit(r)),await r.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{r.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=Array.isArray(e)?Y(e):[e];if(t.length>1)throw new re;const i=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.cancelSelectionTool();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)throw new r("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new r("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t,"update")}async deleteFeatureFromWorkflow(){a(c.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;if(K(e))return e.deleteActiveFeatures();this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}itemHasInvalidFormTemplate(e){return null!=e&&!0===te(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:o}=this;if(!i)return;const a=void 0,r=e??o?.createGraphic;if(r)"mesh"===r.geometry?.type?fe(i,r.geometry,a):fe(i,r,a);else{const e=this._getWorkingFeatures();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?fe(i,e.map(e=>e.geometry).filter(t),a):e&&fe(i,e,a)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){me(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){me(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):ye(e)&&await this._startUpdateWorkflowWithLayerItem(e,t)}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,o=i.editableLayers.toArray(),a=i.allTables.toArray().filter(e=>I(e)||A(e));return await Promise.allSettled([...o.flatMap(e=>this._getLayerLoadPromise(e)),...a.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...o.reverse(),...a.reverse()].filter(e=>F(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return A(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return this._drainEditorItems(),void this.editorItemsLayerMap.clear();const o=[],a=[],r=[],{editorItemsLayerMap:s,layerInfos:n}=this;for(const c of i){const t=ve(n,c),i=await ie(e,c).catch(()=>null),l=t?o:i?a:r,d=new oe({layer:c,layerInfo:t,layerView:i});l.push(d),s.set(c,d)}n?.length&&o.sort((e,t)=>n.findIndex(({layer:t})=>t===e.layer)-n.findIndex(({layer:e})=>e===t.layer));const l=[...o,...a,...r];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(l))});this._updatingHandles.consumePromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const o=await b({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of o)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.consumePromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const o of e){const e=t.get(o);e&&e.length>0&&i.push(pe(o,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return D.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){const i=B.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t),applyAttachmentEdits:(e,t)=>this._editAttachments(e,t)});return i}async _editAttachments(e,i){const o=[];i.adds.forEach(t=>o.push(this._addAttachment(e,t))),i.updates.forEach(t=>o.push(this._updateAttachment(e,t))),i.deletes.forEach(t=>o.push(this._deleteAttachments(e,t)));return(await Promise.all(o)).filter(t).flat()}_addAttachments(e,t){return Promise.all(t.map(t=>this._addAttachment(e,t)))}async _addAttachment(e,t){let i=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Adding attachments is not supported for this layer.");const{feature:o,attachment:a,keywords:s}=t,n=s?{keywords:s}:void 0;return await this._queueOperation(async()=>(i=await(e.addAttachment?.(o,a,n).catch(e=>{throw e?.error||e}))??null,i)),i}async _updateAttachment(e,t){if(!("updateAttachment"in e)||!e.updateAttachment||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Updating attachments is not supported for this layer");const{feature:i,attachmentId:o,attachment:a}=t;let s=null;return await this._queueOperation(async()=>(s=await e.updateAttachment(i,o,a).catch(e=>{throw e?.error||e}),s)),s}async _deleteAttachments(e,t){if(!("deleteAttachments"in e)||!e.deleteAttachments||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Deleting attachments is not supported for this layer");const{feature:i,attachmentIds:o}=t;let a=null;return await this._queueOperation(async()=>(a=await e.deleteAttachments(i,o).catch(e=>{throw e?.error||e}),a)),a}async _applyEdits(e,t,i){let o=null;const a=e.url?await L(e.url):null,r={returnServiceEditsOption:(!a||!E(a))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,editsRespectTrueCurves:!0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const a=await ie(i,e).catch(()=>null);return o=await e.applyEdits(t,r),a&&await _(()=>!a.updating),o}),o}async _applyEditsFeatureService(e,t,i){let o=null;return await this._queueOperation(async()=>o=await e.applyEdits(t,i)),o}_destroyWorkflowOnCommit(e){return g(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const o={error:i,retry:()=>(t(o,this.failures),this._queueOperation(e)),cancel:()=>{t(o,this.failures)}};this._set("failures",[...this.failures,o])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:o}=e,a=t.find(e=>!!e.error)||o.find(e=>!!e.error)||i.find(e=>!!e.error);if(a)throw a.error}}_createUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:o}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,o??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=X(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new r(e,t,i))}_syncSelectionSources(){this._defaultSelectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:o}=this;this._queuedSelectionTool=void 0;const a=[],r=[];i.forEach(e=>{const t=S(e),i=this.editorItemsLayerMap.get(t);i?.editable&&r.push(e),!1!==i?.visible&&a.push(e)});const s=1===a.length&&r.includes(a[0]);if("ready"===this.state&&s&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(a[0]);switch(t){case"remove":o.updateSelection({current:[],added:[],removed:a});break;case"replace":o.clear(),o.updateSelection({current:a,added:[],removed:[]});break;case"add":o.updateSelection({current:a,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),o=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let a;if(null!=o&&""!==o){const e=Y(i);if(e.length>1)throw new re;if(a=e[0],!a)throw new se("merge"===t?2:1)}else a={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(a):"merge"===t&&await this.startMergeFeaturesWorkflow(a)}_getWorkingFeatures(){const{sketchViewModel:e}=this;if(e?.createGraphic)return[e.createGraphic];if(e?.updateGraphics?.length)return e.updateGraphics.toArray();const{formViewModel:t}=this;return t?t.activeFeature?[t.activeFeature]:t.features.toArray():[]}};e([W()],_e.prototype,"_defaultSelectionManager",void 0),e([W()],_e.prototype,"_featureTemplatesLayersAndTables",null),e([W()],_e.prototype,"_queuedSelectionTool",void 0),e([W()],_e.prototype,"_snappingManager",void 0),e([W()],_e.prototype,"_selectionSources",null),e([W()],_e.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],_e.prototype,"activeWorkflow",void 0),e([W()],_e.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],_e.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],_e.prototype,"canCreate",null),e([W()],_e.prototype,"canCreateVisible",null),e([W({readOnly:!0})],_e.prototype,"canUpdate",null),e([W()],_e.prototype,"canUpdateVisible",null),e([W()],_e.prototype,"featureTemplatesLayers",null),e([W()],_e.prototype,"editorItems",void 0),e([W()],_e.prototype,"editorItemsLayerMap",void 0),e([W()],_e.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],_e.prototype,"failures",void 0),e([W()],_e.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:G})],_e.prototype,"attachmentsViewModel",void 0),e([W()],_e.prototype,"featureFormViewModel",null),e([W()],_e.prototype,"formViewModel",null),e([W()],_e.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:he})],_e.prototype,"featureTemplatesViewModel",void 0),e([W({type:O})],_e.prototype,"labelOptions",null),e([W()],_e.prototype,"layerInfos",void 0),e([W()],_e.prototype,"useLegacyCreateTools",null),e([W()],_e.prototype,"isUsingLegacyCreateTools",null),e([W()],_e.prototype,"ownSketchViewModel",void 0),e([W()],_e.prototype,"selectionListViewModel",void 0),e([W()],_e.prototype,"selectionManager",void 0),e([W()],_e.prototype,"selectionToolbarViewModel",void 0),e([W()],_e.prototype,"sketchOptions",void 0),e([W()],_e.prototype,"sketchViewModel",null),e([W({type:q,nonNullable:!0})],_e.prototype,"snappingOptions",void 0),e([W()],_e.prototype,"spinnerViewModel",void 0),e([W()],_e.prototype,"state",null),e([W({readOnly:!0})],_e.prototype,"syncing",null),e([W()],_e.prototype,"syncViewSelection",void 0),e([W()],_e.prototype,"updating",null),e([W({type:P})],_e.prototype,"tooltipOptions",null),e([W({type:R})],_e.prototype,"valueOptions",null),e([W()],_e.prototype,"view",null),e([W()],_e.prototype,"canZoomTo",null),e([W()],_e.prototype,"pageStack",void 0),e([W()],_e.prototype,"showDiscardEditsPrompt",void 0),e([W()],_e.prototype,"showConfirmationPrompt",void 0),e([W()],_e.prototype,"_candidateCommitted",void 0),e([W()],_e.prototype,"page",null),e([W()],_e.prototype,"formDisabled",null),e([W()],_e.prototype,"formHasAssociation",null),e([W()],_e.prototype,"canGoBack",null),e([W()],_e.prototype,"shouldShowDeleteButton",null),e([W()],_e.prototype,"hasPendingEdits",null),e([W()],_e.prototype,"snappingManager",null),_e=e([M("esri.widgets.Editor.EditorViewModel")],_e);const We=_e;export{We as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedFunction as a}from"../../core/deprecate.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import c from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{watch as f,syncAndInitial as m,initial as y,on as g,when as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M,subclass as W}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as T}from"../../editing/templateUtils.js";import{getGraphicLayer as F}from"../../graphic/graphicOriginUtils.js";import S from"../../layers/GraphicsLayer.js";import{isEditableLayer as V}from"../../layers/support/editableLayers.js";import{isFeatureLayer as A,isSubtypeGroupLayer as E,getOwningPortalUrl as I}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import C from"../../views/SelectionManager.js";import{fetchFullFeaturesByObjectId as U}from"../../views/draw/support/editingSessionUtils.js";import O from"../../views/interactive/sketch/SketchLabelOptions.js";import j from"../../views/interactive/sketch/SketchOptions.js";import P from"../../views/interactive/sketch/SketchTooltipOptions.js";import R from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as H}from"../../views/interactive/snapping/SnappingManager.js";import q from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as x}from"../../views/support/selectionUtils.js";import G from"../Attachments/AttachmentsViewModel.js";import{isNextOrLegacyCreateFeaturesWorkflow as D,isNextOrLegacyUpdateRecordWorkflow as B,isNextOrLegacyUpdateFeaturesWorkflow as N,isNextOrLegacyMergeFeaturesWorkflow as Q,isNextOrLegacySplitFeatureWorkflow as z,isNextOrLegacyUpdateWorkflow as Z,isLegacyFeatureFormViewModel as $}from"./compatibilityAdapters.js";import J from"./CreateFeaturesWorkflow.js";import K from"./UpdateWorkflow.js";import{getLayersFromWorkflow as X,isBatchAttributeFormViewModel as Y,findEditorItemForLayerOrThrow as ee,toFeatureInfos as te,fetchFullFeatures as ie,findEditorItemForLayer as oe,whenEditorLayerView as ae}from"./workflowUtils.js";import re from"./legacy/CreateFeaturesWorkflow.js";import se from"./legacy/UpdateWorkflow.js";import ne from"./support/EditorItem.js";import{assertViewNot3D as le,MultipleSourceLayersError as ce,InsufficientFeatureCountError as de,MissingOriginLayerError as pe,assertMergeWorkflowCapabilities as he,FetchFullFeatureError as ue,assertSplitWorkflowCapabilities as we}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as fe}from"../FeatureTemplates/featureTemplatesUtils.js";import me from"../FeatureTemplates/FeatureTemplatesViewModel.js";import ye from"../Sketch/SketchViewModel.js";import ge from"../Spinner/SpinnerViewModel.js";import{goTo as ke}from"../support/goToUtils.js";import{isFeatureItem as ve,isLayerItem as _e}from"../support/SelectionList/selectionListUtils.js";import Me from"../support/SelectionList/SelectionListViewModel.js";import We from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function be(e,t){return e?.find(e=>e.layer===t)}let Te=class extends s{constructor(e){super(e),this._defaultSelectionManager=new C,this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new S({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new o,this.editorItems=new o,this.editorItemsLayerMap=new w,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new G({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new me({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new ye({layer:this._sketchGraphicsLayer,useLegacyCreateTools:this._get("useLegacyCreateTools")??!0}),this.selectionListViewModel=new Me,this.selectionManager=null,this.selectionToolbarViewModel=new We({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new j,this.snappingOptions=new q({attributeRulesEnabled:!0}),this.spinnerViewModel=new ge,this.syncViewSelection=!1,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this.showConfirmationPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.formSystem="legacy",this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save(this.showConfirmationPrompt)),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:o}=i.data;o.removeAll(),e&&o.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,o=i?.filter(e=>!!t?.includes(e.layer));return[t,o,this.layerInfos]},()=>this._updateEditorItems(),m),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),y),g(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),g(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),g(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),k(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this._defaultSelectionManager.highlightEnabled=!e),k(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),y),g(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},m),k(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),g(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const o={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(o);await this.startCreateFeaturesWorkflowAtFeatureCreation(o)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},m),g(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),g(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=X(t),o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=d(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new H({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},m),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},m),g(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:o})=>{t.view=e,i.view=e,o.view=e},m),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this._defaultSelectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new o;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new o;if(this.syncViewSelection||this.selectionManager)return e;for(const t of this.editorItems)x(t.layer)&&t.supportsUpdateWorkflow&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return D(e)?e.pendingFeatures.length:B(e)&&e.data.edits.feature?1:N(e)?e.data.fullFeatures.length:Q(e)?e.data.features.length:z(e)?2:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&Z(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){const e=this.view;return e&&this.syncViewSelection?e.selectionManager:this.selectionManager??this._defaultSelectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return $(e)?e:null}get formViewModel(){return this.activeWorkflow?.formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get useLegacyCreateTools(){return this.ownSketchViewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.ownSketchViewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){return this._getWorkingFeatures().some(e=>e.geometry)}get page(){const{activeWorkflow:e,state:t}=this;if(Y(e?.formViewModel)){if("update"===e?.type&&e.formViewModel?.activeAssociationsInput)return e.formViewModel.activeAssociationsInput.associatedLayer?"viewing-associated-features":"viewing-associated-layers"}else if("update"===e?.type&&e.formViewModel){const{associatedLayer:t,associationId:i}=e.formViewModel;if(t||null!=i)return"viewing-associated-features"}if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get formDisabled(){const{activeLeafWorkflow:e}=this;if(B(e)){const t=e.formViewModel,i=!$(t)&&t.readOnly;return!1===e.data.editorItem?.capabilities.update.attributes||!0===t.disabled||i}if(N(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(B(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(N(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get formHasAssociation(){return!!this.formViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(B(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!N(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}activateSelectionTool(e){return this.selectionToolbarViewModel.activateTool(e)}cancelSelectionTool(){this.selectionToolbarViewModel.cancel()}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,o=i?ee(this.editorItems,i):void 0;if(!o?.supportsCreateFeaturesWorkflow)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow({initialFeature:t,layer:o.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",a),await a.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),le(this,"merge-features");const i=Array.isArray(e)?te(e):[e];if(i.length>1)throw new ce;if(0===i.length||i[0].objectIds.length<2)throw new de(2);const a=i[0],r=a.layer;if(!r)throw new pe;const s=ee(this.editorItems,r);he(s);const l=this._createUpdatingResolver(),c=new AbortController;this.addHandles(n(c));try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=await U(a.objectIds,r,this.view?.spatialReference,c.signal);if(e.length!==a.objectIds.length)throw new ue;let i;if(t.keyFeature){const o=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===o)??t.keyFeature}const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(e),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:i}}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(d){this._logErrorAndCancelWorkflow(d)}finally{l.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating),le(this,"split-feature");const i=F(e);if(!i)throw new pe;const a=ee(this.editorItems,i);we(a);const r=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow(),this.cancelSelectionTool();const a=await ie([e],i,this.view?.spatialReference,s.signal);if(1!==a.length)throw new ue;const r=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(a),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",r),this.addHandles(this._destroyWorkflowOnCommit(r)),await r.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{r.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=Array.isArray(e)?te(e):[e];if(t.length>1)throw new ce;const i=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.cancelSelectionTool();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)throw new r("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new r("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t,"update")}async deleteFeatureFromWorkflow(){a(c.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;if(Z(e))return e.deleteActiveFeatures();this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}itemHasInvalidFormTemplate(e){return null!=e&&!0===oe(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:o}=this;if(!i)return;const a=void 0,r=e??o?.createGraphic;if(r)"mesh"===r.geometry?.type?ke(i,r.geometry,a):ke(i,r,a);else{const e=this._getWorkingFeatures();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?ke(i,e.map(e=>e.geometry).filter(t),a):e&&ke(i,e,a)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){ve(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){ve(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):_e(e)&&await this._startUpdateWorkflowWithLayerItem(e,t)}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,o=i.editableLayers.toArray(),a=i.allTables.toArray().filter(e=>A(e)||E(e));return await Promise.allSettled([...o.flatMap(e=>this._getLayerLoadPromise(e)),...a.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...o.reverse(),...a.reverse()].filter(e=>V(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return E(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return this._drainEditorItems(),void this.editorItemsLayerMap.clear();const o=[],a=[],r=[],{editorItemsLayerMap:s,layerInfos:n}=this;for(const c of i){const t=be(n,c),i=await ae(e,c).catch(()=>null),l=t?o:i?a:r,d=new ne({layer:c,layerInfo:t,layerView:i});l.push(d),s.set(c,d)}n?.length&&o.sort((e,t)=>n.findIndex(({layer:t})=>t===e.layer)-n.findIndex(({layer:e})=>e===t.layer));const l=[...o,...a,...r];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(l))});this._updatingHandles.consumePromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const o=await T({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of o)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.consumePromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const o of e){const e=t.get(o);e&&e.length>0&&i.push(fe(o,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return"legacy"===this.formSystem?re.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)}):J.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){if("legacy"===this.formSystem)return se.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});const i=K.create({sketchOptions:this.sketchOptions,viewModel:this,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t),applyAttachmentEdits:(e,t)=>this._editAttachments(e,t)});return i}async _editAttachments(e,i){const o=[];i.adds.forEach(t=>o.push(this._addAttachment(e,t))),i.updates.forEach(t=>o.push(this._updateAttachment(e,t))),i.deletes.forEach(t=>o.push(this._deleteAttachments(e,t)));return(await Promise.all(o)).filter(t).flat()}_addAttachments(e,t){return Promise.all(t.map(t=>this._addAttachment(e,t)))}async _addAttachment(e,t){let i=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Adding attachments is not supported for this layer.");const{feature:o,attachment:a,keywords:s}=t,n=s?{keywords:s}:void 0;return await this._queueOperation(async()=>(i=await(e.addAttachment?.(o,a,n).catch(e=>{throw e?.error||e}))??null,i)),i}async _updateAttachment(e,t){if(!("updateAttachment"in e)||!e.updateAttachment||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Updating attachments is not supported for this layer");const{feature:i,attachmentId:o,attachment:a}=t;let s=null;return await this._queueOperation(async()=>(s=await e.updateAttachment(i,o,a).catch(e=>{throw e?.error||e}),s)),s}async _deleteAttachments(e,t){if(!("deleteAttachments"in e)||!e.deleteAttachments||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Deleting attachments is not supported for this layer");const{feature:i,attachmentIds:o}=t;let a=null;return await this._queueOperation(async()=>(a=await e.deleteAttachments(i,o).catch(e=>{throw e?.error||e}),a)),a}async _applyEdits(e,t,i){let o=null;const a=e.url?await I(e.url):null,r={returnServiceEditsOption:(!a||!L(a))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,editsRespectTrueCurves:!0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const a=await ae(i,e).catch(()=>null);return o=await e.applyEdits(t,r),a&&await _(()=>!a.updating),o}),o}async _applyEditsFeatureService(e,t,i){let o=null;return await this._queueOperation(async()=>o=await e.applyEdits(t,i)),o}_destroyWorkflowOnCommit(e){return g(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const o={error:i,retry:()=>(t(o,this.failures),this._queueOperation(e)),cancel:()=>{t(o,this.failures)}};this._set("failures",[...this.failures,o])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:o}=e,a=t.find(e=>!!e.error)||o.find(e=>!!e.error)||i.find(e=>!!e.error);if(a)throw a.error}}_createUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:o}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,o??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=ee(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new r(e,t,i))}_syncSelectionSources(){this._defaultSelectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:o}=this;this._queuedSelectionTool=void 0;const a=[],r=[];i.forEach(e=>{const t=F(e),i=this.editorItemsLayerMap.get(t);i?.editable&&r.push(e),!1!==i?.visible&&a.push(e)});const s=1===a.length&&r.includes(a[0]);if("ready"===this.state&&s&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(a[0]);switch(t){case"remove":o.updateSelection({current:[],added:[],removed:a});break;case"replace":o.clear(),o.updateSelection({current:a,added:[],removed:[]});break;case"add":o.updateSelection({current:a,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),o=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let a;if(null!=o&&""!==o){const e=te(i);if(e.length>1)throw new ce;if(a=e[0],!a)throw new de("merge"===t?2:1)}else a={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(a):"merge"===t&&await this.startMergeFeaturesWorkflow(a)}_getWorkingFeatures(){const{sketchViewModel:e}=this;if(e?.createGraphic)return[e.createGraphic];if(e?.updateGraphics?.length)return e.updateGraphics.toArray();const{formViewModel:i}=this;return i?$(i)?[i.feature].filter(t):i.activeFeature?[i.activeFeature]:i.features.toArray():[]}};e([M()],Te.prototype,"_defaultSelectionManager",void 0),e([M()],Te.prototype,"_featureTemplatesLayersAndTables",null),e([M()],Te.prototype,"_queuedSelectionTool",void 0),e([M()],Te.prototype,"_snappingManager",void 0),e([M()],Te.prototype,"_selectionSources",null),e([M()],Te.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],Te.prototype,"activeWorkflow",void 0),e([M()],Te.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],Te.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],Te.prototype,"canCreate",null),e([M()],Te.prototype,"canCreateVisible",null),e([M({readOnly:!0})],Te.prototype,"canUpdate",null),e([M()],Te.prototype,"canUpdateVisible",null),e([M()],Te.prototype,"featureTemplatesLayers",null),e([M()],Te.prototype,"editorItems",void 0),e([M()],Te.prototype,"editorItemsLayerMap",void 0),e([M()],Te.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],Te.prototype,"failures",void 0),e([M()],Te.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:G})],Te.prototype,"attachmentsViewModel",void 0),e([M()],Te.prototype,"featureFormViewModel",null),e([M()],Te.prototype,"formViewModel",null),e([M()],Te.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:me})],Te.prototype,"featureTemplatesViewModel",void 0),e([M({type:O})],Te.prototype,"labelOptions",null),e([M()],Te.prototype,"layerInfos",void 0),e([M()],Te.prototype,"useLegacyCreateTools",null),e([M()],Te.prototype,"isUsingLegacyCreateTools",null),e([M()],Te.prototype,"ownSketchViewModel",void 0),e([M()],Te.prototype,"selectionListViewModel",void 0),e([M()],Te.prototype,"selectionManager",void 0),e([M()],Te.prototype,"selectionToolbarViewModel",void 0),e([M()],Te.prototype,"sketchOptions",void 0),e([M()],Te.prototype,"sketchViewModel",null),e([M({type:q,nonNullable:!0})],Te.prototype,"snappingOptions",void 0),e([M()],Te.prototype,"spinnerViewModel",void 0),e([M()],Te.prototype,"state",null),e([M({readOnly:!0})],Te.prototype,"syncing",null),e([M()],Te.prototype,"syncViewSelection",void 0),e([M()],Te.prototype,"updating",null),e([M({type:P})],Te.prototype,"tooltipOptions",null),e([M({type:R})],Te.prototype,"valueOptions",null),e([M()],Te.prototype,"view",null),e([M()],Te.prototype,"canZoomTo",null),e([M()],Te.prototype,"pageStack",void 0),e([M()],Te.prototype,"showDiscardEditsPrompt",void 0),e([M()],Te.prototype,"showConfirmationPrompt",void 0),e([M()],Te.prototype,"_candidateCommitted",void 0),e([M()],Te.prototype,"page",null),e([M()],Te.prototype,"formDisabled",null),e([M()],Te.prototype,"featureFormDisabled",null),e([M()],Te.prototype,"featureFormHasAssociation",null),e([M()],Te.prototype,"formHasAssociation",null),e([M()],Te.prototype,"formSystem",void 0),e([M()],Te.prototype,"canGoBack",null),e([M()],Te.prototype,"shouldShowDeleteButton",null),e([M()],Te.prototype,"hasPendingEdits",null),e([M()],Te.prototype,"snappingManager",null),Te=e([W("esri.widgets.Editor.EditorViewModel")],Te);const Fe=Te;export{Fe as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../core/Collection.js";import i from"../../core/Error.js";import{makeHandle as
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../core/Collection.js";import i from"../../core/Error.js";import{makeHandle as r,abortHandle as a}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as l}from"../../core/reactiveUtils.js";import{property as n,subclass as d}from"../../core/accessorSupport/decorators.js";import h from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as c}from"../../views/support/HighlightDefaults.js";import u from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import p from"./UpdateRecordWorkflowData.js";import m from"./Workflow.js";import{fetchFullFeatures as f,handleFormValuesChangeEvent as g}from"./workflowUtils.js";import{toAttachmentEdit as w,toEditAttachmentsPayload as y}from"./support/attachmentUtils.js";var b;const F={exit:Symbol()};let v=class extends m{static{b=this}constructor(t){super(t),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:t}=this,{edits:e}=t,{view:l}=t.viewModel,n=e.feature;l&&(this._highlightHelper=new h({view:l,highlightName:c}),this.addHandles(r(()=>this._highlightHelper?.removeAll())));const d=new AbortController;this.addHandles(a(d)),this._updatingHandles.consumePromise(f([n],n.sourceLayer,t.viewModel.view.spatialReference,d.signal).then(([t])=>{s(d)||(this._onFullFeatureLoaded(t),this._initializeFormViewModel())},t=>(o.getLogger(this).error("initialize()","Failed to fetch full feature for update workflow.",t),this.cancel({force:!0,error:new i("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:t}})}))))}get allowSave(){return!this.data.readOnly&&this.hasPendingEdits&&!this.updating}get editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItem.hasInvalidFormTemplate}get hasPendingEdits(){return this.data.edits.modified&&!this.data.readOnly}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const t=this.editorItem.capabilities;return t.update.reliesOnOwnerAdminPrivileges||t.delete.reliesOnOwnerAdminPrivileges}async enter(){}exit(t){this.removeHandles(F.exit)}async start(){return await super.start(),null}_initializeFormViewModel(){const{association:t,edits:i,viewModel:{view:r},readOnly:a,editorItem:o}=this.data,{fullFeature:s}=this,n=o.layerInfo?[o.layerInfo]:null,d=this._formViewModel=new u({activeFeatureIndex:0,attachmentsEnabled:!0,editType:"UPDATE",features:new e([s]),highlightHelper:this._highlightHelper,layerInfos:n,map:r?.map,readOnly:a,spatialReference:r.spatialReference,timeZone:r?.timeZone,callbacks:this.data.formCallbacks});t&&d.setActiveAssociation(t);const{initialFeature:h}=i;h&&d.overrideOriginalFeature(s,h),this.addHandles([d.on("values-change",g({filter:t=>t===s,forEachFeature:()=>{i.updateAttributes(d.getValues(s)),s.attributes=i.feature.attributes}})),d.on("attachments-change",t=>i.setAttachmentEdits(t.attachmentEdits)),l(()=>r?.timeZone,t=>d.timeZone=t)])}_onFullFeatureLoaded(t){this.fullFeature=t;const{edits:e}=this.data;e.updateAttributes(t.attributes),e.trackChanges()}static async create(t){const e=new b({data:await p.create(t),onCommit:this._onCommitFactory(t.applyEdits,t.applyAttachmentEdits)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){}},{id:"editing-attachment",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=(t,e)=>async i=>{const{edits:r,editorItem:a}=i,{feature:o}=r;if(!o)return;const s=o.sourceLayer,l=o.clone();if(!r.attributesModified||r.stagedForDelete){const t=s.objectIdField;if(l.attributes={[t]:o.getAttribute(t)},"scene"===s.type&&null!=s.infoFor3D){const t=s.associatedLayer?.globalIdField;null!=t&&l.setAttribute(t,o.getAttribute(t))}}const n=a.supportsGlobalIds&&"globalIdField"in s;if(n){const t=s.globalIdField;null!=t&&l.setAttribute(t,o.getAttribute(t))}r.geometryModified&&!r.stagedForDelete||(l.geometry=null);const d=r.stagedForDelete?"deleteFeatures":"updateFeatures",h=[],c=[],u=[],p={[d]:[l]};let m;r.attachmentsModified&&(r.attachmentEdits.forEach(t=>{t.adds.forEach(t=>h.push(w(t))),t.updates.forEach(t=>c.push(w(t))),t.deletes.forEach(t=>u.push(t.globalId))}),n&&(m={globalIdUsed:!0},h.length&&(p.addAttachments=h),c.length&&(p.updateAttachments=c),u.length&&(p.deleteAttachments=u)));await t(s,p,m)&&r.attachmentsModified&&!n&&await e(s,y(o,r.attachmentEdits))}}get test(){return{formViewModel:this._formViewModel}}};t([n()],v.prototype,"_formViewModel",void 0),t([n()],v.prototype,"allowSave",null),t([n()],v.prototype,"editorItem",null),t([n()],v.prototype,"formViewModel",null),t([n()],v.prototype,"fullFeature",void 0),t([n()],v.prototype,"hasInvalidFormTemplate",null),t([n()],v.prototype,"hasPendingEdits",null),t([n()],v.prototype,"layer",null),t([n()],v.prototype,"parent",null),t([n()],v.prototype,"saveActionLabel",null),t([n()],v.prototype,"shouldShowAttachments",null),t([n()],v.prototype,"shouldAllowAttachmentEditing",null),t([n()],v.prototype,"reliesOnOwnerAdminPrivileges",null),v=b=t([d("esri.widgets.Editor.UpdateRecordWorkflow")],v);export{v as UpdateRecordWorkflow,F as handleKeys};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{onAbort as n,createAbortError as l,throwIfAborted as c,debounce as d}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as w,sync as h,on as f,when as g}from"../../core/reactiveUtils.js";import{last as v}from"../../core/SetUtils.js";import{property as k,subclass as m}from"../../core/accessorSupport/decorators.js";import{getGraphicLayer as y}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as W}from"../../layers/support/editableLayers.js";import{isSubtypeSublayer as A,isSubtypeGroupLayer as _,isTable as b}from"../../layers/support/layerUtils.js";import{findUtilityNetwork as S,isGraphicForRelatableFeatureSupportedLayer as M}from"../../popup/support/featureUtils.js";import{createFeatureServices as C}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as U}from"../../views/input/InputManager.js";import{temporaryHighlightName as E}from"../../views/support/HighlightDefaults.js";import{isAssociationsLayerUnion as R}from"../BatchAttributeForm/batchAttributeFormUtils.js";import I from"./CreateFeaturesWorkflow.js";import j from"./MergeFeaturesWorkflow.js";import P from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as N}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as O}from"./UpdateRecordWorkflow.js";import T from"./UpdateWorkflowData.js";import x from"./Workflow.js";import{findEditorItemForLayer as D,isSplitFeatureWorkflow as L,workflowInfluencesOutcomeOfParent as H,isAnyUpdateLeafWorkflow as z,isUpdateRecordWorkflow as B,isParentWorkflow as G,findEditorItemForLayerOrThrow as q,createWorkflowSteps as Q,fetchCandidates as $,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";var ee;let te=ee=class extends x{constructor(e){super(e),this._workflowStack=new p(v),this._sketchStack=new p(v),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;return!!(this.activeWorkflow&&this.data.viewModel.view?.map&&e)&&!(!e.activeAssociation||!R(e.activeFeature?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}getUpdating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||!!this.activeWorkflow?.formViewModel?.canGoBack}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>D(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}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 noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}get curveResizeDisabled(){return this.activeWorkflow?.curveResizeDisabled??!1}get curveUpdatesDisabled(){return this.activeWorkflow?.curveUpdatesDisabled??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);if(e?.featureSpatialItems.length)return void e.reset()}if(i?.canGoBack)await i.goBack();else if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(L(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){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})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:a,applyAttachmentEdits:o,...r}=e,s=new ee({data:new T({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,applyAttachmentEditsCallback:o,...r}),onCommit:async()=>{}});return s._set("steps",this._createWorkflowSteps(s,t)),s}async save(e){const{formViewModel:t}=this;if(t&&(await t.submit(),!t.valid))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:i}=this;if(await(i?.commit(e)),!H(i))return void await this._popWorkflowAndReconcile();this._popWorkflow();const a=this._workflowStack.peek();if(a&&a===i?.parent&&(await a.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:o})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:o})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:o})}finally{i.resolve()}}async startAddAssociation(e){const t=this._makeUpdatingResolver();try{const t=await this._createNestedAddAssociationWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=z(e);if(t){e.data.stageDelete();const t=B(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),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._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!e)throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,activeFeature:i}=e,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=A(s)&&s.parent?s.parent:s,l=C([n]),c=l.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 d=r.view.map,p=S(d,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await o(c,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const a of e)i(t,a)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!e?.activeAssociationsInput)return;const{activeAssociationsInput:t}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&e.setActiveAssociationsLayer(null),t.associatedFeatureInfos.size||e.setActiveAssociationsInput(null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!W(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const c=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=c.template||c.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:c,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:d,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!W(i)||_(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={}){const i=b(e.sourceLayer)?O:N,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,applyAttachmentEditsCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,c=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:c,sketchOptions:s,snappingManager:n,viewModel:l,applyEdits:a,applyEditsFeatureService:o,applyAttachmentEdits:r,formCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},editAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e)}},...t});return await u(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:a,featureInfos:e,viewModel:o,...t});return await u(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e){const{feature:t,associationType:i,utilityNetwork:o}=e,{AddAssociationWorkflow:r}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:s,applyEditsFeatureServiceCallback:n,viewModel:l}=this.data,c=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,p=d?.activeAssociationsInput;if(!p)throw new a("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const w=await r.create({utilityNetwork:o,associationType:i,feature:t,parent:c,viewModel:l,associationsInput:p,applyEdits:s,applyEditsFeatureService:n});return await u(()=>!w.updating),w}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(e);const r=q(this.data.viewModel.editorItems,y(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:e,parent:s,viewModel:o,...t});return await u(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,sketchOptions:o,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=q(s.editorItems,e.sourceLayer),c=P.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,feature:e,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...t});return await u(()=>!c.updating),c}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const a of t){const t=e(a).finally(()=>a.destroy());this._updatingHandles.consumePromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:a}=e;if(!M(t))return;const o=i.relationships?.find(e=>e.id===a);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===a);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=ie(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 c=ie(i,o);return{[c]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();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 _pushWorkflowAndReconcile(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 i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,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&&!b(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return Q(["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}=i.viewModel,a=i.viewModel.view;a.activeTool=null;let r=null;e.addHandles(o(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const d=a.on("immediate-click",async o=>{const s=Promise.withResolvers();e._updatingHandles.consumePromise(s.promise);try{t.location=o.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const d=await o.defer(()=>new Promise((e,t)=>{n(r?.signal,()=>t(l())),e($(s,a,o,r?.signal))}));if(c(r),i.candidates=d.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(o.stopPropagation(),1===i.candidates.length){const{rootFeatures:a}=i;a.removeAll(),a.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},U.TOOL),p=g(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([d,p],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const a=new F({view:t,highlightName:E});e.addHandles([f(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>a.remove(e)),e.forEach(e=>a.add(e))},h),o(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await ae(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=d(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([w(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},h)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.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 ie(e,{keyField:t}){return e.getField(t)?.name??t}async function ae(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(J(i)){const{rootFeatureInfos:o}=t,r=o.length>0?o:K(t.rootFeatures.toArray());if(0===r.length)throw new a("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:o}=t,r=o.getItemAt(0);if(!r)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await e.startMergingFeatures(o.toArray(),i.props):Y(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([k()],te.prototype,"formViewModel",null),e([k()],te.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([k()],te.prototype,"activeSketchViewModel",null),e([k()],te.prototype,"canDeleteAssociation",null),e([k()],te.prototype,"activeWorkflow",null),e([k()],te.prototype,"data",void 0),e([k()],te.prototype,"hasPreviousStep",null),e([k()],te.prototype,"hasUpdatableCandidates",null),e([k()],te.prototype,"nestedWorkflowCount",null),e([k()],te.prototype,"shouldShowAttachments",null),e([k()],te.prototype,"shouldAllowAttachmentEditing",null),e([k()],te.prototype,"hasPendingEdits",null),e([k()],te.prototype,"helpMessage",null),e([k()],te.prototype,"noticeMessage",null),e([k()],te.prototype,"reliesOnOwnerAdminPrivileges",null),e([k()],te.prototype,"hasInvalidFormTemplate",null),e([k()],te.prototype,"curveResizeDisabled",null),e([k()],te.prototype,"curveUpdatesDisabled",null),te=ee=e([m("esri.widgets.Editor.UpdateWorkflow")],te);const oe=te;export{oe as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{onAbort as n,createAbortError as l,throwIfAborted as c,debounce as d}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as w,sync as h,on as f,when as g}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as v,subclass as m}from"../../core/accessorSupport/decorators.js";import{getGraphicLayer as y}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as W}from"../../layers/support/editableLayers.js";import{isSubtypeSublayer as A,isSubtypeGroupLayer as _,isTable as b}from"../../layers/support/layerUtils.js";import{findUtilityNetwork as S,isGraphicForRelatableFeatureSupportedLayer as C}from"../../popup/support/featureUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as U}from"../../views/input/InputManager.js";import{temporaryHighlightName as E}from"../../views/support/HighlightDefaults.js";import{isAssociationsLayerUnion as R}from"../BatchAttributeForm/batchAttributeFormUtils.js";import I from"./CreateFeaturesWorkflow.js";import j from"./MergeFeaturesWorkflow.js";import P from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as N}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as O}from"./UpdateRecordWorkflow.js";import T from"./UpdateWorkflowData.js";import x from"./Workflow.js";import{findEditorItemForLayer as D,isSplitFeatureWorkflow as L,workflowInfluencesOutcomeOfParent as H,isAnyUpdateLeafWorkflow as z,isUpdateRecordWorkflow as B,isParentWorkflow as G,findEditorItemForLayerOrThrow as q,createWorkflowSteps as Q,fetchCandidates as $,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";var ee;let te=ee=class extends x{constructor(e){super(e),this._workflowStack=new p(k),this._sketchStack=new p(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;return!!(this.activeWorkflow&&this.data.viewModel.view?.map&&e)&&!(!e.activeAssociation||!R(e.activeFeature?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}getUpdating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||!!this.activeWorkflow?.formViewModel?.canGoBack}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>D(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}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 noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}get curveResizeDisabled(){return this.activeWorkflow?.curveResizeDisabled??!1}get curveUpdatesDisabled(){return this.activeWorkflow?.curveUpdatesDisabled??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);if(e?.featureSpatialItems.length)return void e.reset()}if(i?.canGoBack)await i.goBack();else if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(L(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){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})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:a,applyAttachmentEdits:o,...r}=e,s=new ee({data:new T({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,applyAttachmentEditsCallback:o,...r}),onCommit:async()=>{}});return s._set("steps",this._createWorkflowSteps(s,t)),s}async save(e){const{formViewModel:t}=this;if(t&&(await t.submit(),!t.valid))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:i}=this;if(await(i?.commit(e)),!H(i))return void await this._popWorkflowAndReconcile();this._popWorkflow();const a=this._workflowStack.peek();if(a&&a===i?.parent&&(await a.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:o})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:o})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:o})}finally{i.resolve()}}async startAddAssociation(e){const t=this._makeUpdatingResolver();try{const t=await this._createNestedAddAssociationWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=z(e);if(t){e.data.stageDelete();const t=B(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),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._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!e)throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,activeFeature:i}=e,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=A(s)&&s.parent?s.parent:s,l=M([n]),c=l.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 d=r.view.map,p=S(d,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await o(c,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const a of e)i(t,a)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!e?.activeAssociationsInput)return;const{activeAssociationsInput:t}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&e.setActiveAssociationsLayer(null),t.associatedFeatureInfos.size||e.setActiveAssociationsInput(null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!W(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const c=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=c.template||c.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:c,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:d,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!W(i)||_(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={}){const i=b(e.sourceLayer)?O:N,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,applyAttachmentEditsCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data,c=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:c,sketchOptions:s,snappingManager:n,viewModel:l,applyEdits:a,applyEditsFeatureService:o,applyAttachmentEdits:r,formCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},editAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e)}},...t});return await u(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:a,featureInfos:e,viewModel:o,...t});return await u(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e){const{feature:t,associationType:i,utilityNetwork:o}=e,{AddAssociationWorkflow:r}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:s,applyEditsFeatureServiceCallback:n,viewModel:l}=this.data,c=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,p=d?.activeAssociationsInput;if(!p)throw new a("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const w=await r.create({utilityNetwork:o,associationType:i,feature:t,parent:c,viewModel:l,associationsInput:p,applyEdits:s,applyEditsFeatureService:n});return await u(()=>!w.updating),w}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(e);const r=q(this.data.viewModel.editorItems,y(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:e,parent:s,viewModel:o,...t});return await u(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,sketchOptions:o,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=q(s.editorItems,e.sourceLayer),c=P.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,feature:e,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...t});return await u(()=>!c.updating),c}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const a of t){const t=e(a).finally(()=>a.destroy());this._updatingHandles.consumePromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:a}=e;if(!C(t))return;const o=i.relationships?.find(e=>e.id===a);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===a);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=ie(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 c=ie(i,o);return{[c]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();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 _pushWorkflowAndReconcile(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 i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,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&&!b(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return Q(["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}=i.viewModel,a=i.viewModel.view;a.activeTool=null;let r=null;e.addHandles(o(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const d=a.on("immediate-click",async o=>{const s=Promise.withResolvers();e._updatingHandles.consumePromise(s.promise);try{t.location=o.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const d=await o.defer(()=>new Promise((e,t)=>{n(r?.signal,()=>t(l())),e($(s,a,o,r?.signal))}));if(c(r),i.candidates=d.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(o.stopPropagation(),1===i.candidates.length){const{rootFeatures:a}=i;a.removeAll(),a.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},U.TOOL),p=g(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([d,p],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const a=new F({view:t,highlightName:E});e.addHandles([f(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>a.remove(e)),e.forEach(e=>a.add(e))},h),o(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await ae(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=d(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([w(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},h)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){}})})}_logContinuingWithoutRelationshipWarning(e,t){r.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 ie(e,{keyField:t}){return e.getField(t)?.name??t}async function ae(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(J(i)){const{rootFeatureInfos:o}=t,r=o.length>0?o:K(t.rootFeatures.toArray());if(0===r.length)throw new a("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:o}=t,r=o.getItemAt(0);if(!r)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await e.startMergingFeatures(o.toArray(),i.props):Y(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([v()],te.prototype,"formViewModel",null),e([v()],te.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],te.prototype,"activeSketchViewModel",null),e([v()],te.prototype,"canDeleteAssociation",null),e([v()],te.prototype,"activeWorkflow",null),e([v()],te.prototype,"data",void 0),e([v()],te.prototype,"hasPreviousStep",null),e([v()],te.prototype,"hasUpdatableCandidates",null),e([v()],te.prototype,"nestedWorkflowCount",null),e([v()],te.prototype,"shouldShowAttachments",null),e([v()],te.prototype,"shouldAllowAttachmentEditing",null),e([v()],te.prototype,"hasPendingEdits",null),e([v()],te.prototype,"helpMessage",null),e([v()],te.prototype,"noticeMessage",null),e([v()],te.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],te.prototype,"hasInvalidFormTemplate",null),e([v()],te.prototype,"curveResizeDisabled",null),e([v()],te.prototype,"curveUpdatesDisabled",null),te=ee=e([m("esri.widgets.Editor.UpdateWorkflow")],te);const oe=te;export{oe as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
function e(e){return!!e&&"feature"in e}function t(e){return null!=e&&"create-features"===e.type}function u(e){return null!=e&&"update-features"===e.type}function n(e){return null!=e&&"update-feature"===e.type}function r(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function l(e){return null!=e&&"update"===e.type}function f(e){return null!=e&&"merge-features"===e.type}function p(e){return null!=e&&"split-feature"===e.type}export{e as isLegacyFeatureFormViewModel,t as isNextOrLegacyCreateFeaturesWorkflow,f as isNextOrLegacyMergeFeaturesWorkflow,p as isNextOrLegacySplitFeatureWorkflow,n as isNextOrLegacyUpdateFeatureWorkflow,u as isNextOrLegacyUpdateFeaturesWorkflow,r as isNextOrLegacyUpdateRecordWorkflow,l as isNextOrLegacyUpdateWorkflow};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r,subclass as
|
|
2
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import o from"../../Widget.js";import{isNextOrLegacySplitFeatureWorkflow as s,isNextOrLegacyCreateFeaturesWorkflow as n}from"../compatibilityAdapters.js";import{css as a}from"../css.js";import{CreateFeaturesWorkflowPendingFeatureListAdapter as l}from"./workflowAdapters/pendingFeatureList/CreateFeaturesWorkflowPendingFeatureListAdapter.js";import{SplitFeatureWorkflowPendingFeatureListAdapter as c}from"./workflowAdapters/pendingFeatureList/SplitFeatureWorkflowPendingFeatureListAdapter.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import{Heading as m,incrementHeadingLevel as p}from"../../support/Heading.js";import{ItemList as u}from"../../support/ItemList.js";import{fetchThumbnail as h}from"../../support/symbolPreviewUtils.js";import{messageBundle as f,tsx as g,tsxFragment as w}from"../../support/widget.js";let b=class extends o{constructor(){super(...arguments),this.workflow=null,this.workflowAdapter=null,this.headingLevel=4,this._iconIntersectionObserver=new IntersectionObserver((e,r)=>{e.forEach(async e=>{if(e.isIntersecting){const i=e.target;if(I(i))return void r.unobserve(i);const o=v(i),{graphic:s}=o,n=s.sourceLayer??this.workflowAdapter?.layer;if(!n||!s)return;k(i,!0);const a=o.id?t(this.messages.previewTemplateAriaLabel,{label:o.id}):this.messagesCommon.preview,l=await h(s,n,{ariaLabel:a}).catch(()=>(k(i,!1),null));if(null==l)return;i.appendChild(l)}})}),this.messages=null,this.messagesCommon=null,this._renderActionEnd=({graphic:e})=>{const{workflowAdapter:t,messages:r}=this;if(!t)return;const i=e.geometry?g("calcite-action",{icon:"zoom-to-object",slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo,onblur:()=>t.clearHighlights(),onclick:()=>t.zoomToFeature(e),onfocus:()=>t.highlightFeature(e)}):void 0,o=t.allowCancel?g("calcite-action",{icon:"trash",slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard,onblur:()=>t.clearHighlights(),onclick:()=>t.cancelFeature(e),onfocus:()=>t.highlightFeature(e)}):void 0;return g(w,null,i,o)},this._renderItemContentEnd=({graphic:e})=>{const{workflowAdapter:t}=this,r=t?.isSubmittable(e);return[r?void 0:g("calcite-icon",{class:a.pendingFeatureListIcon,icon:"exclamation-mark-triangle",scale:"s",slot:"content-end"})]},this._renderItemIcon=e=>{if(null!=e?.graphic?.geometry)return g("span",{afterCreate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":e,key:"icon"})},this._afterItemCreateOrUpdate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)}}loadDependencies(){return d({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}initialize(){this.workflowAdapter=L(this.workflow)}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}render(){const e=this.workflowAdapter;if(!e)return g(w,null,void 0);const t=this.messages,r=e.features.filter(t=>e.isVisible(t)).map((r,i)=>{const o=e.isSubmittable(r),s=o?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit;return{disabled:!1,id:`${e.getFeatureTitle(r)??i}`,graphic:r,label:s,submittable:o}}),i=s(this.workflow)?t.result:t.createFeaturesSelectionList.heading;return g("div",null,g(m,{level:p(this.headingLevel)},i),g("calcite-list",{label:i},u({enableListScroll:!1,filterEnabled:!1,filterText:"",id:"update-features-pick-list",items:r,messages:{filterPlaceholder:"",noItems:"",noMatches:""},renderIcon:this._renderItemIcon,renderItemTitle:e=>e.label,renderItemLabel:e=>e.id,onItemMouseEnter:e=>this.workflowAdapter?.highlightFeature(e.graphic),onItemMouseLeave:()=>this.workflowAdapter?.clearHighlights(),onItemSelect:e=>this.workflowAdapter?.onSelectFeature(e.graphic),renderItemContentEnd:this._renderItemContentEnd,renderItemActionEnd:this._renderActionEnd})))}};function v(e){return e?.["data-item"]}function I(e){return!!e?.["data-has-icon"]}function k(e,t){e&&(e["data-has-icon"]=t)}function L(e){return n(e)?new l({workflow:e}):s(e)?new c({workflow:e}):null}e([r()],b.prototype,"workflow",void 0),e([r()],b.prototype,"workflowAdapter",void 0),e([r()],b.prototype,"headingLevel",void 0),e([r(),f("esri/widgets/Editor/t9n/Editor")],b.prototype,"messages",void 0),e([r(),f("esri/t9n/common")],b.prototype,"messagesCommon",void 0),b=e([i("esri.widgets.Editor.components.PendingFeatureList")],b);const F=b;export{F as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{substitute as e}from"../../../intl/substitute.js";import{
|
|
2
|
+
import{substitute as e}from"../../../intl/substitute.js";import{isNextOrLegacyCreateFeaturesWorkflow as t,isNextOrLegacySplitFeatureWorkflow as o,isNextOrLegacyMergeFeaturesWorkflow as i,isLegacyFeatureFormViewModel as n,isNextOrLegacyUpdateFeatureWorkflow as s,isNextOrLegacyUpdateFeaturesWorkflow as a}from"../compatibilityAdapters.js";import{css as l}from"../css.js";import{isBatchAttributeFormViewModel as r}from"../workflowUtils.js";import{loadFooterActionsComponents as c,FooterActions as u}from"./FooterActions.js";import p from"./MergeFeaturesList.js";import{loadNoticesComponents as m,Notices as d}from"./Notices.js";import{loadPanelContentComponents as f,PanelContentSection as g,PanelContentSectionGroup as k,PanelContent as b}from"./PanelContent.js";import w from"./PendingFeatureList.js";import{loadCalciteComponents as v}from"../../support/componentsUtils.js";import{Heading as h,incrementHeadingLevel as y}from"../../support/Heading.js";import{tsx as F,tsxFragment as j}from"../../support/widget.js";import{classes as A}from"../../support/widgetUtils.js";const C=()=>Promise.all([v({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),c(),m(),f()]);function M(e){const{editorViewModel:s,headingLevel:a,messages:c,renderAttachments:m,renderFeatureForm:f,formWidget:v,renderSketchToolbar:A}=e,{activeFeatureCount:C,activeLeafWorkflow:M,activeWorkflow:B,formViewModel:T}=s;if(!M||!B||!T)return null;const V=r(T),z=t(M)&&!M.data.selectedPendingFeature||o(M)&&!M.activeFeature,I=i(M),W=M.shouldShowAttachments&&!V&&!T.activeRelationshipInput&&!T.activeAssociationInput,x=V?T.activeForm.inputs:T.inputs,D=t(M)&&x.every(e=>!e.visible)&&!W,H=null!=s.featureFormViewModel?.activeAssociationInput,P=!z&&!D&&!H,U=D||t(M)&&!W&&!P&&!H,E=n(T)?f:v?.render.bind(v),N=D?F(g,null,F(w,{headingLevel:a,key:"pending-feature-list",workflow:M})):F(j,null,F(d,{activeFeatureCount:C,messages:c,workflow:B}),I?F(g,{class:l.mergeFeaturesListSection,key:"panel-section-merge"},F(p,{headingLevel:a,key:"merge-features-list",workflow:M})):void 0,F(g,{key:"panel-content-section-main"},F(k,null,z?F(w,{headingLevel:a,key:"pending-feature-list",workflow:M}):E?.(),W?F("div",{key:"attachments"},F(h,{level:y(a)},c.attachments),m()):null)));return F(j,null,P?L(M,e):void 0,U?A?.():void 0,F(b,{key:"attribute-panel-content"},N),F(u,{buttons:S(e)}))}function L(e,t){const o=[],i="3d"===t.editorViewModel.view?.type,{visibleElements:n}=t,r="s";if(n.zoomToButton&&t.editorViewModel.canZoomTo&&o.push(F("calcite-action",{alignment:"center",icon:"zoom-to-object",key:"zoom-to-button",scale:r,text:t.messages.zoomTo,title:t.messages.zoomTo,onclick:()=>t.editorViewModel.zoomTo()})),n.splitButton&&s(e)&&e.supportsSplitFeatureWorkflow&&!i&&t.onSplit){const{onSplit:e,messages:i}=t;o.push(F("calcite-action",{icon:"split-geometry",key:"split-button",scale:r,text:i.split,title:i.split,onclick:e}))}if(n.mergeButton&&a(e)&&e.supportsMergeFeaturesWorkflow&&!i&&t.onMerge){const{onMerge:e,messages:i}=t;o.push(F("calcite-action",{icon:"merge",key:"merge-button",scale:r,text:i.mergeFeatures,title:i.mergeFeatures,onclick:e}))}return o.length>0?F("calcite-action-bar",{class:A(l.sketchContainer,l.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal",scale:r},o):void 0}function S({editorViewModel:t,formWidget:o,messages:i,messagesCommon:s,onDelete:a,onDeleteAssociation:l,onSave:r}){const{activeFeatureCount:c,activeLeafWorkflow:u,syncing:p}=t;if(!u)return[];const{page:m}=t;if("viewing-associated-features"===m||"viewing-associated-layers"===m)return[{appearance:"outline",onClick:()=>{const e=u.formViewModel;n(e)?null!=e.associationId&&(e.associationId=null):e?.goBack()},disabled:p,label:s.cancel,type:"button"}];const d=t.formViewModel,f=o?.footerButtonInfos??[];if(d&&!n(d)&&"default"!==d.page)return f.map(({appearance:e,disabled:t,form:o,icon:i,kind:n,label:s,onclick:a})=>({appearance:e,disabled:t,form:o,icon:i,kind:n,label:s,onClick:a,type:"button"}));const g=[],k=c>1?i.multiFeature:i.singleFeature,b=!u.allowSave||p,w=e(k[u.saveActionLabel],{count:c});g.push({appearance:"solid",onClick:r,disabled:b,kind:"brand",label:w,type:"button"});const v={appearance:"outline",disabled:p,kind:"danger",label:e(k.delete,{count:c}),type:"button"};return t.shouldShowDeleteButton&&!t.formHasAssociation&&a&&g.push({...v,onClick:a}),t.formHasAssociation&&!t.shouldShowDeleteButton&&l&&g.push({...v,onClick:l,label:i.deleteAssociationTitle}),t.formHasAssociation&&t.shouldShowDeleteButton&&l&&a&&g.push({...v,primaryLabel:s.delete,primaryText:s.delete,onClick:a,dropdownItems:[{onClick:l,label:i.deleteAssociationTitle}],type:"split-button"}),g}export{M as UpdateFeaturePanelContent,C as loadUpdateFeaturePanelContentComponents};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../../core/handleUtils.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{watch as a}from"../../../core/reactiveUtils.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isSubtypeSublayer as n}from"../../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../../rest/featureService/utils.js";import c from"../../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../../views/support/HighlightDefaults.js";import{fetchFullFeatures as p}from"../workflowUtils.js";import w from"./AddAssociationWorkflowData.js";import h from"./Workflow.js";import y from"../../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as m}from"../../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";var A;const f={exit:Symbol()};let g=class extends h{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new y,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.consumePromise(this._setup(s))}get editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._addHandles()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const[e]=await p([o],o.sourceLayer,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const a=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer&&await e.sourceLayer.getFeatureTitle(e)||m(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:a},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(a){await this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:a}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,o.highlightHelper=this._highlightHelper,e.networkSystemLayers.loadAssociationsTable()}_addHandles(){const t=this._utilityNetworkAssociationAddAssociationViewModel;this.addHandles([a(()=>t.selectedLayer,t=>{t&&this.go("add-association-select-feature")}),a(()=>t.selectedFeature,t=>{t&&this.go("add-association-create-association")})],f.exit)}static async create(t){const e=new A({data:await w.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationsInput:a}=i,{utilityNetworkAssociationAddAssociationViewModel:r}=i.viewModel,{association:l}=r;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([l]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=n(u)&&u.parent?u.parent:u,w=d([p]),h=w.values().next().value?.featureService;if(!h)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(h?.load());const y=s?.gdbVersion??void 0;await t(h,[c],{gdbVersion:y}),await a.refresh()}}};t([r()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([r()],g.prototype,"_formViewModel",void 0),t([r()],g.prototype,"editorItem",null),t([r()],g.prototype,"formViewModel",null),t([r()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([r()],g.prototype,"sourceFeatureItem",void 0),t([r()],g.prototype,"hasPendingEdits",null),t([r()],g.prototype,"layer",null),t([r()],g.prototype,"parent",null),t([r()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([l("esri.widgets.Editor.legacy.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as t}from"tslib";import o from"../../../core/Accessor.js";import{property as e,subclass as i}from"../../../core/accessorSupport/decorators.js";import{findEditorItemForLayerOrThrow as r}from"../workflowUtils.js";var s;let a=s=class extends o{constructor(t){super(t),this.editorItem=null,this.feature=null,this.utilityNetwork=null,this.associationType=null,this.parent=null,this.associationsInput=null,this.viewModel=null}static async create(t){const{feature:o,parent:e,viewModel:i,utilityNetwork:a,associationType:n,associationsInput:p}=t,l=r(i.editorItems,o.sourceLayer);return new s({editorItem:l,feature:o,parent:e,viewModel:i,utilityNetwork:a,associationType:n,associationsInput:p})}};t([e({constructOnly:!0})],a.prototype,"editorItem",void 0),t([e()],a.prototype,"feature",void 0),t([e({constructOnly:!0})],a.prototype,"utilityNetwork",void 0),t([e({constructOnly:!0})],a.prototype,"associationType",void 0),t([e()],a.prototype,"parent",void 0),t([e()],a.prototype,"associationsInput",void 0),t([e()],a.prototype,"viewModel",void 0),a=s=t([i("esri.widgets.Editor.legacy.AddAssociationWorkflowData")],a);export{a as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import a from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../../core/handleUtils.js";import"../../../core/has.js";import o from"../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../../core/promiseUtils.js";import{watch as u,initial as p,sync as h,whenOnce as m,syncAndInitial as f}from"../../../core/reactiveUtils.js";import{generateBracedUUID as g}from"../../../core/uuid.js";import{property as w,subclass as y}from"../../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,getCreationAttributes as _,isStandardFeatureTemplate as b}from"../../../editing/templateUtils.js";import{getFullTemplate as M}from"../../../editing/sharedTemplates/templateLoader.js";import I from"../../../layers/GraphicsLayer.js";import{isSceneLayer as V,isTable as k}from"../../../layers/support/layerUtils.js";import{isNumber as S}from"../../../support/guards.js";import{getDisplayedSymbol as T}from"../../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as A}from"../../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as P}from"../../../views/draw/support/helpMessageUtils.js";import E from"../../../views/draw/support/HighlightHelper.js";import U from"../../../views/interactive/sketch/SketchOptions.js";import C from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as H}from"../../../views/support/HighlightDefaults.js";import{isModelUpload as L,handleModelUpload as j}from"../modelUploadUtils.js";import{activeSketchToolDrawsUnsupportedCurve as O,createToolFromGeometryType as x,containsUnsupportedCurve as D,findEditorItemForLayer as z,getServiceEditsFromWorkflowData as R,getServiceInfoForLayer as W,orderEditsByRelationshipDependencies as G,getServiceLayersById as N,startCreatingNewFeature as K,syncUpdateOptions as Z,findLayerInfo as q,isTerminalUpdateEventType as B,getVisualVariableAttributes as J,startUpdatingFeatureGeometry as Q,createWorkflowSteps as X,avoidFeatureTemplateSelectionWithOnlyOneItem as Y,setUpSketchCreateWatchers as $,setRelationshipFields as ee,showProgressCursor as te,setVisualVariablesAndElevationInfoForUpdate as ae,visualVariableInteractiveUpdate as ie}from"../workflowUtils.js";import re from"./CreateFeaturesWorkflowData.js";import se from"./Workflow.js";import{prepareAttachmentsForCreateFeaturesWorkflow as oe}from"./workflowUtils.js";import ne from"../../FeatureForm/FeatureFormViewModel.js";import le from"../../Sketch/SketchViewModel.js";var de;const ce=Symbol(),ue=Symbol(),pe=Symbol(),he=Symbol(),me={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let fe=de=class extends se{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ne,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!L(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,{drawTool:i,isUsingLegacyCreateTools:r}=a;if(!r)return i?.helpMessageKey??"noTool";const s=e.layer.geometryType,o=a.createGraphic;if("mesh"===s){this._getDrawMeshHelpMessage||import("../../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(o,e):void 0}const{activeCreateToolDrawMode:n,activeTool:l}=a;return P("rectangle"===l||"circle"===l?l:s,o?.geometry,n)}get noticeMessage(){if(O(this._sketchViewModel,this.data.editorItem))return"curveToolDensifyWarning"}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){const{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!V(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=x(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...me[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([pe])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),k(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){const{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;t.submit(),this._stashValidationState();const a=this.data.selectedPendingFeature,i=this._hasValidationErrors(a)?a:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(i)return await this._startUpdating({feature:i}),void t?.submit();const{pendingFeatures:r,editorItem:s}=this.data;if(s&&e&&D(r.toArray(),s)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||L(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||L(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new U,u=s?.layer,p=u?z(d.editorItems,u):void 0,h=new de({data:new re({creationInfo:s,editorItem:p,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;h._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=h._attachmentFileInfos,{fullTemplate:c}=e,u=R(h.data),p=F(c)&&u;if(n){if(ve(s),p){let t=_e(u,l);const a=await(W(o,d.view)?.load());a&&(t=G({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=Fe(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=p?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,ye(s,e.addFeatureResults,o,l))}))}});return h._set("steps",this._createWorkflowSteps(h,l)),h}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await M(a,t.template);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:N(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ue);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await K(this._sketchViewModel,this._sketchLayer,e)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:s,_sketchViewModel:o,sketchUpdateOptions:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:p,layerInfos:h,view:m}=c;if(!m||!d)return;Z(o,l),n(this._featureFormHandle);const f=e.sourceLayer,g=q(h,f),w=g?.formTemplate,y=m.spatialReference;s.set({editType:"INSERT",feature:e,formTemplate:w,spatialReference:y,map:m.map}),"add"!==p.mode&&"edit"!==p.mode||await(c.activeWorkflow?.previous()),p.graphic=e,p.fileInfos.removeAll(),p.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>p.addFile(e,t)),await A(e,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([s.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(s.getValues()),S(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await A(e,"2d"===m.type?m.scale:null)}),o.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&B(e.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()}),u(()=>s.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[s.feature,s.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return k(l)?void 0:(this._visualVariableAttributes=J(e),Q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=X(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(L(t)?e.addHandles(await j({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([pe,ce,ue,he]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return Y(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s}=e,{creationInfo:o,viewModel:n}=t,{view:l}=n,d=[];if(!l)return i();if("2d"===l.type){o&&d.push(e._fadeExistingFeatures(o.layer));const t=c((e,t)=>Promise.all(e.map(e=>A(e,t))));d.push(u(()=>l.scale,e=>t(a.graphics,e)))}const p=_(t.fullTemplate,o?.attributeOverrides,o?.layer),h=u(()=>s.createGraphic&&s.activeComponent,()=>{s.createGraphic&&s.activeComponent&&!e.hasHandles(ue)&&e._updatingHandles.consumePromise($({creationAttributes:p,data:t,sketchViewModel:s,view:l}).then(t=>e.addHandles(t,ue)))}),m=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ue),"cancel"===t.state&&null!==l.activeTool&&l.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===l.type?l.scale:null,useSourceLayer:!0});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},f=async i=>{const{attachmentsViewModel:r}=n,{_formViewModel:d}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const c=i.graphics[0];if("complete"===i.state){const{submittable:t}=d;if(e.numPendingFeatures!==o?.maxFeatures&&t||d.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(n.activeWorkflow?.previous()),null==e.data.selectedPendingFeature&&(null==l.activeTool||l.activeTool===e.sketchViewModel.activeComponent)&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return c.sourceLayer??=t.creationInfo?.layer,await ae({graphic:c,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,sourceLayer:c.sourceLayer}),e._selectFeatureForUpdate({feature:c});if("active"===i.state){await e.updatePendingFeature(c);const t=e._visualVariableAttributes;ie(l,c,i,t)&&await A(c,"2d"===l.type?l.scale:null);const a=c.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;d.setValue(e,a[e])}if(null!=s){const{field:e}=s;d.setValue(e,a[e])}}}},g=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!L(t.creationInfo))return e._startCreating()},w=async()=>{if(L(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(h,s.on("create",t=>e._updatingHandles.addPromise(m(t))),s.on("update",t=>e._updatingHandles.addPromise(f(t))),s.on("delete",t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(w())),i(()=>{s.cancel()}),ge(s,a,t),...we(t));const y=r(d);return s.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new I({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new le({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),l(a)}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p),u(()=>this.sketchUpdateOptions,e=>{r.defaultUpdateOptions=e,Z(r,e)},h)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,c=l(e.geometry,"completion"),u=d(c)?await c:c;n.completionResults.push(u),ee(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await T(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=q(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=q(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.updateAttributes(s.getValues()),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(pe))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],g=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=z(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),g.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,oe(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const w=te(c);f.push(w);const y=k(o.layer),{template:F}=o,M=!F||b(F)||v(F)&&"feature"===F.type,I=y&&M;try{if(I){const a=h??new t({attributes:_(e.fullTemplate,o.attributeOverrides,m),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(de._configureSketchViewModel(this)),h?(L(o)&&o.geometryToPlace&&(h.attributes=_(e.fullTemplate,o.attributeOverrides,m)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{w.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),S=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),T=i(()=>{L(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(g),T,V,S],pe)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),he),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function ge(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function we(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new E({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new E({view:t,highlightName:H});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function ye(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function ve(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=g())}}function Fe(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:g(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function _e(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:g(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([w()],fe.prototype,"allowSave",null),e([w()],fe.prototype,"createFeatureState",void 0),e([w()],fe.prototype,"curveResizeDisabled",null),e([w()],fe.prototype,"curveUpdatesDisabled",null),e([w()],fe.prototype,"data",void 0),e([w({constructOnly:!0})],fe.prototype,"isNested",void 0),e([w()],fe.prototype,"formViewModel",null),e([w()],fe.prototype,"hasInvalidFormTemplate",null),e([w()],fe.prototype,"hasPendingEdits",null),e([w()],fe.prototype,"hasPreviousStep",null),e([w()],fe.prototype,"_getDrawMeshHelpMessage",void 0),e([w()],fe.prototype,"helpMessage",null),e([w()],fe.prototype,"noticeMessage",null),e([w()],fe.prototype,"layer",null),e([w()],fe.prototype,"parent",null),e([w()],fe.prototype,"keyboardCancellationEnabled",null),e([w()],fe.prototype,"reliesOnOwnerAdminPrivileges",null),e([w()],fe.prototype,"saveActionLabel",null),e([w()],fe.prototype,"shouldShowAttachments",null),e([w()],fe.prototype,"shouldAllowAttachmentEditing",null),e([w()],fe.prototype,"sketchUpdateOptions",null),e([w()],fe.prototype,"sketchViewModel",null),e([w()],fe.prototype,"availableCreateTools",null),e([w()],fe.prototype,"_attachmentsActive",null),fe=de=e([y("esri.widgets.Editor.legacy.CreateFeaturesWorkflow")],fe);const be=fe;export{be as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import i from"../../../core/Collection.js";import r from"../../../core/Logger.js";import s from"../../../core/ReactiveMap.js";import{property as o,subclass as n}from"../../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as a}from"../../../editing/templateUtils.js";import{hasCircularArc as l,isCurvedGeometry as p}from"../../../geometry/support/curves/curveUtils.js";import u from"../Edits.js";const d=()=>r.getLogger("esri.widgets.Editor.CreateFeaturesWorkflowData");let g=class extends t{constructor(e){super(e),this.creationInfo=null,this.editorItem=null,this.fullTemplate=null,this.parent=null,this.temporaryHighlightFeature=null,this.sketchOptions=null,this.snappingManager=null,this.templateExecutorInfo=null,this.viewModel=null,this.upload=null,this._pendingEdits=new s}get attachmentsModified(){return[...this._pendingEdits.values()].some(e=>e.attachmentsModified)}get curveResizeDisabled(){return this.hasCurves&&l(this.selectedPendingFeature?.geometry)&&!this.editorItem?.supportedCurveTypes.includes("elliptic-arc")}get curveUpdatesDisabled(){return this.hasCurves&&!1===this.editorItem?.capabilities.supportsTrueCurveUpdate}get hasCurves(){const e=this.selectedPendingFeature;return!(!e?.geometry||!p(e.geometry))}get isSharedTemplateWorkflow(){return!!this.fullTemplate&&a(this.fullTemplate)}get pendingFeatures(){return new i([...this._pendingEdits.keys()])}set selectedPendingFeature(e){this._set("selectedPendingFeature",e),this.temporaryHighlightFeature=null}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach(t=>{t.timeZone=e})}isSubmittable(e){const t=this._pendingEdits.get(e);return!!t?.submittable||!!t?.isAssociation}isDisplayable(e){return!this._pendingEdits.get(e)?.isAssociation}addPendingFeature(e,t=e,i={isAssociation:!1}){this.temporaryHighlightFeature=null;const{_pendingEdits:r}=this;if(r.has(e))return r.get(e);e.sourceLayer||d().warn("source-layer-not-set","A feature added to `pendingFeatures` did not have `sourceLayer` set. This may cause problems throughout `CreateFeaturesWorkflow`.");const s=new u({feature:e,isAssociation:i.isAssociation});return s.trackChanges(t),r.set(e,s),s}getEditsForPendingFeature(e){return this._pendingEdits.get(e)}removePendingFeature(e){this.temporaryHighlightFeature=null;const{_pendingEdits:t}=this,i=t.get(e);i&&(i.destroy(),t.delete(e)),this.selectedPendingFeature===e&&(this.selectedPendingFeature=null)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}};e([o()],g.prototype,"attachmentsModified",null),e([o()],g.prototype,"creationInfo",void 0),e([o()],g.prototype,"curveResizeDisabled",null),e([o()],g.prototype,"curveUpdatesDisabled",null),e([o()],g.prototype,"editorItem",void 0),e([o()],g.prototype,"fullTemplate",void 0),e([o()],g.prototype,"hasCurves",null),e([o()],g.prototype,"isSharedTemplateWorkflow",null),e([o()],g.prototype,"parent",void 0),e([o()],g.prototype,"pendingFeatures",null),e([o()],g.prototype,"selectedPendingFeature",null),e([o()],g.prototype,"temporaryHighlightFeature",void 0),e([o({constructOnly:!0})],g.prototype,"sketchOptions",void 0),e([o()],g.prototype,"snappingManager",void 0),e([o()],g.prototype,"templateExecutorInfo",void 0),e([o()],g.prototype,"viewModel",void 0),e([o()],g.prototype,"upload",void 0),e([o()],g.prototype,"timeZone",null),g=e([n("esri.widgets.Editor.legacy.CreateFeaturesWorkflowData")],g);const h=g;export{h as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{on as s,whenOnce as n,watch as l,initial as d}from"../../../core/reactiveUtils.js";import{property as h,subclass as m}from"../../../core/accessorSupport/decorators.js";import u from"../../../layers/GraphicsLayer.js";import{updateGraphicSymbolWhenRequired as p}from"../../../views/draw/support/editingSessionUtils.js";import c from"../../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as w}from"../../../views/support/HighlightDefaults.js";import f from"../Edits.js";import{makeMinimalAttributes as g}from"../workflowUtils.js";import y from"./MergeFeaturesWorkflowData.js";import F from"./Workflow.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as V}from"../support/errors.js";import{mergeFeatures as j}from"../support/mergeFeaturesUtils.js";import H from"../../FeatureForm/FeatureFormViewModel.js";var I;const b=Symbol();let A=I=class extends F{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get hasPendingEdits(){return!1}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get shouldShowAttachments(){return this.data.editorItem.capabilities.attachments.enabled}static async create(e){const{applyEdits:t,applyEditsFeatureService:i,...r}=e,{editorItem:a,features:o}=r;if(v(r.viewModel,"merge-features"),_(a),M(o,2),k(o),r.keyFeature&&!o.includes(r.keyFeature))throw new V;const s=await j(o),n=new I({data:new y({...r,mergedGeometry:s}),onCommit:L(t)});return n._set("steps",S()),n}async enter(){this._configureAttachmentsViewModel()}exit(){}isKeyFeature(e){return this.data.keyFeature===e}isTemporaryHighlightFeature(e){return this.data.temporaryHighlightFeature===e}async setKeyFeature(e){const{data:t}=this;if(e!==t.keyFeature){if(!t.features.includes(e))throw new V;t.keyFeature=e,await this._createAndInitializeEdits(e)}}async start(){return await super.start(),this._makeSketchController()}getFeatureTitle(e){return this.data.getFeatureTitle(e)}async _createAndInitializeEdits(e){const{data:t}=this,i=e.clone();i.geometry=t.mergedGeometry;const r=new f({feature:i});t.edits=r;const a=t.getInitialFeature(e)||e;r.trackChanges(a),await this._setFeatureOnFormViewModel(i,a),this._setFeatureOnAttachmentsViewModel(e)}_initializeFeatureFormViewModel(){const{data:e}=this,t=e.viewModel.view,i=new H({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:t?.map,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(s(()=>i,"value-change",({feature:i,fieldName:r,value:a})=>{const o=e.edits;i&&o&&(o.setAttribute(r,a),p(i,t?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=i,t?.map.add(i)}_makeSketchController(){return{enter:async()=>{this.addHandles(z(this.data),b)},exit:()=>{this.removeHandles(b)}}}async _setFeatureOnFormViewModel(e,t){const i=this._formViewModel;i.feature=e,i.overrideInitialFeature(t),await n(()=>!i.updating)}_configureAttachmentsViewModel(){const{data:e}=this,{keyFeature:t,viewModel:i}=e,{attachmentsViewModel:r}=i;r.set({capabilities:{editing:!1},graphic:t,filesEnabled:!1,mode:"view"})}_setFeatureOnAttachmentsViewModel(e){this.data.viewModel.attachmentsViewModel.graphic=e}};e([h()],A.prototype,"formViewModel",null),e([h()],A.prototype,"hasPendingEdits",null),e([h()],A.prototype,"layer",null),e([h()],A.prototype,"parent",null),e([h()],A.prototype,"shouldShowAttachments",null),e([h()],A.prototype,"type",void 0),e([h()],A.prototype,"_formViewModel",void 0),e([h()],A.prototype,"_graphicsLayer",void 0),e([h()],A.prototype,"_highlightHelper",void 0),A=I=e([m("esri.widgets.Editor.legacy.MergeFeaturesWorkflow")],A);const E=A;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function L(e){return async i=>{const{edits:r,keyFeature:a}=i,o=r?.feature?.cloneShallow(),s=i.editorItem.layer;if(!r||!o)throw new t("editing:missing-feature","Workflow data has no edits to submit.");r.attributesModified||(o.attributes=g(o,i.editorItem.layer));const n=[];for(const e of i.features){if(e===a)continue;const t=e.cloneShallow();t.attributes=g(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[o],deleteFeatures:n})}}function z(e){const t=e.viewModel.view;if(!t)return i();const o=new c({view:t});for(const i of e.features)o.add(i);const s=new c({view:t,highlightName:w}),n=l(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new c({view:t,highlightName:w}),m=l(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return r([a(o),n,a(s),m,a(h)])}export{E as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import i from"../../../core/ReactiveMap.js";import{property as r,subclass as o}from"../../../core/accessorSupport/decorators.js";let a=class extends t{constructor(e){super(e),this._featureTitleMap=null,this.editorItem=null,this.features=[],this.initialFeatures=[],this.keyFeature=null,this.edits=null,this.mergedGeometry=null,this.parent=null,this.temporaryHighlightFeature=null,this.viewModel=null}async initialize(){const{features:e,timeZone:t}=this,{layer:r}=this.editorItem;if(this.keyFeature??=e[0],0===this.initialFeatures.length&&(this.initialFeatures=e.slice()),!("getFeatureTitle"in r))return;const o=await Promise.all(e.map(async e=>[e,await r.getFeatureTitle(e,{fetchMissingFields:!1,timeZone:t})]));this._featureTitleMap=new i(o)}get _initialFeatureMap(){const e=new Map(this.initialFeatures.map(e=>[e.getObjectId(),e])),t=new Map(this.features.map(e=>[e.getObjectId(),e])),i=new Map;for(const[r,o]of t){const t=e.get(r);r&&t&&i.set(o,t)}return i}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(e){null==e?this._clearOverride("timeZone"):this._override("timeZone",e)}getFeatureTitle(e){return this._featureTitleMap?.get(e)}getInitialFeature(e){return this._initialFeatureMap.get(e)}};e([r()],a.prototype,"_featureTitleMap",void 0),e([r()],a.prototype,"_initialFeatureMap",null),e([r({constructOnly:!0})],a.prototype,"editorItem",void 0),e([r({constructOnly:!0})],a.prototype,"features",void 0),e([r()],a.prototype,"initialFeatures",void 0),e([r()],a.prototype,"keyFeature",void 0),e([r()],a.prototype,"edits",void 0),e([r()],a.prototype,"mergedGeometry",void 0),e([r()],a.prototype,"parent",void 0),e([r()],a.prototype,"temporaryHighlightFeature",void 0),e([r()],a.prototype,"timeZone",null),e([r()],a.prototype,"viewModel",void 0),a=e([o("esri.widgets.Editor.legacy.MergeFeaturesWorkflowData")],a);const s=a;export{s as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../../core/handleUtils.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{debounce as s}from"../../../core/promiseUtils.js";import{watch as n,on as l,whenOnce as p,initial as d}from"../../../core/reactiveUtils.js";import{property as u,subclass as c}from"../../../core/accessorSupport/decorators.js";import h from"../../../layers/GraphicsLayer.js";import{swapForEditingSession as m,updateGraphicSymbolWhenRequired as y}from"../../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as w}from"../../../views/draw/support/helpMessageUtils.js";import g from"../../../views/draw/support/HighlightHelper.js";import f from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as v}from"../../../views/support/HighlightDefaults.js";import _ from"../Edits.js";import{activeSketchToolDrawsUnsupportedCurve as F,containsUnsupportedCurve as M,createWorkflowSteps as S,makeMinimalAttributes as b}from"../workflowUtils.js";import k from"./SplitFeatureWorkflowData.js";import T from"./Workflow.js";import{assertViewNot3D as I,assertSplitWorkflowCapabilities as V}from"../support/errors.js";import{getCompatibleSpitterGeometryType as E,ensureSplittableGeometry as G,makeNewFeatureAttributes as H,splitGeometry as j,canSplitByPoint as x,isSplitterGeometry as C}from"../support/splitFeatureUtils.js";import U from"../../FeatureForm/FeatureFormViewModel.js";import L from"../../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as W}from"../../Sketch/support/sketchUtils.js";var O;const P=Symbol(),z=Symbol();let A=O=class extends T{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new g({view:e,highlightName:v}):null,this._initializeFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i,drawTool:r,isUsingLegacyCreateTools:a}=this._sketchViewModel;if(!a)return r?.helpMessageKey??"noTool";const o=W(t);return"mesh"!==o?w(o,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get sketchUpdateOptions(){return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1}}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}get noticeMessage(){return this._splittingMayIntroduceCurves&&F(this._sketchViewModel,this.data.editorItem)?"curveToolDensifyWarning":this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}get _splittingMayIntroduceCurves(){return"polygon"===this.data.editorItem.layer.geometryType}async back(e){if(this.activeFeature)return await this.setActiveFeature(null);await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(I(e.viewModel,"split-feature"),V(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=E(G(s.feature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.feature.geometry?.type}'.`)}const n=new O({data:new k(s),defaultSplitterGeometryType:a,onCommit:R(e.applyEdits)});return n._set("steps",O._createWorkflowSteps(n,o)),n}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async commit(e){const{newFeatureEdits:t,existingFeatureEdits:i,editorItem:r}=this.data,a=[i?.feature,t?.feature].filter(e=>!!e);if(e&&M(a,r)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.commit()}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.feature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new _({feature:o});i.existingFeatureEdits=s,s.trackChanges(i.initialFeature),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const n=r.clone();n.geometry=e,n.attributes=H(r.attributes,i.editorItem.layer);const l=new _({feature:n});return i.newFeatureEdits=l,l.trackChanges(),await this._setFeatureOnFormViewModel(n,"new"),l.submittable=a.submittable,{featureToCreate:n,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return S(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.feature.geometry),a=E(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;x(i)&&o&&e.addHandles(N(o,e.layer));const s=e._sketchViewModel;e.addHandles([l(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!C(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),n(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(P)&&o?e.addHandles(Z(o,e.layer),P):"point"===i&&e.removeHandles(P)})],this.id),await s.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),n=await e._displayFeatureGraphics(s,o);e.addHandles(n,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,l=a.viewModel.view,p=[];if(!e||!t||!l)return i();const d=s(i=>Promise.all([y(e,i),y(t,i)]));return await d("2d"===l.type?l.scale:null),"2d"===l.type&&p.push(n(()=>l.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await m(o,l,a.feature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{feature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await j(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,i=new U({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:t?.map,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(l(()=>i,"value-change",({feature:i,fieldName:r,value:a})=>{i&&(e.getEditsForFeature(i)?.setAttribute(r,a),y(i,t?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new L({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,useLegacyCreateTools:t.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:i})}_makeSketchController(){return{enter:async()=>this.addHandles($(this)),exit:()=>this.removeHandles(z),viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.initialFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],A.prototype,"activeFeature",null),e([u()],A.prototype,"allowSave",null),e([u()],A.prototype,"availableCreateTools",null),e([u()],A.prototype,"defaultSplitterGeometryType",void 0),e([u()],A.prototype,"formViewModel",null),e([u()],A.prototype,"hasInvalidFormTemplate",null),e([u()],A.prototype,"hasPreviousStep",null),e([u()],A.prototype,"helpMessage",null),e([u()],A.prototype,"layer",null),e([u()],A.prototype,"parent",null),e([u()],A.prototype,"sketchUpdateOptions",null),e([u()],A.prototype,"type",void 0),e([u()],A.prototype,"updating",null),e([u()],A.prototype,"noticeMessage",null),e([u()],A.prototype,"_activeFeature",void 0),e([u()],A.prototype,"_formViewModel",void 0),e([u()],A.prototype,"_graphicsLayer",void 0),e([u()],A.prototype,"_highlightHelper",void 0),e([u()],A.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],A.prototype,"_sketchViewModel",void 0),e([u()],A.prototype,"_splittingMayIntroduceCurves",null),A=O=e([c("esri.widgets.Editor.legacy.SplitFeatureWorkflow")],A);const D=A;function R(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),n=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=b(o,i.editorItem.layer)),await e(n,{addFeatures:[s],updateFeatures:[o]})}}function N(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new f({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function Z(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const n=new Map;for(const i of r.featureSources)n.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of n)e.enabled=t})}function $(e){const t=e.data,{feature:o,viewModel:s}=t,{view:l}=s;if(!l)return i();const p=new g({view:l}),u=n(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new g({view:l,highlightName:v}),h=n(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=n(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}export{D as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{property as i,subclass as r}from"../../../core/accessorSupport/decorators.js";import o from"../../../views/interactive/sketch/SketchOptions.js";let s=class extends e{constructor(t){super(t),this.editorItem=null,this.newFeatureEdits=null,this.existingFeatureEdits=null,this.feature=null,this.initialFeature=null,this.sketchOptions=new o,this.snappingManager=null,this.splitResult=null,this.splitterGeometry=null,this.temporaryHighlightFeature=null,this.viewModel=null}initialize(){this.initialFeature||(this.initialFeature=this.feature)}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(t){null==t?this._clearOverride("timeZone"):this._override("timeZone",t)}getEditsForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:i}=this;return e?.feature===t?e:i?.feature===t?i:null}getRoleForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:i}=this;return e?.feature===t?"existing":i?.feature===t?"new":null}};t([i({constructOnly:!0})],s.prototype,"editorItem",void 0),t([i()],s.prototype,"newFeatureEdits",void 0),t([i()],s.prototype,"existingFeatureEdits",void 0),t([i()],s.prototype,"feature",void 0),t([i()],s.prototype,"initialFeature",void 0),t([i()],s.prototype,"parent",void 0),t([i({constructOnly:!0})],s.prototype,"sketchOptions",void 0),t([i()],s.prototype,"snappingManager",void 0),t([i()],s.prototype,"splitResult",void 0),t([i()],s.prototype,"splitterGeometry",void 0),t([i()],s.prototype,"temporaryHighlightFeature",void 0),t([i()],s.prototype,"timeZone",null),t([i()],s.prototype,"viewModel",void 0),s=t([r("esri.widgets.Editor.legacy.SplitFeatureWorkflowData")],s);const n=s;export{n as default};
|