@arcgis/core 5.0.0-next.13 → 5.0.0-next.15
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/PopupTemplate.js +1 -1
- package/applications/Components/QuantityFormatter.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{5299ec59c86022ca37e2.js → 080268f78436a2f0d996.js} +1 -1
- package/assets/esri/core/workers/chunks/{a6ee40dfc471d6612f3c.js → 1585298168c200d65c2f.js} +1 -1
- package/assets/esri/core/workers/chunks/{34bb4852ebef0f529c96.js → 1a98e35837c6279fd8ee.js} +1 -1
- package/assets/esri/core/workers/chunks/5608e1eeec887295dc7c.js +1 -0
- package/assets/esri/core/workers/chunks/57262321c51096ef885f.js +1 -0
- package/assets/esri/core/workers/chunks/58d891779f04b6d12fc0.js +1 -0
- package/assets/esri/core/workers/chunks/{7c14f99e6cfff2a8ef4a.js → 5a7bb13ccb9188f90dfd.js} +1 -1
- package/assets/esri/core/workers/chunks/607beb12592f99871bf9.js +1 -0
- package/assets/esri/core/workers/chunks/{8be16b03caa947ac7631.js → 79326e3ebd5081046f79.js} +1 -1
- package/assets/esri/core/workers/chunks/7c08c0824ad354177787.js +1 -0
- package/assets/esri/core/workers/chunks/{54c49a768147720c3c56.js → 8208dfa8f7fae7e616b9.js} +1 -1
- package/assets/esri/core/workers/chunks/{d7755c4c8d1d3059efca.js → 847f4fc39100fac1df01.js} +1 -1
- package/assets/esri/core/workers/chunks/8b73db0f4d6714396eb0.js +1 -0
- package/assets/esri/core/workers/chunks/{9cdd087c43a601ec331d.js → 9a7f7de06dbc37661ffb.js} +1 -1
- package/assets/esri/core/workers/chunks/{55adbd7481f8dfb1067e.js → a174c9f6bc687349e563.js} +1 -1
- package/assets/esri/core/workers/chunks/{38fa50336983265c73a4.js → bc318b6fef192cee2a72.js} +1 -1
- package/assets/esri/core/workers/chunks/{57806a01f33074b601e7.js → cdb4664fd59860ddeb5a.js} +1 -1
- package/assets/esri/core/workers/chunks/d98203c932a60f9f809d.js +1 -0
- package/assets/esri/core/workers/chunks/{5e08b19e6d7202ea38d7.js → db900e8949cc75e72b18.js} +1 -1
- package/assets/esri/core/workers/chunks/de831a9cb542a09db5c3.js +1 -0
- package/assets/esri/core/workers/chunks/{2166238a7ad63a2d43c7.js → e05ce6f91ca59e34da7c.js} +1 -1
- package/assets/esri/core/workers/chunks/{f28ffda9a95c6568503d.js → e07dda45281439e6582e.js} +1 -1
- package/assets/esri/core/workers/chunks/{d888ae5ac1810a486919.js → ff8752dbcb014ea66806.js} +1 -1
- package/chunks/GaussianSplat.glsl.js +2 -2
- package/config.js +1 -1
- package/copyright.txt +0 -60
- package/core/SetUtils.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/identity/IdentityModal.js +1 -1
- package/interfaces.d.ts +105 -9
- package/intl.js +1 -1
- package/kernel.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/NumberFieldFormat.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterFunctionUtils.js +1 -1
- package/package.json +1 -1
- package/popup/content.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/renderers/support/numberUtils.js +1 -1
- package/rest/geometryService.js +1 -1
- package/rest/geoprocessor.js +1 -1
- package/rest/imageService.js +1 -1
- package/rest/locator.js +1 -1
- package/rest/query.js +1 -1
- package/smartMapping/labels/bins.js +1 -1
- package/smartMapping/popup/support/clusterUtils.js +1 -1
- package/smartMapping/popup/support/utils.js +1 -1
- package/smartMapping/renderers/support/utils.js +1 -1
- package/support/BasemapStyle.js +1 -1
- package/support/actions/actionUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/svgUtils.js +1 -1
- package/tables/elements.js +1 -1
- package/views/2d/layers/features/FeatureSourceEventLog.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/graphics/GraphicStore.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PiUtils.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/FastApproximateTrigonometry.glsl.js +26 -0
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
- package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
- package/views/interactive/tooltip/components/TooltipField.js +1 -1
- package/views/interactive/tooltip/components/ValueByValue.js +1 -1
- package/views/interactive/tooltip/content/Fields.js +1 -1
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawCircle.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawMesh.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawRectangle.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentElevation.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentExtentRotate.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentExtentScale.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentMovePoint.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentReshapeEdgeOffset.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentSelectedVertex.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTransformMesh.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTransformPoint.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslate.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateXY.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateZ.js +1 -1
- package/views/navigation/gamepad/GamepadSettings.js +1 -1
- package/views/overlay/BoxOverlayItem.js +1 -1
- package/views/overlay/CrosshairOverlayItem.js +1 -1
- package/views/overlay/OutlineOverlayItem.js +1 -1
- package/views/ui/UI.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/AreaMeasurement2D.js +1 -1
- package/widgets/AreaMeasurement3D.js +1 -1
- package/widgets/Attachments.js +1 -1
- package/widgets/Attribution.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/BasemapToggle.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/InputBase.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesNode.js +1 -1
- package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
- package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
- package/widgets/BuildingExplorer/BuildingLevelPicker/Label.js +1 -1
- package/widgets/BuildingExplorer/BuildingLevelPicker/LevelItem.js +1 -1
- package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
- package/widgets/BuildingExplorer.js +1 -1
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/Compass.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
- package/widgets/Daylight.js +1 -1
- package/widgets/DirectLineMeasurement3D.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/DistanceMeasurement2D.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflowData.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/Workflow.js +1 -1
- package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
- package/widgets/Editor/components/FeatureList.js +1 -1
- package/widgets/Editor/components/FooterActions.js +1 -1
- package/widgets/Editor/components/MergeFeaturesList.js +1 -1
- package/widgets/Editor/components/Notices.js +1 -1
- package/widgets/Editor/components/PanelContent.js +1 -1
- package/widgets/Editor/components/PanelToolbar.js +1 -1
- package/widgets/Editor/components/PendingFeatureList.js +1 -1
- package/widgets/Editor/components/Prompt.js +1 -1
- package/widgets/Editor/components/Settings.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/components/UploadDetails.js +1 -1
- package/widgets/Editor/components/workflowAdapters/pendingFeatureList/SplitFeatureWorkflowPendingFeatureListAdapter.js +1 -1
- package/widgets/Editor/support/errors.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/components/Legend.js +1 -1
- package/widgets/ElevationProfile/components/LegendItem.js +1 -1
- package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
- package/widgets/ElevationProfile/components/Statistics.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/Feature/FeatureAttachments.js +1 -1
- package/widgets/Feature/FeatureContent.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression.js +1 -1
- package/widgets/Feature/FeatureFields.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/Feature/FeatureRelationship.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
- package/widgets/Feature/support/FeatureContentMixin.js +1 -1
- package/widgets/Feature/support/FeatureElementInfo.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/AssociationDetails.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/Features/FeaturesDrillIn.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/FloorFilter.js +1 -1
- package/widgets/FovOverlay.js +1 -1
- package/widgets/Fullscreen.js +1 -1
- package/widgets/Histogram.js +1 -1
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/Home.js +1 -1
- package/widgets/LayerList/LayerListItem.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/styles/card/CardView.js +1 -1
- package/widgets/Legend/styles/card/ColorRamp.js +1 -1
- package/widgets/Legend/styles/card/LegendElement.js +1 -1
- package/widgets/Legend/styles/card/SizeRamp.js +1 -1
- package/widgets/Legend/styles/card/UnivariateAboveAndBelowRamp.js +1 -1
- package/widgets/Legend/styles/card/UnivariateColorSizeRamp.js +1 -1
- package/widgets/Legend/styles/classic/ClassicView.js +1 -1
- package/widgets/Legend/styles/classic/ColorRamp.js +1 -1
- package/widgets/Legend/styles/classic/LegendElement.js +1 -1
- package/widgets/Legend/styles/classic/SizeRamp.js +1 -1
- package/widgets/Legend/styles/classic/UnivariateAboveAndBelowRamp.js +1 -1
- package/widgets/Legend/styles/classic/UnivariateColorSizeRamp.js +1 -1
- package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
- package/widgets/Legend/styles/support/sizeRampUtils.js +1 -1
- package/widgets/Legend/styles/support/univariateUtils.js +1 -1
- package/widgets/Legend/styles/support/utils.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/Legend/support/styleUtils.js +1 -1
- package/widgets/Legend/support/utils.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/LineOfSight.js +1 -1
- package/widgets/Locate/LocateViewModel.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/Measurement.js +1 -1
- package/widgets/NavigationToggle.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/Alert.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
- package/widgets/OrientedImageryViewer/components/NavigationActions.js +1 -1
- package/widgets/OrientedImageryViewer/components/NavigationSettings.js +1 -1
- package/widgets/OrientedImageryViewer/components/NavigationUI360.js +1 -1
- package/widgets/OrientedImageryViewer/components/SequentialNavigationUI.js +1 -1
- package/widgets/OrientedImageryViewer/components/SketchTools.js +1 -1
- package/widgets/OrientedImageryViewer/components/VideoEnhancementTools.js +1 -1
- package/widgets/OrientedImageryViewer/mixins/ImageMeasurementMixin.js +1 -1
- package/widgets/OrientedImageryViewer/mixins/TriangulatedImageMeasurementMixin.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/PanoramicVideoViewer.js +1 -1
- package/widgets/PanoramicViewer.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/Print/FileLink.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ScaleBar.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search/SearchResultRenderer.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/ShadowCast/components/DiscreteConfigurator.js +1 -1
- package/widgets/ShadowCast/components/DurationConfigurator.js +1 -1
- package/widgets/ShadowCast/components/ShadowTooltipContent.js +1 -1
- package/widgets/ShadowCast/components/ThresholdConfigurator.js +1 -1
- package/widgets/ShadowCast.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/MeasuredContentGroup.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/Slice.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/Spinner.js +1 -1
- package/widgets/Swipe.js +1 -1
- package/widgets/TableList/ListItemPanel.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/widgets/Track.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeaturesDrillIn.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.js +1 -1
- package/widgets/ValuePicker/ValuePickerCollection.js +1 -1
- package/widgets/ValuePicker/ValuePickerCombobox.js +1 -1
- package/widgets/ValuePicker/ValuePickerLabel.js +1 -1
- package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
- package/widgets/ValuePicker.js +1 -1
- package/widgets/VideoPlayer/components/MetadataSection.js +1 -1
- package/widgets/VideoPlayer/components/PlayerActionsGroup.js +1 -1
- package/widgets/VideoPlayer/components/PlayerControlsGroup.js +1 -1
- package/widgets/VideoPlayer/components/SettingsButton.js +1 -1
- package/widgets/VideoPlayer.js +1 -1
- package/widgets/Weather/LabeledSlider.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/Zoom.js +1 -1
- package/widgets/smartMapping/BinaryColorSizeSlider.js +1 -1
- package/widgets/smartMapping/ClassedColorSlider.js +1 -1
- package/widgets/smartMapping/ClassedSizeSlider.js +1 -1
- package/widgets/smartMapping/ColorSizeSlider.js +1 -1
- package/widgets/smartMapping/ColorSlider.js +1 -1
- package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
- package/widgets/smartMapping/HeatmapSlider.js +1 -1
- package/widgets/smartMapping/OpacitySlider.js +1 -1
- package/widgets/smartMapping/SizeSlider.js +1 -1
- package/widgets/smartMapping/SmartMappingSliderBase.js +1 -1
- package/widgets/support/ColorPicker.js +1 -1
- package/widgets/support/FilterBuilder.js +1 -1
- package/widgets/support/FilterCondition.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/widgets/support/Heading.js +1 -1
- package/widgets/support/ItemList.js +1 -1
- package/widgets/support/LabeledSwitch.js +1 -1
- package/widgets/support/MeasurementWidgetContent.js +1 -1
- package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
- package/widgets/support/SelectionList/LayerItem.js +1 -1
- package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
- package/widgets/support/SelectionList/selectionListUtils.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/widgets/support/SketchTooltipControls.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/TimezonePicker.js +1 -1
- package/widgets/support/UnitSelect.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/utils/formatPercentAlong.js +1 -1
- package/widgets/support/chartUtilsAm5.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/widgets/support/iconUtils.js +1 -1
- package/widgets/support/widget.js +1 -1
- package/assets/esri/core/workers/chunks/3edffdb0e282ed562ac7.js +0 -1
- package/assets/esri/core/workers/chunks/8fc82fe1fcbcedf35400.js +0 -1
- package/assets/esri/core/workers/chunks/af5fc5d6c1d072a27df1.js +0 -1
- package/assets/esri/core/workers/chunks/bc29c29bfa5be3ebafb1.js +0 -1
- package/assets/esri/core/workers/chunks/c4dfd897bcab20dee43b.js +0 -1
- package/assets/esri/core/workers/chunks/c68935ed44eb0702a6ba.js +0 -1
- package/assets/esri/core/workers/chunks/db54552def7bc6cef9bd.js +0 -1
- package/assets/esri/core/workers/chunks/fd88e07cba5964f80e9e.js +0 -1
- package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +0 -5
- package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +0 -5
- package/widgets/support/jsxFactory.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import a 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,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W}from"../../core/accessorSupport/decorators/property.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import{getGraphicLayer as T}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as I}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,isSubtypeGroupLayer as S,getOwningPortalUrl as A}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import U from"../../views/SelectionManager.js";import C from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import j from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as R}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import H from"./CreateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as x,isCreateFeaturesWorkflow as G,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isMergeFeaturesWorkflow as N,isSplitFeatureWorkflow as Q,isUpdateWorkflow as z,isFeatureFormViewModel as Z,findEditorItemForLayerOrThrow as $,toFeatureInfos as J,fetchFullFeaturesByObjectId as K,fetchFullFeatures as X,findEditorItemForLayer as Y,whenEditorLayerView as ee}from"./workflowUtils.js";import te from"./support/EditorItem.js";import{MultipleSourceLayersError as ie,InsufficientFeatureCountError as re,MissingOriginLayerError as oe,assertMergeWorkflowCapabilities as ae,FetchFullFeatureError as se,assertSplitWorkflowCapabilities as ne}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as le}from"../FeatureTemplates/featureTemplatesUtils.js";import ce from"../FeatureTemplates/FeatureTemplatesViewModel.js";import de from"../Sketch/SketchViewModel.js";import pe from"../Spinner/SpinnerViewModel.js";import{goTo as he}from"../support/goToUtils.js";import{isFeatureItem as ue,isLayerItem as we}from"../support/SelectionList/selectionListUtils.js";import fe from"../support/SelectionList/SelectionListViewModel.js";import me from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ye(e,t){return e?.find(e=>e.layer===t)}let ge=class extends s{constructor(e){super(e),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 b,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new ce({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new de({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new fe,this.selectionManager=new U,this.selectionToolbarViewModel=new me({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new C,this.snappingOptions=new j({attributeRulesEnabled:!0}),this.spinnerViewModel=new pe,this.pageStack=[],this.showDiscardEditsPrompt=()=>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.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:r}=i.data;r.removeAll(),e&&r.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter(e=>!!t?.includes(e.layer));return[t,r,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>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},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>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 r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);await this.startCreateFeaturesWorkflowAtFeatureCreation(r)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=x(t),r=`sketch-${e.type}`;this.emit(r,{type:r,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 O({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>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:r})=>{t.view=e,i.view=e,r.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}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.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;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 r;for(const t of this.editorItems)R(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return G(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.fullFeatures.length:N(e)?e.data.features.length:Q(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(){return this.selectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return Z(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 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(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&Z(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 featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}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 a("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(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?$(this.editorItems,i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating);const i=Array.isArray(e)?J(e):[e];if(i.length>1)throw new ie;if(0===i.length||i[0].objectIds.length<2)throw new re(2);const o=i[0],a=o.layer;if(!a)throw new oe;const s=$(this.editorItems,a);ae(s);const l=this._createUpdatingResolver(),c=new AbortController;this.addHandles(n(c));try{await this._cancelWorkflow(),this.selectionToolbarViewModel.cancel();const e=await K(o.objectIds,a,this.view?.spatialReference,c.signal);if(e.length!==o.objectIds.length)throw new se;let i;if(t.keyFeature){const r=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===r)??t.keyFeature}const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(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);const i=T(e);if(!i)throw new oe;const o=$(this.editorItems,i);ne(o);const a=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow();const o=await X([e],i,this.view?.spatialReference,s.signal);if(1!==o.length)throw new se;const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(o),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{a.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)?J(e):[e];if(t.length>1)throw new ie;const i=this._createUpdatingResolver();try{await this._cancelWorkflow();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(r){this._logErrorAndCancelWorkflow(r)}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.selectionToolbarViewModel.cancel();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r([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 a("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new a("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(){o(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===Y(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:r}=this;if(!i)return;const o=void 0,a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?he(i,a.geometry,o):he(i,a,o);else{const e=r?.updateGraphics?.toArray();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?he(i,e.map(e=>e.geometry).filter(t),o):e&&he(i,e,o)}}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){ue(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){ue(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):we(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,r=i.editableLayers.toArray(),o=i.allTables.toArray().filter(e=>E(e)||S(e));return await Promise.allSettled([...r.flatMap(e=>this._getLayerLoadPromise(e)),...o.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...r.reverse(),...o.reverse()].filter(e=>I(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(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 void this._drainEditorItems();const r=[],o=[],a=[],{layerInfos:s}=this;for(const l of i){const t=ye(s,l),i=await ee(e,l).catch(()=>null);(t?r:i?o:a).push(new te({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...r,...o,...a];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(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 r=await F({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push(le(r,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 H.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=q.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)});return i}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new a("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(r=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,r)),r}async _applyEdits(e,t,i){let r=null;const o=e.url?await A(e.url):null,a={returnServiceEditsOption:(!o||!L(o))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const o=await ee(i,e).catch(()=>null);return r=await e.applyEdits(t,a),o&&await _(()=>!o.updating),r}),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation(async()=>r=await e.applyEdits(t,i)),r}_destroyWorkflowOnCommit(e){return m(()=>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 r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])}).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:r}=e,o=t.find(e=>!!e.error)||r.find(e=>!!e.error)||i.find(e=>!!e.error);if(o)throw o.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=$(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new a(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,o="ready"===this.state,a=1===i.length;if(this._queuedSelectionTool=void 0,o&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),r=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let o;if(null!=r&&""!==r){const e=J(i);if(e.length>1)throw new ie;if(o=e[0],!o)throw new re("merge"===t?2:1)}else o={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(o):"merge"===t&&await this.startMergeFeaturesWorkflow(o)}};e([W()],ge.prototype,"_featureTemplatesLayersAndTables",null),e([W()],ge.prototype,"_queuedSelectionTool",void 0),e([W()],ge.prototype,"_snappingManager",void 0),e([W()],ge.prototype,"_selectionSources",null),e([W()],ge.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],ge.prototype,"activeWorkflow",void 0),e([W()],ge.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],ge.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],ge.prototype,"canCreate",null),e([W()],ge.prototype,"canCreateVisible",null),e([W({readOnly:!0})],ge.prototype,"canUpdate",null),e([W()],ge.prototype,"canUpdateVisible",null),e([W()],ge.prototype,"featureTemplatesLayers",null),e([W()],ge.prototype,"editorItems",void 0),e([W()],ge.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],ge.prototype,"failures",void 0),e([W()],ge.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:P})],ge.prototype,"attachmentsViewModel",void 0),e([W()],ge.prototype,"featureFormViewModel",null),e([W()],ge.prototype,"formViewModel",null),e([W()],ge.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:ce})],ge.prototype,"featureTemplatesViewModel",void 0),e([W()],ge.prototype,"labelOptions",null),e([W()],ge.prototype,"layerInfos",void 0),e([W()],ge.prototype,"ownSketchViewModel",void 0),e([W()],ge.prototype,"selectionListViewModel",void 0),e([W()],ge.prototype,"selectionManager",void 0),e([W()],ge.prototype,"selectionToolbarViewModel",void 0),e([W()],ge.prototype,"sketchOptions",void 0),e([W()],ge.prototype,"sketchViewModel",null),e([W({type:j,nonNullable:!0})],ge.prototype,"snappingOptions",void 0),e([W()],ge.prototype,"spinnerViewModel",void 0),e([W()],ge.prototype,"state",null),e([W({readOnly:!0})],ge.prototype,"syncing",null),e([W()],ge.prototype,"updating",null),e([W()],ge.prototype,"tooltipOptions",null),e([W()],ge.prototype,"valueOptions",null),e([W()],ge.prototype,"view",null),e([W()],ge.prototype,"canZoomTo",null),e([W()],ge.prototype,"pageStack",void 0),e([W()],ge.prototype,"showDiscardEditsPrompt",void 0),e([W()],ge.prototype,"_candidateCommitted",void 0),e([W()],ge.prototype,"page",null),e([W()],ge.prototype,"featureFormDisabled",null),e([W()],ge.prototype,"featureFormHasAssociation",null),e([W()],ge.prototype,"canGoBack",null),e([W()],ge.prototype,"shouldShowDeleteButton",null),e([W()],ge.prototype,"hasPendingEdits",null),e([W()],ge.prototype,"snappingManager",null),ge=e([M("esri.widgets.Editor.EditorViewModel")],ge);const ke=ge;export{ke as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import a 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,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W}from"../../core/accessorSupport/decorators/property.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import{getGraphicLayer as T}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as I}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,isSubtypeGroupLayer as S,getOwningPortalUrl as A}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import U from"../../views/SelectionManager.js";import C from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import j from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as R}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import H from"./CreateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as x,isCreateFeaturesWorkflow as G,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isMergeFeaturesWorkflow as N,isSplitFeatureWorkflow as Q,isUpdateWorkflow as z,isFeatureFormViewModel as Z,findEditorItemForLayerOrThrow as $,toFeatureInfos as J,fetchFullFeaturesByObjectId as K,fetchFullFeatures as X,findEditorItemForLayer as Y,whenEditorLayerView as ee}from"./workflowUtils.js";import te from"./support/EditorItem.js";import{assertViewNot3D as ie,MultipleSourceLayersError as re,InsufficientFeatureCountError as oe,MissingOriginLayerError as ae,assertMergeWorkflowCapabilities as se,FetchFullFeatureError as ne,assertSplitWorkflowCapabilities as le}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as ce}from"../FeatureTemplates/featureTemplatesUtils.js";import de from"../FeatureTemplates/FeatureTemplatesViewModel.js";import pe from"../Sketch/SketchViewModel.js";import he from"../Spinner/SpinnerViewModel.js";import{goTo as ue}from"../support/goToUtils.js";import{isFeatureItem as we,isLayerItem as fe}from"../support/SelectionList/selectionListUtils.js";import me from"../support/SelectionList/SelectionListViewModel.js";import ye from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ge(e,t){return e?.find(e=>e.layer===t)}let ke=class extends s{constructor(e){super(e),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 b,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new de({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new pe({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new me,this.selectionManager=new U,this.selectionToolbarViewModel=new ye({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new C,this.snappingOptions=new j({attributeRulesEnabled:!0}),this.spinnerViewModel=new he,this.pageStack=[],this.showDiscardEditsPrompt=()=>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.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:r}=i.data;r.removeAll(),e&&r.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter(e=>!!t?.includes(e.layer));return[t,r,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>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},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>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 r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);await this.startCreateFeaturesWorkflowAtFeatureCreation(r)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=x(t),r=`sketch-${e.type}`;this.emit(r,{type:r,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 O({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>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:r})=>{t.view=e,i.view=e,r.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}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.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;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 r;for(const t of this.editorItems)R(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return G(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.fullFeatures.length:N(e)?e.data.features.length:Q(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(){return this.selectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return Z(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 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(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&Z(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 featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}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 a("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(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?$(this.editorItems,i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ie(this,"merge-features");const i=Array.isArray(e)?J(e):[e];if(i.length>1)throw new re;if(0===i.length||i[0].objectIds.length<2)throw new oe(2);const o=i[0],a=o.layer;if(!a)throw new ae;const s=$(this.editorItems,a);se(s);const l=this._createUpdatingResolver(),c=new AbortController;this.addHandles(n(c));try{await this._cancelWorkflow(),this.selectionToolbarViewModel.cancel();const e=await K(o.objectIds,a,this.view?.spatialReference,c.signal);if(e.length!==o.objectIds.length)throw new ne;let i;if(t.keyFeature){const r=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===r)??t.keyFeature}const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(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),ie(this,"split-feature");const i=T(e);if(!i)throw new ae;const o=$(this.editorItems,i);le(o);const a=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow();const o=await X([e],i,this.view?.spatialReference,s.signal);if(1!==o.length)throw new ne;const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(o),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{a.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)?J(e):[e];if(t.length>1)throw new re;const i=this._createUpdatingResolver();try{await this._cancelWorkflow();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(r){this._logErrorAndCancelWorkflow(r)}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.selectionToolbarViewModel.cancel();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r([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 a("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new a("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(){o(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===Y(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:r}=this;if(!i)return;const o=void 0,a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?ue(i,a.geometry,o):ue(i,a,o);else{const e=r?.updateGraphics?.toArray();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?ue(i,e.map(e=>e.geometry).filter(t),o):e&&ue(i,e,o)}}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){we(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){we(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):fe(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,r=i.editableLayers.toArray(),o=i.allTables.toArray().filter(e=>E(e)||S(e));return await Promise.allSettled([...r.flatMap(e=>this._getLayerLoadPromise(e)),...o.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...r.reverse(),...o.reverse()].filter(e=>I(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(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 void this._drainEditorItems();const r=[],o=[],a=[],{layerInfos:s}=this;for(const l of i){const t=ge(s,l),i=await ee(e,l).catch(()=>null);(t?r:i?o:a).push(new te({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...r,...o,...a];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(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 r=await F({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push(ce(r,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 H.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=q.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)});return i}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new a("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(r=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,r)),r}async _applyEdits(e,t,i){let r=null;const o=e.url?await A(e.url):null,a={returnServiceEditsOption:(!o||!L(o))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const o=await ee(i,e).catch(()=>null);return r=await e.applyEdits(t,a),o&&await _(()=>!o.updating),r}),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation(async()=>r=await e.applyEdits(t,i)),r}_destroyWorkflowOnCommit(e){return m(()=>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 r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])}).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:r}=e,o=t.find(e=>!!e.error)||r.find(e=>!!e.error)||i.find(e=>!!e.error);if(o)throw o.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=$(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new a(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,o="ready"===this.state,a=1===i.length;if(this._queuedSelectionTool=void 0,o&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),r=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let o;if(null!=r&&""!==r){const e=J(i);if(e.length>1)throw new re;if(o=e[0],!o)throw new oe("merge"===t?2:1)}else o={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(o):"merge"===t&&await this.startMergeFeaturesWorkflow(o)}};e([W()],ke.prototype,"_featureTemplatesLayersAndTables",null),e([W()],ke.prototype,"_queuedSelectionTool",void 0),e([W()],ke.prototype,"_snappingManager",void 0),e([W()],ke.prototype,"_selectionSources",null),e([W()],ke.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],ke.prototype,"activeWorkflow",void 0),e([W()],ke.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],ke.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],ke.prototype,"canCreate",null),e([W()],ke.prototype,"canCreateVisible",null),e([W({readOnly:!0})],ke.prototype,"canUpdate",null),e([W()],ke.prototype,"canUpdateVisible",null),e([W()],ke.prototype,"featureTemplatesLayers",null),e([W()],ke.prototype,"editorItems",void 0),e([W()],ke.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],ke.prototype,"failures",void 0),e([W()],ke.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:P})],ke.prototype,"attachmentsViewModel",void 0),e([W()],ke.prototype,"featureFormViewModel",null),e([W()],ke.prototype,"formViewModel",null),e([W()],ke.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:de})],ke.prototype,"featureTemplatesViewModel",void 0),e([W()],ke.prototype,"labelOptions",null),e([W()],ke.prototype,"layerInfos",void 0),e([W()],ke.prototype,"ownSketchViewModel",void 0),e([W()],ke.prototype,"selectionListViewModel",void 0),e([W()],ke.prototype,"selectionManager",void 0),e([W()],ke.prototype,"selectionToolbarViewModel",void 0),e([W()],ke.prototype,"sketchOptions",void 0),e([W()],ke.prototype,"sketchViewModel",null),e([W({type:j,nonNullable:!0})],ke.prototype,"snappingOptions",void 0),e([W()],ke.prototype,"spinnerViewModel",void 0),e([W()],ke.prototype,"state",null),e([W({readOnly:!0})],ke.prototype,"syncing",null),e([W()],ke.prototype,"updating",null),e([W()],ke.prototype,"tooltipOptions",null),e([W()],ke.prototype,"valueOptions",null),e([W()],ke.prototype,"view",null),e([W()],ke.prototype,"canZoomTo",null),e([W()],ke.prototype,"pageStack",void 0),e([W()],ke.prototype,"showDiscardEditsPrompt",void 0),e([W()],ke.prototype,"_candidateCommitted",void 0),e([W()],ke.prototype,"page",null),e([W()],ke.prototype,"featureFormDisabled",null),e([W()],ke.prototype,"featureFormHasAssociation",null),e([W()],ke.prototype,"canGoBack",null),e([W()],ke.prototype,"shouldShowDeleteButton",null),e([W()],ke.prototype,"hasPendingEdits",null),e([W()],ke.prototype,"snappingManager",null),ke=e([M("esri.widgets.Editor.EditorViewModel")],ke);const ve=ke;export{ve as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as o}from"../../core/handleUtils.js";import{destroyMaybe as a}from"../../core/maybe.js";import{on as s,whenOnce as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as o}from"../../core/handleUtils.js";import{destroyMaybe as a}from"../../core/maybe.js";import{on as s,whenOnce as l,watch as n,initial as d}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../layers/GraphicsLayer.js";import u from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as c}from"../../views/support/HighlightDefaults.js";import f from"./Edits.js";import w from"./MergeFeaturesWorkflowData.js";import y from"./Workflow.js";import{updateGraphicSymbolWhenRequired as g,makeMinimalAttributes as F}from"./workflowUtils.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as j}from"./support/errors.js";import{mergeFeatures as H}from"./support/mergeFeaturesUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";var b;const E=Symbol();let I=b=class extends y{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new u({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=a(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}static async create(e){const{applyEdits:t,applyEditsFeatureService:r,...i}=e,{editorItem:o,features:a}=i;if(v(i.viewModel,"merge-features"),_(o),M(a,2),k(a),i.keyFeature&&!a.includes(i.keyFeature))throw new j;const s=await H(a),l=new b({data:new w({...i,mergedGeometry:s}),onCommit:z(t)});return l._set("steps",S()),l}async enter(){}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 j;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,r=e.clone();r.geometry=t.mergedGeometry;const i=new f({feature:r});t.edits=i,i.trackChanges(e),await this._setFeatureOnFormViewModel(r)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,r=e.viewModel.view,i=new V({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(s(()=>i,"value-change",({feature:i,fieldName:o,value:a})=>{const s=e.edits;i&&s&&(s.setAttribute(o,a),g(i,t,r?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,r=new p({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=r,t?.map.add(r)}_makeSketchController(){return{enter:async()=>{this.addHandles(A(this.data),E)},exit:()=>{this.removeHandles(E)}}}async _setFeatureOnFormViewModel(e){const t=this._formViewModel;t.feature=e,await l(()=>!t.updating)}};e([h()],I.prototype,"formViewModel",null),e([h()],I.prototype,"hasPendingEdits",null),e([h()],I.prototype,"layer",null),e([h()],I.prototype,"parent",null),e([h()],I.prototype,"type",void 0),e([h()],I.prototype,"_formViewModel",void 0),e([h()],I.prototype,"_graphicsLayer",void 0),e([h()],I.prototype,"_highlightHelper",void 0),I=b=e([m("esri.widgets.Editor.MergeFeaturesWorkflow")],I);const L=I;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function z(e){return async r=>{const{edits:i,keyFeature:o}=r,a=i?.feature?.cloneShallow(),s=r.editorItem.layer;if(!i||!a)throw new t("editing:missing-feature","Workflow data has no edits to submit.");i.attributesModified||(a.attributes=F(a,r.editorItem.layer));const l=[];for(const e of r.features){if(e===o)continue;const t=e.cloneShallow();t.attributes=F(t,s),t.geometry=null,l.push(t)}await e(s,{updateFeatures:[a],deleteFeatures:l})}}function A(e){const t=e.viewModel.view;if(!t)return r();const a=new u({view:t});for(const r of e.features)a.add(r);const s=new u({view:t,highlightName:c}),l=n(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new u({view:t,highlightName:c}),m=n(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return i([o(a),l,o(s),m,o(h)])}export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as a}from"../../core/maybe.js";import{debounce as o}from"../../core/promiseUtils.js";import{watch as s,on as l,whenOnce as n}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as u}from"../../views/draw/support/helpMessageUtils.js";import c from"../../views/draw/support/HighlightHelper.js";import m from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as g}from"../../views/support/HighlightDefaults.js";import y from"./Edits.js";import w from"./SplitFeatureWorkflowData.js";import f from"./Workflow.js";import{createWorkflowSteps as v,swapForEditingSession as _,updateGraphicSymbolWhenRequired as F,makeMinimalAttributes as M}from"./workflowUtils.js";import{assertSplitWorkflowCapabilities as S}from"./support/errors.js";import{getCompatibleSpitterGeometryType as b,ensureSplittableGeometry as k,makeNewFeatureAttributes as T,splitGeometry as V,canSplitByPoint as G,isSplitterGeometry as I}from"./support/splitFeatureUtils.js";import H from"../FeatureForm/FeatureFormViewModel.js";import j from"../Sketch/SketchViewModel.js";var E;const x=Symbol();let C=E=class extends f{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,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e,highlightName:g}):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=a(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(){if(this._lastSplitterGeometryWasInvalid)return"invalidSplitterGeometry";const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r="rectangle"===t||"circle"===t?t:this.data.editorItem.layer.geometryType;return"mesh"!==r?u(r,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(S(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=b(k(s.originalFeature.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.originalFeature.geometry?.type}'.`)}const l=new E({data:new w(s),defaultSplitterGeometryType:a,onCommit:W(e.applyEdits)});return l._set("steps",E._createWorkflowSteps(l,o)),l}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.")}highlightFeature(e,t){this._highlightHelper?.add(e,t)}clearHighlights(){this._highlightHelper?.removeAll()}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data;this.clearHighlights();const 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.");this.highlightFeature(e),await this._setFeatureOnFormViewModel(e,o)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new y({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=T(r.attributes,i.editorItem.layer);const n=new y({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return v(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=k(r.originalFeature.geometry),a=b(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;G(i)&&o&&e.addHandles(U(o,e.layer));const n=e._sketchViewModel;e.addHandles([l(()=>n,"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(!I(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 n.create(i.tool)}}}),s(()=>n.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(x)&&o?e.addHandles(P(o,e.layer),x):"point"===i&&e.removeHandles(x)})],this.id),await n.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),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e.clearHighlights()}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:l}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=o(i=>Promise.all([F(e,this._webStyleCache,i),F(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(s(()=>n.scale,e=>d(e))),l.add(t),p.push(i(()=>l.remove(t))),p.push(await _(l,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature: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 V(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,_webStyleCache:t}=this,i=e.viewModel.view,r=new H({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(l(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),F(r,t,i?.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 j({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>{const{activeFeature:e}=this;e&&this.highlightFeature(e)},exit:()=>{this.clearHighlights()},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.originalFeature)):r.editType="INSERT",await n(()=>!r.updating)}get test(){}};e([p()],C.prototype,"activeFeature",null),e([p()],C.prototype,"allowSave",null),e([p()],C.prototype,"availableCreateTools",null),e([p()],C.prototype,"defaultSplitterGeometryType",void 0),e([p()],C.prototype,"formViewModel",null),e([p()],C.prototype,"hasInvalidFormTemplate",null),e([p()],C.prototype,"hasPreviousStep",null),e([p()],C.prototype,"helpMessage",null),e([p()],C.prototype,"layer",null),e([p()],C.prototype,"parent",null),e([p()],C.prototype,"type",void 0),e([p()],C.prototype,"updating",null),e([p()],C.prototype,"_activeFeature",void 0),e([p()],C.prototype,"_formViewModel",void 0),e([p()],C.prototype,"_graphicsLayer",void 0),e([p()],C.prototype,"_highlightHelper",void 0),e([p()],C.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([p()],C.prototype,"_sketchViewModel",void 0),C=E=e([d("esri.widgets.Editor.SplitFeatureWorkflow")],C);const L=C;function W(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=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=M(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}function U(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new m({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function P(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 l=new Map;for(const i of r.featureSources)l.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 l)e.enabled=t})}export{L as default};
|
|
5
|
+
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 l,on as n,whenOnce as p,initial as d}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/draw/support/HighlightHelper.js";import y from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as g}from"../../views/support/HighlightDefaults.js";import f from"./Edits.js";import v from"./SplitFeatureWorkflowData.js";import _ from"./Workflow.js";import{createWorkflowSteps as F,swapForEditingSession as M,updateGraphicSymbolWhenRequired as b,makeMinimalAttributes as S}from"./workflowUtils.js";import{assertViewNot3D as k,assertSplitWorkflowCapabilities as T}from"./support/errors.js";import{getCompatibleSpitterGeometryType as V,ensureSplittableGeometry as G,makeNewFeatureAttributes as I,splitGeometry as E,canSplitByPoint as H,isSplitterGeometry as j}from"./support/splitFeatureUtils.js";import x from"../FeatureForm/FeatureFormViewModel.js";import C from"../Sketch/SketchViewModel.js";var L;const W=Symbol(),U=Symbol();let P=L=class extends _{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,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new w({view:e,highlightName:g}):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(){if(this._lastSplitterGeometryWasInvalid)return"invalidSplitterGeometry";const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r="rectangle"===t||"circle"===t?t:this.data.editorItem.layer.geometryType;return"mesh"!==r?m(r,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(k(e.viewModel,"split-feature"),T(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=V(G(s.originalFeature.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.originalFeature.geometry?.type}'.`)}const l=new L({data:new v(s),defaultSplitterGeometryType:a,onCommit:A(e.applyEdits)});return l._set("steps",L._createWorkflowSteps(l,o)),l}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 start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new f({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=I(r.attributes,i.editorItem.layer);const n=new f({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return F(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.originalFeature.geometry),a=V(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;H(i)&&o&&e.addHandles(O(o,e.layer));const s=e._sketchViewModel;e.addHandles([n(()=>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(!j(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)}}}),l(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(W)&&o?e.addHandles(R(o,e.layer),W):"point"===i&&e.removeHandles(W)})],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),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=s(i=>Promise.all([b(e,this._webStyleCache,i),b(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(l(()=>n.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await M(o,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature: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 E(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,_webStyleCache:t}=this,i=e.viewModel.view,r=new x({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(n(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),b(r,t,i?.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 C({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>this.addHandles(D(this)),exit:()=>this.removeHandles(U),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.originalFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],P.prototype,"activeFeature",null),e([u()],P.prototype,"allowSave",null),e([u()],P.prototype,"availableCreateTools",null),e([u()],P.prototype,"defaultSplitterGeometryType",void 0),e([u()],P.prototype,"formViewModel",null),e([u()],P.prototype,"hasInvalidFormTemplate",null),e([u()],P.prototype,"hasPreviousStep",null),e([u()],P.prototype,"helpMessage",null),e([u()],P.prototype,"layer",null),e([u()],P.prototype,"parent",null),e([u()],P.prototype,"type",void 0),e([u()],P.prototype,"updating",null),e([u()],P.prototype,"_activeFeature",void 0),e([u()],P.prototype,"_formViewModel",void 0),e([u()],P.prototype,"_graphicsLayer",void 0),e([u()],P.prototype,"_highlightHelper",void 0),e([u()],P.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],P.prototype,"_sketchViewModel",void 0),P=L=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],P);const z=P;function A(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=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=S(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}function O(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new y({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function R(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 l=new Map;for(const i of r.featureSources)l.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 l)e.enabled=t})}function D(e){const t=e.data,{originalFeature:o,viewModel:s}=t,{view:n}=s;if(!n)return i();const p=new w({view:n}),u=l(()=>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 w({view:n,highlightName:g}),h=l(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=l(()=>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{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import i 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.originalFeature=null,this.sketchOptions=new i,this.snappingManager=null,this.splitResult=null,this.splitterGeometry=null,this.viewModel=null}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:o}=this;return e?.feature===t?e:o?.feature===t?o:null}getRoleForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:o}=this;return e?.feature===t?"existing":o?.feature===t?"new":null}};t([o({constructOnly:!0})],s.prototype,"editorItem",void 0),t([o()],s.prototype,"newFeatureEdits",void 0),t([o()],s.prototype,"existingFeatureEdits",void 0),t([o()],s.prototype,"originalFeature",void 0),t([o()],s.prototype,"parent",void 0),t([o({constructOnly:!0})],s.prototype,"sketchOptions",void 0),t([o()],s.prototype,"snappingManager",void 0),t([o()],s.prototype,"splitResult",void 0),t([o()],s.prototype,"splitterGeometry",void 0),t([o()],s.prototype,"timeZone",null),t([o()],s.prototype,"viewModel",void 0),s=t([r("esri.widgets.Editor.SplitFeatureWorkflowData")],s);const n=s;export{n as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import i 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.originalFeature=null,this.sketchOptions=new i,this.snappingManager=null,this.splitResult=null,this.splitterGeometry=null,this.temporaryHighlightFeature=null,this.viewModel=null}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:o}=this;return e?.feature===t?e:o?.feature===t?o:null}getRoleForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:o}=this;return e?.feature===t?"existing":o?.feature===t?"new":null}};t([o({constructOnly:!0})],s.prototype,"editorItem",void 0),t([o()],s.prototype,"newFeatureEdits",void 0),t([o()],s.prototype,"existingFeatureEdits",void 0),t([o()],s.prototype,"originalFeature",void 0),t([o()],s.prototype,"parent",void 0),t([o({constructOnly:!0})],s.prototype,"sketchOptions",void 0),t([o()],s.prototype,"snappingManager",void 0),t([o()],s.prototype,"splitResult",void 0),t([o()],s.prototype,"splitterGeometry",void 0),t([o()],s.prototype,"temporaryHighlightFeature",void 0),t([o()],s.prototype,"timeZone",null),t([o()],s.prototype,"viewModel",void 0),s=t([r("esri.widgets.Editor.SplitFeatureWorkflowData")],s);const n=s;export{n as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as k}from"./workflowUtils.js";import g from"../Sketch/SketchViewModel.js";var _;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=_=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}get viewGraphic(){return this._sketchViewModel?this._sketchGraphicClone:this.data.edits.feature??this.fullFeature}async commit(){this.removeHandles(V.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),o(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;h(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:o}=this,{edits:r,viewModel:a}=i,l=r.feature,{view:h}=a,d=p(l),n=await w({feature:l,featureClone:o,visualVariableAttributes:d,sketchLayer:e,sketchViewModel:t,view:h,onUpdate:({geometry:e,attributes:t},i)=>{if(r.updateAttributes(t),r.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;s.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&k(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,V.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:o}=e,r=e.edits.feature,{capabilities:a,layer:h}=e.editorItem,d=e.viewModel.view;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!a.update.geometry||o)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:h.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c=new g({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:d});return this._sketchLayer=n,this._sketchViewModel=c,d?.map.add(n),await(d?.whenLayerView(n)),this.addHandles(i(()=>{d?.destroyed||d?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=s(c)}),V.sketchViewModel),await u(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await m(n,d,r,t)]),{enter:async()=>{this.hasHandles(V.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([V.sketchGraphics]),viewModel:c}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new _({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([r()],v.prototype,"_layerViewEditSession",void 0),e([r()],v.prototype,"_sketchGraphicClone",void 0),e([r()],v.prototype,"_sketchLayer",void 0),e([r()],v.prototype,"_sketchViewModel",void 0),v=_=e([a("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v as UpdateFeatureWorkflow,V as handleKeys};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{destroyMaybe as i}from"../../core/maybe.js";import{whenOnce as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as l}from"../../layers/support/layerUtils.js";import u from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import d from"./UpdateFeaturesWorkflowData.js";import p from"./Workflow.js";import{whenEditorLayerView as c,findEditorItemForLayer as f}from"./workflowUtils.js";import{MultipleSourceLayersError as h}from"./support/errors.js";import{SketchController as m}from"./support/SketchController.js";var g;const
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{destroyMaybe as i}from"../../core/maybe.js";import{whenOnce as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as l}from"../../layers/support/layerUtils.js";import u from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import d from"./UpdateFeaturesWorkflowData.js";import p from"./Workflow.js";import{whenEditorLayerView as c,findEditorItemForLayer as f}from"./workflowUtils.js";import{MultipleSourceLayersError as h}from"./support/errors.js";import{SketchController as m}from"./support/SketchController.js";var g;const y=()=>o.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),w=Symbol();let F=g=class extends p{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new t(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new r("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=i(this._sketchController),this._formViewModel.destroy()}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get selectedFeature(){return this.data.selectedFeature}get sketchViewModel(){return this._sketchController?.viewModel}get supportsMergeFeaturesWorkflow(){const e=this.data,{layers:t}=e;return!(1!==t.length||e.fullFeatures.length<2)&&!!e.getEditorItemForLayer(t[0])?.supportsMergeFeaturesWorkflow}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||!!this._sketchController?.updating}get viewGraphics(){return this._sketchController?.sketchGraphics??this.data.fullFeatures}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)M(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=f(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(y().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const u=Array.from(n),p=new g({data:new d({...o,editorItems:u}),onCommit:b(e.applyEdits)});return p._set("steps",k()),p}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;e.submit(),e.valid&&await super.save()}async start(){await super.start(),await s(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=_(t);return!r||l(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(w)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(_(e)),o=r?.layerInfo?[r.layerInfo]:null,i=new u({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone,layerInfos:o});this._formViewModel=i,this.addHandles(i.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}))}async _initializeHighlights(e,t,r){const o=await c(r,t);this.addHandles(o.highlight(e),w)}_initializeSketchController(e,t,r){const{data:o}=this,i=new m({sourceLayer:t,view:r,features:e,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{y().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=_(t);if(l(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&this._initializeSketchController(e,o,r)}};e([a()],F.prototype,"features",null),e([a()],F.prototype,"featureInfos",null),e([a()],F.prototype,"formViewModel",null),e([a()],F.prototype,"hasInvalidFormTemplate",null),e([a()],F.prototype,"hasPendingEdits",null),e([a()],F.prototype,"parent",null),e([a()],F.prototype,"saveActionLabel",null),e([a()],F.prototype,"selectedFeature",null),e([a()],F.prototype,"sketchViewModel",null),e([a()],F.prototype,"supportsMergeFeaturesWorkflow",null),e([a()],F.prototype,"type",void 0),e([a()],F.prototype,"updating",null),e([a()],F.prototype,"viewGraphics",null),e([a()],F.prototype,"_formViewModel",void 0),e([a()],F.prototype,"_sketchController",void 0),F=g=e([n("esri.widgets.Editor.UpdateFeaturesWorkflow")],F);const v=F;function k(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function b(e){return async t=>{const r=_(t),o=[],i=[];for(const e of t.fullFeatures){const r=t.getPendingEditsForFeature(e),s=r?.stagedForDelete;if(!r?.modified&&!s)continue;const a=e.clone();if(!r?.attributesModified||s){const t=e.sourceLayer;if(!t){y().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(a.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&a.setAttribute(r,e.getAttribute(r))}}r?.geometryModified&&!s||(a.geometry=null),s?i.push(a):o.push(a)}if(o.length+i.length===0)return void y().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const s={updateFeatures:o.length>0?o:void 0,deleteFeatures:i.length>0?i:void 0};await e(r,s)}}function _(e){if(e.layers.length>1)throw new h;return e.layers[0]}function M(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{v as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as a}from"../../core/handleUtils.js";import{isAborted as r}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as d}from"../../views/support/HighlightDefaults.js";import c from"./UpdateRecordWorkflowData.js";import
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as a}from"../../core/handleUtils.js";import{isAborted as r}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as d}from"../../views/support/HighlightDefaults.js";import c from"./UpdateRecordWorkflowData.js";import p from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import m from"../FeatureForm/FeatureFormViewModel.js";var u;const g={exit:Symbol()};let f=class extends p{static{u=this}constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:o}=e,{view:s}=e.viewModel,l=o.feature;s&&(this._highlightHelper=new n({view:s,highlightName:d}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const c=new AbortController;this.addHandles(a(c)),this._updatingHandles.addPromise(h([l],l.sourceLayer,e.viewModel.view.spatialReference,c.signal).then(([e])=>{r(c)||(this._onFullFeatureLoaded(e),this._initializeFormViewModel())},e=>this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})})))}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 e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(g.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:a,viewModel:r}=e,{attachmentsViewModel:s}=r,l=e.readOnly?{editing:!1}:a;s.set({capabilities:l,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i(()=>s.fileInfos.removeAll()),o(()=>s.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})],g.exit)}_initializeFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:a},readOnly:r}=this.data,s=this._formViewModel=new m({activeAssociation:e,editType:"UPDATE",feature:this.fullFeature,formTemplate:i,highlightHelper:this._highlightHelper,map:a?.map,spatialReference:a.spatialReference,timeZone:a?.timeZone,disabled:r});s.callbacks={...this.data.featureFormCallbacks,showAllRelatedRecords:e=>s.relationshipId=e.relationshipId,viewAssociatedLayers:e=>s.associationId=e.associationId,viewAssociatedFeatures:e=>s.associatedLayer=e.associatedLayer};const{initialFeature:l}=t;l&&s.overrideInitialFeature(l),this.addHandles([s.on("value-change",()=>{t.updateAttributes(s.getValues()),this.fullFeature.attributes=t.feature.attributes}),o(()=>a?.timeZone,e=>s.timeZone=e)])}_onFullFeatureLoaded(e){this.fullFeature=e;const{edits:t}=this.data;t.updateAttributes(e.attributes),t.trackChanges()}static async create(e){const t=new u({data:await c.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}static{this._onCommitFactory=e=>async t=>{const{edits:i}=t,{feature:a}=i;if(!a)return;const r=a.sourceLayer,o=a.clone();if(!i.attributesModified||i.stagedForDelete){const e=r.objectIdField;if(o.attributes={[e]:a.getAttribute(e)},"scene"===r.type&&null!=r.infoFor3D){const e=r.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,a.getAttribute(e))}}i.geometryModified&&!i.stagedForDelete||(o.geometry=null);const s=i.stagedForDelete?"deleteFeatures":"updateFeatures";await e(r,{[s]:[o]})}}};e([s()],f.prototype,"_formViewModel",void 0),e([s()],f.prototype,"allowSave",null),e([s()],f.prototype,"editorItem",null),e([s()],f.prototype,"formViewModel",null),e([s()],f.prototype,"fullFeature",void 0),e([s()],f.prototype,"hasInvalidFormTemplate",null),e([s()],f.prototype,"hasPendingEdits",null),e([s()],f.prototype,"layer",null),e([s()],f.prototype,"parent",null),e([s()],f.prototype,"saveActionLabel",null),e([s()],f.prototype,"shouldShowAttachments",null),e([s()],f.prototype,"shouldAllowAttachmentEditing",null),e([s()],f.prototype,"reliesOnOwnerAdminPrivileges",null),f=u=e([l("esri.widgets.Editor.UpdateRecordWorkflow")],f);export{f as UpdateRecordWorkflow,g as handleKeys};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
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{createResolver as n,debounce as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as U}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as ee,isGraphicForRelatableFeatureSupportedLayer as te}from"../Feature/support/featureUtils.js";var ie;let ae=ie=class extends O{constructor(e){super(e),this._workflowStack=new u(k),this._sketchStack=new u(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;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>x(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 reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(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,...o}=e,r=new ie({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(){const{formViewModel:e}=this;if(e&&(e.submit(),!e.submittable||T(e)&&re(e)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:t}=this;if(await(t?.commit()),!D(t))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===t?.parent&&(await i.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,t,i){const o=this._makeUpdatingResolver();try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(a)}catch(r){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{o.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=z(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(!T(e))throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=ee(c,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(d,[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(!T(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!A(i)||S(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=C(e.sourceLayer)?L:P,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await w(()=>!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 w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:o}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new a("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await o.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(e);const r=Q(this.data.viewModel.editorItems,W(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:e,parent:s,viewModel:o,...t});return await w(()=>!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),d=j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:e,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...t});return await w(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const a of t){const t=e(a).finally(()=>a.destroy());this._updatingHandles.addPromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=n();return this._updatingHandles.addPromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:a}=e;if(!te(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=oe(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=oe(i,o);return{[d]: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&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return $(["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 l=a.on("immediate-click",async o=>{const s=n();e._updatingHandles.addPromise(s.promise);try{t.location=o.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await o.defer(()=>new Promise((e,t)=>{d(r?.signal,()=>t(c())),e(B(s,a,o,r?.signal))}));if(p(r),i.candidates=n.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()}},E.TOOL),u=v(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([l,u],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:U});e.addHandles([g(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>a.remove(e)),e.forEach(e=>a.add(e))},f),o(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await se(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=l(async()=>{await w(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},f)],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 oe(e,{keyField:t}){return e.getField(t)?.name??t}function re(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function se(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([m()],ae.prototype,"formViewModel",null),e([m()],ae.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([m()],ae.prototype,"activeSketchViewModel",null),e([m()],ae.prototype,"canDeleteAssociation",null),e([m()],ae.prototype,"activeWorkflow",null),e([m()],ae.prototype,"updating",null),e([m()],ae.prototype,"data",void 0),e([m()],ae.prototype,"hasPreviousStep",null),e([m()],ae.prototype,"hasUpdatableCandidates",null),e([m()],ae.prototype,"nestedWorkflowCount",null),e([m()],ae.prototype,"shouldShowAttachments",null),e([m()],ae.prototype,"shouldAllowAttachmentEditing",null),e([m()],ae.prototype,"hasPendingEdits",null),e([m()],ae.prototype,"helpMessage",null),e([m()],ae.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],ae.prototype,"hasInvalidFormTemplate",null),ae=ie=e([y("esri.widgets.Editor.UpdateWorkflow")],ae);const ne=ae;export{ne as default};
|
|
5
|
+
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{createResolver as n,debounce as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as U}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as ee,isGraphicForRelatableFeatureSupportedLayer as te}from"../Feature/support/featureUtils.js";var ie;let ae=ie=class extends O{constructor(e){super(e),this._workflowStack=new u(k),this._sketchStack=new u(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;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>x(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 reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(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,...o}=e,r=new ie({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(){const{formViewModel:e}=this;if(e&&(e.submit(),!e.submittable||T(e)&&re(e)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:t}=this;if(await(t?.commit()),!D(t))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===t?.parent&&(await i.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,t,i){const o=this._makeUpdatingResolver();try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(a)}catch(r){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{o.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=z(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(!T(e))throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=ee(c,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(d,[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(!T(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!A(i)||S(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=C(e.sourceLayer)?L:P,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await w(()=>!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 w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:o}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new a("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await o.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(e);const r=Q(this.data.viewModel.editorItems,W(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:e,parent:s,viewModel:o,...t});return await w(()=>!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),d=j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:e,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...t});return await w(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const a of t){const t=e(a).finally(()=>a.destroy());this._updatingHandles.addPromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=n();return this._updatingHandles.addPromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:a}=e;if(!te(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=oe(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=oe(i,o);return{[d]: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&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return $(["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 l=a.on("immediate-click",async o=>{const s=n();e._updatingHandles.addPromise(s.promise);try{t.location=o.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await o.defer(()=>new Promise((e,t)=>{d(r?.signal,()=>t(c())),e(B(s,a,o,r?.signal))}));if(p(r),i.candidates=n.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()}},E.TOOL),u=v(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([l,u],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:U});e.addHandles([g(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>a.remove(e)),e.forEach(e=>a.add(e))},f),o(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await se(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=l(async()=>{await w(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},f)],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 oe(e,{keyField:t}){return e.getField(t)?.name??t}function re(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function se(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([m()],ae.prototype,"formViewModel",null),e([m()],ae.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([m()],ae.prototype,"activeSketchViewModel",null),e([m()],ae.prototype,"canDeleteAssociation",null),e([m()],ae.prototype,"activeWorkflow",null),e([m()],ae.prototype,"updating",null),e([m()],ae.prototype,"data",void 0),e([m()],ae.prototype,"hasPreviousStep",null),e([m()],ae.prototype,"hasUpdatableCandidates",null),e([m()],ae.prototype,"nestedWorkflowCount",null),e([m()],ae.prototype,"shouldShowAttachments",null),e([m()],ae.prototype,"shouldAllowAttachmentEditing",null),e([m()],ae.prototype,"hasPendingEdits",null),e([m()],ae.prototype,"helpMessage",null),e([m()],ae.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],ae.prototype,"hasInvalidFormTemplate",null),ae=ie=e([y("esri.widgets.Editor.UpdateWorkflow")],ae);const ne=ae;export{ne as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{throwIfNotAbortError as i,createResolver as n}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as a}from"../../core/support/UpdatingHandles.js";let p=class extends s{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._updatingHandles=new a,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null,this._pendingOperation=null}destroy(){this._updatingHandles.destroy()}get formViewModel(){return null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter(t=>!t.parent).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get allowSave(){return!this.updating}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}get updating(){return this._updatingHandles.updating||!!this.formViewModel?.updating}async back(t=()=>Promise.resolve(!0)){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise((s,i)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>i(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})})}async commit(){this.removeHandles(this._handleKeys.beforeCommit),this.onCommit&&await this.onCommit(this.data),this.removeHandles(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex(e=>e.id===t);this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({emitCancelEvent:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({emitCancelEvent:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this._transaction(()=>this.steps[this._stepIndex]?.tearDown({canceled:!0}))),this.removeHandles([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}_go(t=-1,e=!1){return this._transaction(async()=>{const{steps:s}=this;if(!(t<=-1||t>=s.length)){if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&await s[this._lastStepIndex].tearDown({canceled:e});try{await s[t].setUp()}catch(n){i(n)}this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps()}})}async _transaction(t){const e=this._pendingOperation,s=n(),i=(e??Promise.resolve()).then(()=>s.promise);this._pendingOperation=i,this._updatingHandles.addPromise(i);try{e&&await e,await t()}finally{s.resolve(),i===this._pendingOperation&&(this._pendingOperation=null)}}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([o()],p.prototype,"data",void 0),t([o()],p.prototype,"formViewModel",null),t([o()],p.prototype,"hasNextStep",null),t([o()],p.prototype,"hasPreviousStep",null),t([o()],p.prototype,"onCommit",void 0),t([o()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([o()],p.prototype,"hasInvalidFormTemplate",null),t([o()],p.prototype,"shouldShowAttachments",null),t([o()],p.prototype,"shouldAllowAttachmentEditing",null),t([o()],p.prototype,"started",void 0),t([o({readOnly:!0})],p.prototype,"stepId",null),t([o()],p.prototype,"steps",void 0),t([o({readOnly:!0})],p.prototype,"type",void 0),t([o()],p.prototype,"allowSave",null),t([o()],p.prototype,"helpMessage",null),t([o()],p.prototype,"hasPendingEdits",null),t([o()],p.prototype,"keyboardCancellationEnabled",null),t([o()],p.prototype,"updating",null),p=t([r("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{throwIfNotAbortError as i,createResolver as n}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as a}from"../../core/support/UpdatingHandles.js";let p=class extends s{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._updatingHandles=new a,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null,this._pendingOperation=null}destroy(){this._updatingHandles.destroy()}get formViewModel(){return null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter(t=>!t.parent).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get allowSave(){return!this.updating}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}get saveActionLabel(){return"submit"}get updating(){return this._updatingHandles.updating||!!this.formViewModel?.updating}async back(t=()=>Promise.resolve(!0)){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise((s,i)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>i(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})})}async commit(){this.removeHandles(this._handleKeys.beforeCommit),this.onCommit&&await this.onCommit(this.data),this.removeHandles(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex(e=>e.id===t);this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({emitCancelEvent:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({emitCancelEvent:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this._transaction(()=>this.steps[this._stepIndex]?.tearDown({canceled:!0}))),this.removeHandles([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}_go(t=-1,e=!1){return this._transaction(async()=>{const{steps:s}=this;if(!(t<=-1||t>=s.length)){if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&await s[this._lastStepIndex].tearDown({canceled:e});try{await s[t].setUp()}catch(n){i(n)}this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps()}})}async _transaction(t){const e=this._pendingOperation,s=n(),i=(e??Promise.resolve()).then(()=>s.promise);this._pendingOperation=i,this._updatingHandles.addPromise(i);try{e&&await e,await t()}finally{s.resolve(),i===this._pendingOperation&&(this._pendingOperation=null)}}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([o()],p.prototype,"data",void 0),t([o()],p.prototype,"formViewModel",null),t([o()],p.prototype,"hasNextStep",null),t([o()],p.prototype,"hasPreviousStep",null),t([o()],p.prototype,"onCommit",void 0),t([o()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([o()],p.prototype,"hasInvalidFormTemplate",null),t([o()],p.prototype,"shouldShowAttachments",null),t([o()],p.prototype,"shouldAllowAttachmentEditing",null),t([o()],p.prototype,"started",void 0),t([o({readOnly:!0})],p.prototype,"stepId",null),t([o()],p.prototype,"steps",void 0),t([o({readOnly:!0})],p.prototype,"type",void 0),t([o()],p.prototype,"allowSave",null),t([o()],p.prototype,"helpMessage",null),t([o()],p.prototype,"hasPendingEdits",null),t([o()],p.prototype,"keyboardCancellationEnabled",null),t([o()],p.prototype,"updating",null),p=t([r("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{loadPanelContentComponents as
|
|
5
|
+
import{loadPanelContentComponents as e,PanelContent as t,PanelContentMessage as n}from"./PanelContent.js";import{tsx as o,tsxFragment as r}from"../../support/widget.js";const s=()=>e();function a({helpMessage:e,renderSketchToolbar:s}){return o(r,null,s(),o(t,{key:"creating-features-panel-content"},o(n,{key:"content-message"},e)))}export{a as CreateFeaturesPanelContent,s as loadCreateFeaturesPanelContentComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import{getEffectiveFieldAlias as t}from"../../../editing/fieldUtils.js";import{getDisplayFieldName as o}from"../../../layers/support/fieldUtils.js";import{findEditorItemForLayer as r}from"../workflowUtils.js";import{loadPanelContentComponents as s,PanelContentSection as a,PanelContent as l}from"./PanelContent.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{ItemList as i}from"../../support/ItemList.js";import{tsx as c}from"../../support/widget.js";const m=()=>Promise.all([s(),n({action:()=>import("@esri/calcite-components/dist/components/calcite-action")})]);function d({editorItems:t,filterText:o,id:s,messagesTemplates:n,onFilterTextChange:m,onSelectFeature:d,onZoomTo:f,workflow:g,editorMessages:j}){const y=new Map,I=g.data.candidates;let b=0;I.map(e=>({label:p(e),id:e.attributes[e.layer.objectIdField],data:e})).filter(({label:e,data:s})=>{const a=o.toLowerCase(),{title:l}=s.layer,n=r(t,s.sourceLayer);return n?n.supportsUpdateWorkflow&&(!a||e?.toLowerCase().includes(a)||l?.toLowerCase().includes(a)):null}).filter(e).forEach(e=>{b++;const t=e.data.layer;y.has(t)?y.get(t)?.items.push(e):y.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})});const h=t.toArray().map(({layer:e})=>y.get(e)).filter(e),w=b>10||o.length>0;return c(l,{key:"feature-list"},c(a,null,i({enableListScroll:!1,filterEnabled:w,filterText:o,id:s,items:h,messages:{filterPlaceholder:n.filterPlaceholder,noItems:n.noItems,noMatches:n.noMatches},onFilterChange:e=>m(e),onItemMouseEnter:e=>d(e.data),onItemMouseLeave:()=>d(null),onItemSelect:e=>d(e.data,!0),renderItemActionEnd:e=>u(e.data,f,j.zoomTo)})))}function p(e){const r=e.sourceLayer??e.layer;if(!r)return null;const s=r.fieldsIndex.get(r.objectIdField);if(!s)return null;const a=t(s,r)||s.name,l=e.attributes,n=o(r);return n&&l[n]&&`${l[n]}`||`${a}: ${l[s.name]}`}function u(e,t,o){return c("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onclick:()=>t(e),scale:"s",slot:"actions-end",text:o,title:o})}export{d as FeatureList,m as loadFeatureListComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t}from"../../../core/arrayUtils.js";import{loadCalciteComponents as o}from"../../support/componentsUtils.js";import
|
|
5
|
+
import{isSome as t}from"../../../core/arrayUtils.js";import{loadCalciteComponents as o}from"../../support/componentsUtils.js";import{tsx as i}from"../../support/widget.js";const e={base:"esri-editor__actions",notice:"esri-editor__actions--notice"},c=()=>o({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),"split-button":()=>import("@esri/calcite-components/dist/components/calcite-split-button"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")});function n({buttons:o,key:c,notice:n}){return i("div",{class:e.base,key:c??"footer-actions",slot:"footer"},n?i("div",{class:e.notice},n.icon?i("calcite-icon",{icon:n.icon,scale:"s"}):void 0,i("span",null,n.text)):void 0,i("div",null,o.filter(t).map((t,o)=>"split-button"===t.type?l(t,o):s(t,o))))}const s=({disabled:t,onClick:o,label:e,key:c,...n},s)=>i("calcite-button",{disabled:t??!1,key:c??`action-${s}`,onclick:o,width:"full",...n},e),l=({disabled:o,onClick:e,key:c,dropdownItems:n,...s},l)=>i("calcite-split-button",{disabled:o??!1,key:c??`split-action-${l}`,width:"full",onCalciteSplitButtonPrimaryClick:e,...s},i("calcite-dropdown-group",{selectionMode:"none"},n.filter(t).map(p))),p=({disabled:t,onClick:o,label:e,key:c,...n},s)=>i("calcite-dropdown-item",{disabled:t??!1,key:c??`dropdown-item-${s}`,onCalciteDropdownItemSelect:o,...n},e);export{n as FooterActions,e as css,c as loadFooterActionsComponents};
|