@arcgis/core 5.0.0-next.8 → 5.0.0-next.9
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02e7359162cf974b41b6.js +1 -0
- package/assets/esri/core/workers/chunks/0f735b0dec173142f3b6.js +2 -0
- package/assets/esri/core/workers/chunks/{a8f998b8ec8c56150479.js.LICENSE.txt → 0f735b0dec173142f3b6.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{b708792c84620b73c847.js → 21293b0c6405a10ec7b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{a876d6159ca120c1567e.js → 28d1f2cf6aae547615c3.js} +1 -1
- package/assets/esri/core/workers/chunks/292daac70bb828e4923f.js +1 -0
- package/assets/esri/core/workers/chunks/31b6406960261da21dd4.js +1 -0
- package/assets/esri/core/workers/chunks/31dbe07047dc61303d7d.js +1 -0
- package/assets/esri/core/workers/chunks/{59d3cac32ad6dad941dc.js → 35c9b24e4430bd6c2b6b.js} +1 -1
- package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/4fb5f1c671892001a4fd.js +1 -0
- package/assets/esri/core/workers/chunks/{d88f2fe680b8d5603ef8.js → 5350d50b47b6a4e0e169.js} +1 -1
- package/assets/esri/core/workers/chunks/58e59ead33368ce38c8f.js +1 -0
- package/assets/esri/core/workers/chunks/{aff8e40a641c6822af1d.js → 5db37547963857295273.js} +1 -1
- package/assets/esri/core/workers/chunks/{3afb83f5de033dda89ec.js → 604777417722d4effe06.js} +1 -1
- package/assets/esri/core/workers/chunks/67f03d042455cd0f7009.js +1 -0
- package/assets/esri/core/workers/chunks/7565b382f6b3d2cb46a3.js +2 -0
- package/assets/esri/core/workers/chunks/{b96eb0ea506379182d62.js.LICENSE.txt → 7565b382f6b3d2cb46a3.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/7d641f2f5edd95b9bc18.js +1 -0
- package/assets/esri/core/workers/chunks/812f2ccc01f44e3cfd41.js +1 -0
- package/assets/esri/core/workers/chunks/826fa0dfb63df77bfd95.js +1 -0
- package/assets/esri/core/workers/chunks/87921f3fa9001f5801ed.js +1 -0
- package/assets/esri/core/workers/chunks/{2a8dff8521e1e6a10cf6.js → 89b748e064ca90b4f76a.js} +1 -1
- package/assets/esri/core/workers/chunks/{fef45bc59c71f88c60b5.js → 8d9d3797c6d62fdfff9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{e5a06ce0ef6a9a90e100.js → 9f21436016ff7a899e79.js} +1 -1
- package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js → 9ff8ee6ed6b98c03ae7e.js} +2 -2
- package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js.LICENSE.txt → 9ff8ee6ed6b98c03ae7e.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/b05208d56a724a8f1661.js +1 -0
- package/assets/esri/core/workers/chunks/{b0365cbc3d2a41969e3b.js → b7eb486354994dc70855.js} +1 -1
- package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +1 -0
- package/assets/esri/core/workers/chunks/c715fd32f814a0f14f40.js +1 -0
- package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/cf971e7b1b98d9c502d3.js +1 -0
- package/assets/esri/core/workers/chunks/{20975513be0a3a1da286.js → d1ca7c3a32ce00ed8b81.js} +1 -1
- package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js → d391bfbaf0e790cd10d6.js} +2 -2
- package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js.LICENSE.txt → d391bfbaf0e790cd10d6.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/db678a6e352275e507a9.js +1 -0
- package/assets/esri/core/workers/chunks/de2ebd9cc3d9e68d435b.js +1 -0
- package/assets/esri/core/workers/chunks/e599125e746c27de106e.js +1 -0
- package/assets/esri/core/workers/chunks/{05429f9d292a7a714309.js → ebcc94234d9d4be1941f.js} +1 -1
- package/assets/esri/core/workers/chunks/ee5f0fd5384caa11c986.js +1 -0
- package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/f80f5dbf96c343ac4df6.js +1 -0
- package/assets/esri/core/workers/chunks/fccd931f95d81ecc57b2.js +1 -0
- package/assets/esri/themes/base/widgets/_NavigationToggle.scss +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -4
- package/assets/esri/themes/base/widgets/_Widget.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.js +1 -1
- package/form/FormTemplate.js +1 -1
- package/form/elements/Element.js +1 -1
- package/form/elements/FieldElement.js +1 -1
- package/form/elements/GroupElement.js +1 -1
- package/interfaces.d.ts +25 -23
- package/kernel.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/layers/support/rasterFunctions/pixelTransformUtils.js +5 -0
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/package.json +2 -2
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/support/PromiseQueue.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/widgets/Editor/AddAssociationWorkflow.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/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor/support/errors.js +5 -0
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
- package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +0 -1
- package/assets/esri/core/workers/chunks/1d15d1b20dc10fde6def.js +0 -1
- package/assets/esri/core/workers/chunks/28020063048e644f17a5.js +0 -1
- package/assets/esri/core/workers/chunks/36d067c8d03d7a894f5f.js +0 -1
- package/assets/esri/core/workers/chunks/38cc18fd93c18815ded0.js +0 -1
- package/assets/esri/core/workers/chunks/4eebd74ebc20579dade8.js +0 -1
- package/assets/esri/core/workers/chunks/5f402b3c00bc4afc77b2.js +0 -1
- package/assets/esri/core/workers/chunks/63a6f3e70d2b6ea57e40.js +0 -1
- package/assets/esri/core/workers/chunks/695cdef5057e5461078a.js +0 -1
- package/assets/esri/core/workers/chunks/6bb7dbc46787b8e34bd9.js +0 -1
- package/assets/esri/core/workers/chunks/6ee2f0f708494102a493.js +0 -1
- package/assets/esri/core/workers/chunks/78694ad8229347903f41.js +0 -1
- package/assets/esri/core/workers/chunks/90cbd627d4113db3b686.js +0 -1
- package/assets/esri/core/workers/chunks/a31635a6366347dcef0f.js +0 -1
- package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js +0 -2
- package/assets/esri/core/workers/chunks/afc13d5b842275db7dbc.js +0 -1
- package/assets/esri/core/workers/chunks/b548910e820d731ffe8a.js +0 -1
- package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +0 -2
- package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +0 -1
- package/assets/esri/core/workers/chunks/ce98416437cc1a89d8ea.js +0 -1
- package/assets/esri/core/workers/chunks/e0bbfbe1ed39c82f1bd4.js +0 -1
- package/assets/esri/core/workers/chunks/ebf23b46db56aaa88841.js +0 -1
|
@@ -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{destroyMaybe as r}from"../../core/maybe.js";import{on as i,whenOnce as o}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{destroyMaybe as r}from"../../core/maybe.js";import{on as i,whenOnce as o}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import n from"../../views/draw/support/HighlightHelper.js";import d from"./Edits.js";import p from"./MergeFeaturesWorkflowData.js";import h from"./Workflow.js";import{assertMergeWorkflowCapabilities as m,updateGraphicSymbolWhenRequired as c,makeMinimalAttributes as u}from"./workflowUtils.js";import{assertMinimumFeatureCount as f,assertFeaturesAreFromSameLayer as y,InvalidKeyFeatureError as w}from"./support/errors.js";import{mergeFeatures as g}from"./support/mergeFeaturesUtils.js";import _ from"../FeatureForm/FeatureFormViewModel.js";var F;let v=F=class extends h{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 n({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=r(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating}static async create(e){const{applyEdits:t,applyEditsFeatureService:r,...i}=e,{editorItem:o,features:a}=i;if(m(o),f(a,2),y(a),i.keyFeature&&!a.includes(i.keyFeature))throw new w;const s=await g(a),l=new F({data:new p({...i,mergedGeometry:s}),onCommit:k(t)});return l._set("steps",j()),l}async enter(){}exit(){}async setKeyFeature(e){const{data:t}=this;if(!t.features.includes(e))throw new w;t.keyFeature=e,await this._createAndInitializeEdits(e)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits(e){const{data:t}=this,r=e.clone();r.geometry=t.mergedGeometry;const i=new d({feature:r});t.edits=i,i.trackChanges(e),await this._setFeatureOnFormViewModel(r)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,r=e.viewModel.view,o=new _({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r?.spatialReference,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(i(()=>o,"value-change",({feature:i,fieldName:o,value:a})=>{const s=e.edits;i&&s&&(s.setAttribute(o,a),c(i,t,r?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,r=new l({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=r,t?.map.add(r)}_makeSketchController(){return{enter:async()=>{for(const e of this.data.features)this._highlightHelper?.add(e)},exit:()=>{this._highlightHelper?.removeAll()}}}async _setFeatureOnFormViewModel(e){const t=this._formViewModel;t.feature=e,await o(()=>!t.updating)}};e([a()],v.prototype,"formViewModel",null),e([a()],v.prototype,"layer",null),e([a()],v.prototype,"parent",null),e([a()],v.prototype,"type",void 0),e([a()],v.prototype,"updating",null),e([a()],v.prototype,"_formViewModel",void 0),e([a()],v.prototype,"_graphicsLayer",void 0),e([a()],v.prototype,"_highlightHelper",void 0),v=F=e([s("esri.widgets.Editor.MergeFeaturesWorkflow")],v);const M=v;function j(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function k(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=u(a,r.editorItem.layer));const l=[];for(const e of r.features){if(e===o)continue;const t=e.cloneShallow();t.attributes=u(t,s),t.geometry=null,l.push(t)}await e(s,{updateFeatures:[a],deleteFeatures:l})}}export{M as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/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 y}from"../../views/support/HighlightDefaults.js";import g from"./Edits.js";import w from"./SplitFeatureWorkflowData.js";import f from"./Workflow.js";import{assertSplitWorkflowCapabilities as v,createWorkflowSteps as _,swapForEditingSession as F,updateGraphicSymbolWhenRequired as M,makeMinimalAttributes as b}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as S,ensureSplittableGeometry as k,makeNewFeatureAttributes as V,splitGeometry as G,canSplitByPoint as T,isSplitterGeometry as H}from"./support/splitFeatureUtils.js";import I from"../FeatureForm/FeatureFormViewModel.js";import j from"../Sketch/SketchViewModel.js";var E;const C=Symbol();let x=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:y}):null,this._initializeFeatureFormViewModel();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 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 featureFormViewModel(){return this._formViewModel}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(v(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=S(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 g({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=V(r.attributes,i.editorItem.layer);const n=new g({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 _(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=k(r.originalFeature.geometry),a=S(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;T(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(!H(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(C)&&o?e.addHandles(P(o,e.layer),C):"point"===i&&e.removeHandles(C)})],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([M(e,this._webStyleCache,i),M(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 F(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 G(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new I({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),M(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()],x.prototype,"activeFeature",null),e([p()],x.prototype,"availableCreateTools",null),e([p()],x.prototype,"defaultSplitterGeometryType",void 0),e([p()],x.prototype,"featureFormViewModel",null),e([p()],x.prototype,"hasPreviousStep",null),e([p()],x.prototype,"helpMessage",null),e([p()],x.prototype,"layer",null),e([p()],x.prototype,"parent",null),e([p()],x.prototype,"type",void 0),e([p()],x.prototype,"updating",null),e([p()],x.prototype,"_activeFeature",void 0),e([p()],x.prototype,"_formViewModel",void 0),e([p()],x.prototype,"_graphicsLayer",void 0),e([p()],x.prototype,"_highlightHelper",void 0),e([p()],x.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([p()],x.prototype,"_sketchViewModel",void 0),x=E=e([d("esri.widgets.Editor.SplitFeatureWorkflow")],x);const L=x;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=b(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}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 y}from"../../views/support/HighlightDefaults.js";import g from"./Edits.js";import w from"./SplitFeatureWorkflowData.js";import f from"./Workflow.js";import{assertSplitWorkflowCapabilities as v,createWorkflowSteps as _,swapForEditingSession as F,updateGraphicSymbolWhenRequired as M,makeMinimalAttributes as b}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as S,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 C=Symbol();let x=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:y}):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 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(v(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=S(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 g({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 g({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 _(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=k(r.originalFeature.geometry),a=S(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(C)&&o?e.addHandles(P(o,e.layer),C):"point"===i&&e.removeHandles(C)})],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([M(e,this._webStyleCache,i),M(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 F(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),M(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()],x.prototype,"activeFeature",null),e([p()],x.prototype,"availableCreateTools",null),e([p()],x.prototype,"defaultSplitterGeometryType",void 0),e([p()],x.prototype,"formViewModel",null),e([p()],x.prototype,"hasInvalidFormTemplate",null),e([p()],x.prototype,"hasPreviousStep",null),e([p()],x.prototype,"helpMessage",null),e([p()],x.prototype,"layer",null),e([p()],x.prototype,"parent",null),e([p()],x.prototype,"type",void 0),e([p()],x.prototype,"updating",null),e([p()],x.prototype,"_activeFeature",void 0),e([p()],x.prototype,"_formViewModel",void 0),e([p()],x.prototype,"_graphicsLayer",void 0),e([p()],x.prototype,"_highlightHelper",void 0),e([p()],x.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([p()],x.prototype,"_sketchViewModel",void 0),x=E=e([d("esri.widgets.Editor.SplitFeatureWorkflow")],x);const L=x;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=b(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};
|
|
@@ -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 m,swapForEditingSession as u,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()}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 m(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await u(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 d from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import u from"./UpdateFeaturesWorkflowData.js";import c from"./Workflow.js";import{whenEditorLayerView as p,findEditorItemForLayer as f
|
|
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 d from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import u from"./UpdateFeaturesWorkflowData.js";import c from"./Workflow.js";import{whenEditorLayerView as p,findEditorItemForLayer as f}from"./workflowUtils.js";import{MultipleSourceLayersError as h}from"./support/errors.js";import{SketchController as m}from"./support/SketchController.js";var w;const g=()=>o.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),y=Symbol();let F=w=class extends c{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 selectedFeature(){return this.data.selectedFeature}get sketchViewModel(){return this._sketchController?.viewModel}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||!!this._sketchController?.updating}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&&(g().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),c=new w({data:new u({...o,editorItems:d}),onCommit:b(e.applyEdits)});return c._set("steps",_()),c}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=k(t);return!r||l(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(y)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(k(e)),o=new d({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(o.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 p(r,t);this.addHandles(o.highlight(e),y)}_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:()=>{g().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=k(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,"selectedFeature",null),e([a()],F.prototype,"sketchViewModel",null),e([a()],F.prototype,"type",void 0),e([a()],F.prototype,"updating",null),e([a()],F.prototype,"_formViewModel",void 0),e([a()],F.prototype,"_sketchController",void 0),F=w=e([n("esri.widgets.Editor.UpdateFeaturesWorkflow")],F);const v=F;function _(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function b(e){return async t=>{const r=k(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){g().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 g().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 k(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 r}from"../../core/handleUtils.js";import{isAborted as a}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
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as r}from"../../core/handleUtils.js";import{isAborted as a}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 m from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import p from"../FeatureForm/FeatureFormViewModel.js";var u;const f={exit:Symbol()};let g=class extends m{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(r(c)),this._updatingHandles.addPromise(h([l],l.sourceLayer,e.viewModel.view.spatialReference,c.signal).then(([e])=>{a(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 editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItem.hasInvalidFormTemplate}get hasPendingEdits(){return this.data.edits.modified}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}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(f.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:r,viewModel:a}=e,{attachmentsViewModel:s}=a,l=e.readOnly?{editing:!1}:r;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")}})],f.exit)}_initializeFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:r},readOnly:a}=this.data,s=this._formViewModel=new p({activeAssociation:e,editType:"UPDATE",feature:this.fullFeature,formTemplate:i,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r.spatialReference,timeZone:r?.timeZone,disabled:a});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(()=>r?.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:r}=i;if(!r)return;const a=r.sourceLayer,o=r.clone();if(!i.attributesModified||i.stagedForDelete){const e=a.objectIdField;if(o.attributes={[e]:r.getAttribute(e)},"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,r.getAttribute(e))}}i.geometryModified&&!i.stagedForDelete||(o.geometry=null);const s=i.stagedForDelete?"deleteFeatures":"updateFeatures";await e(a,{[s]:[o]})}}};e([s()],g.prototype,"_formViewModel",void 0),e([s()],g.prototype,"editorItem",null),e([s()],g.prototype,"formViewModel",null),e([s()],g.prototype,"fullFeature",void 0),e([s()],g.prototype,"hasInvalidFormTemplate",null),e([s()],g.prototype,"hasPendingEdits",null),e([s()],g.prototype,"layer",null),e([s()],g.prototype,"parent",null),e([s()],g.prototype,"shouldShowAttachments",null),e([s()],g.prototype,"shouldAllowAttachmentEditing",null),e([s()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=u=e([l("esri.widgets.Editor.UpdateRecordWorkflow")],g);export{g as UpdateRecordWorkflow,f 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 t}from"tslib";import e from"../../core/Accessor.js";import o from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"./Edits.js";import{findEditorItemForLayer as a}from"./workflowUtils.js";var p;let d=p=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.parent=null,this.featureFormCallbacks=null,this.viewModel=null,this.readOnly=!1}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=p._makeConstructorProps(t);return new p(e)}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}=t,n=a(d.editorItems,r.sourceLayer);if(!n)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:n,edits:new i({feature:r}),parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l??!1}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"viewModel",void 0),t([r()],d.prototype,"readOnly",void 0),d=p=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],d);const l=d;export{l as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import o from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"./Edits.js";import{findEditorItemForLayer as a}from"./workflowUtils.js";var p;let d=p=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.parent=null,this.featureFormCallbacks=null,this.viewModel=null,this.readOnly=!1}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=p._makeConstructorProps(t);return new p(e)}stageDelete(){this.edits.stageDelete()}static _makeConstructorProps(t){const{association:e,feature:r,parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l}=t,n=a(d.editorItems,r.sourceLayer);if(!n)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:n,edits:new i({feature:r}),parent:s,featureFormCallbacks:p,viewModel:d,readOnly:l??!1}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"viewModel",void 0),t([r()],d.prototype,"readOnly",void 0),d=p=t([s("esri.widgets.Editor.UpdateRecordWorkflowData")],d);const l=d;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 t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{debounce as s,createResolver as n,onAbort as l,createAbortError as d,throwIfAborted as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as w,sync as h,when as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import{isFeatureLayer as y,isSubtypeSublayer as W,isSubtypeGroupLayer as A,isTable as _}from"../../layers/support/layerUtils.js";import{createFeatureServices as b}from"../../rest/featureService/utils.js";import C from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{temporaryHighlightName as S}from"../../views/support/HighlightDefaults.js";import M from"./CreateFeaturesWorkflow.js";import I from"./SplitFeatureWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as R}from"./UpdateRecordWorkflow.js";import V from"./UpdateWorkflowData.js";import U from"./Workflow.js";import{findEditorItemForLayer as j,isSplitFeatureWorkflow as P,isUpdateRecordWorkflow as L,isParentWorkflow as O,findEditorItemForLayerOrThrow as x,createWorkflowSteps as T,fetchCandidates as H}from"./workflowUtils.js";import{findUtilityNetwork as N,isGraphicForRelatableFeatureSupportedLayer as D}from"../Feature/support/featureUtils.js";var q;let G=q=class extends U{constructor(t){super(t),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(t=>t.cancel({force:!0}))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:t}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!t)return!1;const{activeAssociation:e,feature:i}=t;return!(!e||!i?.sourceLayer||!y(i?.sourceLayer)&&!W(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const t=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=t?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=t?.associationId||null!=t?.associatedLayer}get hasUpdatableCandidates(){const{candidates:t,viewModel:e}=this.data;return t.some(({layer:t})=>j(e.editorItems,t)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some(t=>t.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(t=()=>Promise.resolve(!0)){const{activeWorkflow:e}=this,i=e?.featureFormViewModel;if(i?.activeRelationshipInput){const t=i.activeRelationshipInput;if(t.activeCategory)return void(t.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(t.showAllEnabled)return void(t.showAllEnabled=!1)}if("add-association"===e?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:t}=this;if(t?.filterOptionsVisible)return void(t.filterOptionsVisible=!1);t?.featureSpatialItems.length&&t.reset()}if(null==i?.associatedLayer)if(null==i?.associationId)if("create-features"===e?.type&&e.hasPreviousStep)await e.previous({cancelCurrentStep:!0});else{if(P(e)&&e.hasPreviousStep)return await e.back();if(e){if(e.hasPendingEdits&&!i?.disabled){if(!await t())return}e.hasPreviousStep?await e.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}else i.associationId=null;else i.associatedLayer=null}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(t=>t.commit()),await super.commit()}static create(t){const{startAt:e,applyEdits:i,applyEditsFeatureService:a,...o}=t,r=new q({data:new V({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,e)),r}async save(){const{activeFeatureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable||t.pendingSubtypeChoice)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:e}=this;if(await(e?.commit()),!P(e))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===e?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(t){try{const e=this._createNestedCreateFeaturesWorkflow(t);await this._pushWorkflowAndReconcile(e)}catch(e){throw new i("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:e})}}async startSplittingFeature(t,e){try{const i=await this._createNestedSplitFeatureWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(a){throw new i("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}}async startUpdating(t,e){try{const i=await this._createNestedUpdateWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(a){throw new i("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async startAddAssociation(t,e,a){try{const i=await this._createNestedAddAssociationWorkflow(t,e,a);await this._pushWorkflowAndReconcile(i)}catch(o){throw new i("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new i("editor:nothing-to-delete","There is no feature to delete");const e=L(t);e?(t.stageDelete(),t.data.edits.feature===this.data.rootFeature&&this._removeRootFeatureFromCandidates()):await t.cancel(),this.nestedWorkflowCount<2?e?await this.commit():await this.cancel({force:!0}):(e&&await t.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new i("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(t=>t.cancel({force:!0}))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:t,data:e}=this,{activeAssociation:a,feature:o}=t,{applyEditsFeatureServiceCallback:r,viewModel:s}=e,{sourceLayer:n}=o,l=W(n)&&n.parent?n.parent:n,d=b([l]),c=d.values().next().value?.featureService;if(!c)throw new i("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=N(p,l);await(u?.networkSystemLayers.loadAssociationsTable());const w=u?.generateDeleteAssociations([a]);if(!w)throw new i("editor:failed-to-delete-association","Could not create payload needed to delete association");const h=u?.gdbVersion??void 0;await r(c,[w],{gdbVersion:h,globalIdUsed:!0})}_removeRootFeatureFromCandidates(){const{candidates:t,rootFeature:e}=this.data;if(0===t.length||!e)return;const i=t.indexOf(e);i>-1&&t.splice(i,1)}async _returnToPageWithContent(){const{activeFeatureFormViewModel:t}=this;if(!t?.activeAssociationInput)return;const{activeAssociationInput:e,associationId:i}=t;await e.refresh(),e.associatedLayer&&!e.associatedFeatures?.length&&(t.associatedLayer=null),null==i||e.associatedFeatureInfos.size||(t.associationId=null)}_createNestedCreateFeaturesWorkflow(t){const{relatedLayer:e}=t,{addAttachmentsCallback:a,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!m(e))throw new i("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(t),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=O(this.activeWorkflow)?this.activeWorkflow:void 0;return M.create({addAttachmentsCallback:a,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(t){const{relatedLayer:a}=t;if(!m(a)||A(a))throw new i("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:a,maxFeatures:1},s=this._makeRelatedRecordAttributes(t),n=o.getTemplatesForLayer(a);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new e({sourceLayer:a,attributes:s}),r}async _createNestedUpdateWorkflow(t,e={}){const i=_(t.sourceLayer)?R:E,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=O(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:t,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async t=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(t)),editRelatedRecord:async({relatedFeature:t,readOnly:e})=>await this._updatingHandles.addPromise(this.startUpdating(t,{readOnly:e})),selectAssociatedFeature:async({feature:t,association:e})=>await this._updatingHandles.addPromise(this.startUpdating(t,{association:e})),addAssociation:async t=>await this._updatingHandles.addPromise(this.startAddAssociation(t.feature,t.utilityNetwork,t.associationType))},...e});return await u(()=>!d.updating),d}async _createNestedAddAssociationWorkflow(t,e,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n=O(this.activeWorkflow)?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await a.create({utilityNetwork:e,associationType:i,feature:t,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u(()=>!d.updating),d}async _createNestedSplitFeatureWorkflow(t,e){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,sketchOptions:o,snappingManager:r,viewModel:s}=this.data,n=O(this.activeWorkflow)?this.activeWorkflow:void 0,l=x(s.editorItems,t.sourceLayer),d=I.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:t,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...e});return await u(()=>!d.updating),d}async _drainWorkflowStack(t){const e=this._workflowStack,i=[];for(const a of e){const e=t(a).finally(()=>a.destroy());this._updatingHandles.addPromise(e),i.push(e)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeRelatedRecordAttributes(t){const{parentFeature:e,relatedLayer:i,relationshipId:a}=t;if(!D(e))return;const o=i.relationships?.find(t=>t.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=e.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(t=>t.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=z(r,s),l=e.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=z(i,o);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new i("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflowAndReconcile(t){const e=this._workflowRequiresSketchViewModel(t);this.activeWorkflow?.exit({removeSketchHandles:e});const a=this._sketchStack,o=await(t?.start()),r=a.peek();o?(r?.exit(),a.push(o)):a.push(this._cloneSketchController(r)),this._workflowStack.push(t);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new i("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const t=this._workflowStack,e=this._sketchStack;try{const i=t.peek();return await(i?.enter()),await(e.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){t.pop().destroy(),e.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:o+1}}}_cloneSketchController(t){return{enter:t?.enter??(async()=>{}),exit:t?.exit??(async()=>{}),viewModel:t?.viewModel}}_workflowRequiresSketchViewModel(t){const{type:e}=t;return"update-feature"===e||"create-features"===e&&!_(t.data.creationInfo?.layer)}static _createWorkflowSteps(t,e="awaiting-feature-to-update"){const{data:o}=t;return T(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],e,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=o.viewModel,i=o.viewModel.view;i.activeTool=null;let s=null;t.addHandles(a(()=>{s=r(s)}),this.id),o.rootFeature=null,o.candidates=[];const p=i.on("immediate-click",async a=>{const r=n();t._updatingHandles.addPromise(r.promise);try{e.location=a.mapPoint,e.visible=!0,s?.abort();const{editorItems:r}=o.viewModel;s=new AbortController;const n=await a.defer(()=>new Promise((t,e)=>{l(s?.signal,()=>e(d())),t(H(r,i,a,s?.signal))}));if(c(s),o.candidates=n.filter(t=>"fulfilled"===t.status).flatMap(t=>t.value).filter(t=>!t.isAggregate),e.visible=1===o.candidates.length,0===o.candidates.length)return;a.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],t.go("editing-existing-feature").catch(()=>{}).then(()=>e.visible=!1)):t.next()}finally{r.resolve()}},F.TOOL),u=f(()=>null!=i.activeTool,()=>t.cancel({force:!0}),{once:!0});i.focus(),t.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),t.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:e}=o.viewModel;if(!e)return;const i=new C({view:e,highlightName:S});t.addHandles([w(()=>o.rootFeature,(t,e)=>{i.remove(e),i.add(t)},h),a(()=>i.removeAll())],this.id)},async tearDown(){t.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{data:e}=t,{rootFeature:a}=e;if(!a)throw new i("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");"split"===e.rootWorkflowOptions?.type?await t.startSplittingFeature(a,e.rootWorkflowOptions.props):await t.startUpdating(a),e.viewModel.spinnerViewModel.visible=!1;const o=s(async()=>{await u(()=>!t.updating),t.previous()});t.addHandles([w(()=>t.nestedWorkflowCount,(t,e)=>{0===t&&0!==e&&o()},h)],this.id)},async tearDown(){await t.cancelAll(),t.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(t,e){o.getLogger(this).warn(`editor:${t}`,e,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function z(t,{keyField:e}){return t.getField(e)?.name??e}t([v()],G.prototype,"activeEditorItem",null),t([v()],G.prototype,"activeFeatureFormViewModel",null),t([v()],G.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),t([v()],G.prototype,"activeSketchViewModel",null),t([v()],G.prototype,"canDeleteAssociation",null),t([v()],G.prototype,"activeWorkflow",null),t([v()],G.prototype,"updating",null),t([v()],G.prototype,"data",void 0),t([v()],G.prototype,"hasPreviousStep",null),t([v()],G.prototype,"hasUpdatableCandidates",null),t([v()],G.prototype,"nestedWorkflowCount",null),t([v()],G.prototype,"shouldShowAttachments",null),t([v()],G.prototype,"shouldAllowAttachmentEditing",null),t([v()],G.prototype,"hasPendingEdits",null),t([v()],G.prototype,"helpMessage",null),t([v()],G.prototype,"reliesOnOwnerAdminPrivileges",null),t([v()],G.prototype,"hasInvalidFormTemplate",null),G=q=t([k("esri.widgets.Editor.UpdateWorkflow")],G);const Q=G;export{Q as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e 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{debounce as n,createResolver 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 F}from"../../rest/featureService/utils.js";import M from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import U 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,featuresToFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as tt,isGraphicForRelatableFeatureSupportedLayer as et}from"../Feature/support/featureUtils.js";var it;let at=it=class extends O{constructor(t){super(t),this._workflowStack=new u(k),this._sketchStack=new u(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(t=>t.cancel({force:!0}))}get activeFormViewModel(){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{activeFormViewModel:t}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(t))return!1;const{activeAssociation:e,feature:i}=t;return!(!e||!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 t=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(t)&&(null!=t.relationshipId||null!=t.associationId||null!=t.associatedLayer)}get hasUpdatableCandidates(){const{candidates:t,viewModel:e}=this.data;return t.some(({layer:t})=>x(e.editorItems,t)?.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(t=>t.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(t=()=>Promise.resolve(!0)){const{activeWorkflow:e}=this,i=e?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const t=i.activeRelationshipInput;if(t.activeCategory)return void(t.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(t.showAllEnabled)return void(t.showAllEnabled=!1)}if("add-association"===e?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:t}=this;if(t?.filterOptionsVisible)return void(t.filterOptionsVisible=!1);t?.featureSpatialItems.length&&t.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===e?.type&&e.hasPreviousStep)await e.previous({cancelCurrentStep:!0});else{if(H(e)&&e.hasPreviousStep)return await e.back();if(e){if(e.hasPendingEdits&&!i?.disabled){if(!await t())return}e.hasPreviousStep?await e.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(t=>t.commit()),await super.commit()}static create(t){const{startAt:e,applyEdits:i,applyEditsFeatureService:a,...o}=t,r=new it({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,e)),r}async save(){const{activeFormViewModel:t}=this;if(t&&(t.submit(),!t.submittable||T(t)&&rt(t)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:e}=this;if(await(e?.commit()),!D(e))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===e?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(t){try{const e=this._createNestedCreateFeaturesWorkflow(t);await this._pushWorkflowAndReconcile(e)}catch(e){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:e})}}async startMergingFeatures(t,e){try{const i=await this._createNestedMergeFeaturesWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:i})}}async startSplittingFeature(t,e){try{const i=await this._createNestedSplitFeatureWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:i})}}async startUpdatingSingle(t,e){try{const i=await this._createNestedUpdateWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async startUpdatingMultiple(t,e){try{const i=await this._createNestedUpdateFeaturesWorkflow(t,e);await this._pushWorkflowAndReconcile(i)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:i})}}async startAddAssociation(t,e,i){try{const a=await this._createNestedAddAssociationWorkflow(t,e,i);await this._pushWorkflowAndReconcile(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeatures(){const{activeWorkflow:t}=this;if(!t)throw new a("editor:nothing-to-delete","There is no feature to delete");const e=q(t);if(e){t.data.stageDelete();const e=z(t)?t.data.edits.feature?[t.data.edits.feature]:[]:t.data.features;this._removeFeaturesFromCandidates(e)}else await t.cancel();this.nestedWorkflowCount<2?e?await this.commit():await this.cancel({force:!0}):(e&&await t.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(t=>t.cancel({force:!0}))}async _deleteActiveAssociation(){const{activeFormViewModel:t}=this;if(!T(t))throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:e,feature:i}=t,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=F([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=tt(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([e]);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(t){const{candidates:e}=this.data;if(0!==e.length&&0!==t.length)for(const a of t)i(e,a)}async _returnToPageWithContent(){const{activeFormViewModel:t}=this;if(!T(t)||!t?.activeAssociationInput)return;const{activeAssociationInput:e,associationId:i}=t;await e.refresh(),e.associatedLayer&&!e.associatedFeatures?.length&&(t.associatedLayer=null),null==i||e.associatedFeatureInfos.size||(t.associationId=null)}_createNestedCreateFeaturesWorkflow(t){const{relatedLayer:e}=t,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(e))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(t),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return U.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(t){const{relatedLayer:i}=t;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(t),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new e({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(t,e={}){const i=C(t.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:t,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async t=>await this._updatingHandles.addPromise(this.startCreatingRelatedRecord(t)),editRelatedRecord:async({relatedFeature:t,readOnly:e})=>await this._updatingHandles.addPromise(this.startUpdatingSingle(t,{readOnly:e})),selectAssociatedFeature:async({feature:t,association:e})=>await this._updatingHandles.addPromise(this.startUpdatingSingle(t,{association:e})),addAssociation:async t=>await this._updatingHandles.addPromise(this.startAddAssociation(t.feature,t.utilityNetwork,t.associationType))},...e});return await w(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(t,e={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:a,featureInfos:t,viewModel:o,...e});return await w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(t,e,i){const{AddAssociationWorkflow:o}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{activeFormViewModel: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:e,associationType:i,feature:t,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(t,e){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(t);const r=Q(this.data.viewModel.editorItems,W(t[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:t,parent:s,viewModel:o,...e});return await w(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(t,e){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,t.sourceLayer),d=j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:t,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...e});return await w(()=>!d.updating),d}async _drainWorkflowStack(t){const e=this._workflowStack,i=[];for(const a of e){const e=t(a).finally(()=>a.destroy());this._updatingHandles.addPromise(e),i.push(e)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeRelatedRecordAttributes(t){const{parentFeature:e,relatedLayer:i,relationshipId:a}=t;if(!et(e))return;const o=i.relationships?.find(t=>t.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=e.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(t=>t.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=ot(r,s),l=e.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=ot(i,o);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflowAndReconcile(t){const e=this._workflowRequiresSketchViewModel(t);this.activeWorkflow?.exit({removeSketchHandles:e});const i=this._sketchStack,o=await(t?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(t);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 t=this._workflowStack,e=this._sketchStack;try{const i=t.peek();return await(i?.enter()),await(e.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){t.pop().destroy(),e.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:o+1}}}_cloneSketchController(t){return{enter:t?.enter??(async()=>{}),exit:t?.exit??(async()=>{}),viewModel:t?.viewModel}}_workflowRequiresSketchViewModel(t){const{type:e}=t;return"update-feature"===e||"create-features"===e&&!C(t.data.creationInfo?.layer)}static _createWorkflowSteps(t,e="awaiting-feature-to-update"){const{data:i}=t;return $(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],e,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=i.viewModel,a=i.viewModel.view;a.activeTool=null;let r=null;t.addHandles(o(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const n=a.on("immediate-click",async o=>{const s=l();t._updatingHandles.addPromise(s.promise);try{e.location=o.mapPoint,e.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await o.defer(()=>new Promise((t,e)=>{d(r?.signal,()=>e(c())),t(B(s,a,o,r?.signal))}));if(p(r),i.candidates=n.filter(t=>"fulfilled"===t.status).flatMap(t=>t.value).filter(t=>!t.isAggregate),e.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]),t.go("editing-existing-feature").catch(()=>{}).then(()=>e.visible=!1)}else t.next()}finally{s.resolve()}},E.TOOL),u=v(()=>null!=a.activeTool,()=>t.cancel({force:!0}),{once:!0});a.focus(),t.addHandles([n,u],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),t.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:e}=i.viewModel;if(!e)return;const a=new M({view:e,highlightName:I});t.addHandles([g(()=>i.rootFeatures,"change",({added:t,removed:e})=>{e.forEach(t=>a.remove(t)),t.forEach(t=>a.add(t))},f),o(()=>a.removeAll())],this.id)},async tearDown(){t.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await st(t);const{data:e}=t;e.viewModel.spinnerViewModel.visible=!1;const i=n(async()=>{await w(()=>!t.updating),t.previous()});t.addHandles([h(()=>t.nestedWorkflowCount,(t,e)=>{0===t&&0!==e&&i()},f)],this.id)},async tearDown(){await t.cancelAll(),t.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(t,e){r.getLogger(this).warn(`editor:${t}`,e,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function ot(t,{keyField:e}){return t.getField(e)?.name??e}function rt(t){if(t.pendingSubtypeChoice)return!0;const e=t.getValues();return t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0}async function st(t){const{data:e}=t,{rootWorkflowOptions:i}=e;if(J(i)){const{rootFeatureInfos:o}=e,r=o.length>0?o:K(e.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 t.startUpdatingMultiple(r,i.props)}const{rootFeatures:o}=e,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 t.startMergingFeatures(o.toArray(),i.props):Y(i)?await t.startSplittingFeature(r,i.props):await t.startUpdatingSingle(r)}t([m()],at.prototype,"activeFormViewModel",null),t([m()],at.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),t([m()],at.prototype,"activeSketchViewModel",null),t([m()],at.prototype,"canDeleteAssociation",null),t([m()],at.prototype,"activeWorkflow",null),t([m()],at.prototype,"updating",null),t([m()],at.prototype,"data",void 0),t([m()],at.prototype,"hasPreviousStep",null),t([m()],at.prototype,"hasUpdatableCandidates",null),t([m()],at.prototype,"nestedWorkflowCount",null),t([m()],at.prototype,"shouldShowAttachments",null),t([m()],at.prototype,"shouldAllowAttachmentEditing",null),t([m()],at.prototype,"hasPendingEdits",null),t([m()],at.prototype,"helpMessage",null),t([m()],at.prototype,"reliesOnOwnerAdminPrivileges",null),t([m()],at.prototype,"hasInvalidFormTemplate",null),at=it=t([y("esri.widgets.Editor.UpdateWorkflow")],at);const nt=at;export{nt 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
|
|
5
|
+
import{__decorate as o}from"tslib";import t from"../../core/Accessor.js";import e from"../../core/Collection.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../views/interactive/sketch/SketchOptions.js";let i=class extends t{constructor(o){super(o),this.addAttachmentsCallback=null,this.applyEditsCallback=null,this.applyEditsFeatureServiceCallback=null,this.candidates=[],this.rootFeatures=new e,this.rootFeatureInfos=[],this.rootWorkflowOptions={type:"update-single"},this.sketchOptions=new p,this.snappingManager=null,this.viewModel=null}};o([r()],i.prototype,"addAttachmentsCallback",void 0),o([r()],i.prototype,"applyEditsCallback",void 0),o([r()],i.prototype,"applyEditsFeatureServiceCallback",void 0),o([r()],i.prototype,"candidates",void 0),o([r()],i.prototype,"rootFeatures",void 0),o([r()],i.prototype,"rootFeatureInfos",void 0),o([r()],i.prototype,"rootWorkflowOptions",void 0),o([r({constructOnly:!0})],i.prototype,"sketchOptions",void 0),o([r()],i.prototype,"snappingManager",void 0),o([r()],i.prototype,"viewModel",void 0),i=o([s("esri.widgets.Editor.UpdateWorkflowData")],i);const a=i;export{a 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/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as o,watch as r}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import c from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as h,updateGraphicSymbolWhenRequired as u,setVisualVariablesAndElevationInfoForUpdate as y,swapForEditingSession as m,visualVariableInteractiveUpdate as v,getSizeVariableAttribute as g,getRotationVariableAttribute as w}from"../workflowUtils.js";import _ from"../../Sketch/SketchViewModel.js";const b=Symbol();let f=class extends t{constructor(e){super(e),this.features=[],this.onGeometriesUpdated=()=>{},this.onVisualVariableAttributesUpdated=()=>{},this.sketchOptions=new c,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._nextUpdateSubset=[],this._sketchGraphicsMap=new Map,this._sketchLayer=null,this._updatingHandles=new p,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=h(this.sourceLayer),this._nextUpdateSubset=this.features,this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){await this.startUpdatingFeatures(this._nextUpdateSubset)}async exit(){this._completeCurrentOperation()}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const o of e){const e=this._sketchGraphicsMap.get(o),r=o.getAttribute(t);if(!e||e.getAttribute(t)===r)continue;e.setAttribute(t,r);const n=this._visualVariableAttributes.get(o);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(r),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(r),a.addPromise(u(e,i,s))}}async startUpdatingFeatures(e){const{onGeometriesUpdated:t,onVisualVariableAttributesUpdated:a,_sketchGraphicsMap:r,_sketchLayer:n,sourceLayer:l,view:p,viewModel:d,_webStyleCache:c}=this,h=e.map(e=>r.get(e)).filter(i),m={};this._completeCurrentOperation();let g=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await y({graphic:h[0],sketchLayer:n,sketchViewModel:d,sourceLayer:l,visualVariables:i,webStyleCache:c}),"point"===l.geometryType&&(m.enableRotation=null!=i.rotation,m.enableScaling=null!=i.size,g=async e=>{const s=e.graphics[0];v(p,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(u(s,c,"2d"===p.type?p.scale:null)))}))}else m.tool="move";const w=()=>d.update(h,m),_=d.on("update",a=>{if("complete"===a.state){if(null===p.activeTool)return void w();const e=new AbortController,t=s(e);return this.addHandles(t,b),void this._updatingHandles.addPromise(o(()=>null===p.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await w())}))}const n=e.map(e=>{const t=r.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),g?.(a)});await w(),this._nextUpdateSubset=this.features,this.addHandles(_,b),d.addHandles(_)}_completeCurrentOperation(){this.removeHandles(b),this.viewModel.complete()}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,o=a.rotation?.field,r=a.size?.field,n={rotation:o?i.getField(o):null,size:r?i.getField(r):null},l=!(!n.rotation&&!n.size);for(const p of e)t.set(p,p.clone()),l&&s.set(p,k(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphicsMap:e,_sketchLayer:t,view:i,_webStyleCache:s}=this,o=Array.from(e.entries()),n=new _({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:t,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:i});this.viewModel=n;const l=a(e=>Promise.all(o.map(([,t])=>u(t,s,e))));await l("2d"===i.type?i.scale:null),"2d"===i.type&&this.addHandles(r(()=>i.scale,e=>l(e))),this.addHandles(await Promise.all(o.map(([e,s])=>m(t,i,e,s))))}};function k({rotation:e,size:t},i){return{rotation:e?w(e,i.rotation):null,size:t?g(t,i.size):null}}e([n()],f.prototype,"features",void 0),e([n()],f.prototype,"onGeometriesUpdated",void 0),e([n()],f.prototype,"onVisualVariableAttributesUpdated",void 0),e([n()],f.prototype,"sketchOptions",void 0),e([n()],f.prototype,"snappingManager",void 0),e([n()],f.prototype,"sourceLayer",void 0),e([n()],f.prototype,"updating",null),e([n()],f.prototype,"view",void 0),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"_nextUpdateSubset",void 0),e([n()],f.prototype,"_sketchGraphicsMap",void 0),e([n()],f.prototype,"_sketchLayer",void 0),e([n()],f.prototype,"_visualVariablesForLayer",void 0),f=e([l("esri.widgets.Editor.support.SketchController")],f);export{f as SketchController};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{unique as e}from"../../../core/arrayUtils.js";import t from"../../../core/Error.js";import{getGraphicLayer as r}from"../../../graphic/graphicOriginUtils.js";class s extends t{constructor(e=!1){super("editing:fetch-feature",`Failed to fetch the full ${e?"features":"feature"} from the service.`)}}class o extends t{constructor(e){super("editing:not-enough-features",`At least ${e} ${1===e?"feature is":"features are"} required to perform this operation.`)}}class a extends t{constructor(){super("editing:invalid-argument","Key feature must be one of the features being merged")}}class i extends t{constructor(){super("editing:multiple-layers-not-supported","Features must belong to the same layer.")}}class n extends t{constructor(){super("editing:layer-required","The feature must be associated with a layer to start a split feature workflow.")}}function u(t){if(e(t.map(e=>r(e))).length>1)throw new i}function c(e,t){if(e.length<t)throw new o(t)}export{s as FetchFullFeatureError,o as InsufficientFeatureCountError,a as InvalidKeyFeatureError,n as MissingOriginLayerError,i as MultipleSourceLayersError,u as assertFeaturesAreFromSameLayer,c as assertMinimumFeatureCount};
|
|
@@ -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 e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import d from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as I}from"../../core/screenUtils.js";import{addMany as v}from"../../core/SetUtils.js";import{diff as T}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as F,isSharedTemplate as k,isSharedPresetTemplate as j,isStandardFeatureTemplate as A,isSharedFeatureTemplate as L}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as M,fixFields as O,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as q}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as E}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import D from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as W}from"../../undoredo/support/Services.js";import{GraphicState as Z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as J,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>d.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return!!e&&"features"in e}function ee(e){return null!=e&&"create-features"===e.type}function te(e){return null!=e&&"update-features"===e.type}function re(e){return null!=e&&"update-feature"===e.type}function ne(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function oe(e){return null!=e&&"update"===e.type}function ae(e){return null!=e&&"split-feature"===e.type}function ie(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"split-feature"===t}function se(e){const t=e&&"renderer"in e?e.renderer:null;if(!ye(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===C(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function le(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ye(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=se(t);let o=null,a=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=ce(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=pe(n,r)}return{rotation:o,size:a}}function ce(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,fe((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ue(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function de(e,t,r){if(null==t)return 0;const{symbol:n}=B(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(rt.icon,(await e(o,rt.icon))[0])||rt.icon}case"text":return rt.text;case"line":return rt.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ue(await t(o,e.scale/rt.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/rt.viewScaleSizeFactor;default:return 0}}function pe(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},a=E[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*a/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*a/2:e=>e*a,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>fe(i(await de(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,fe(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:at(e.valueUnit),axis:e.axis}}function fe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ye(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function me(e,t,r){const n=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function he(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:Q,optionsPerTool:r};if(S(t)){const o=t.defaultTool,a=F(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function ge(e,t,r,n){const{creationInfo:o,fullTemplate:a}=r;if(!o)throw new i("featureworkflow","No creation info provided.");const s=o.layer,l=ze(a,o.attributeOverrides),{view:c}=e,u="2d"===c?.type;F(a)||j(a)||await Ee(e,s,l,n,u?c.scale:null);const{capabilities:d}=s;t.elevationInfo=s.elevationInfo;const p=he(s.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:l,sourceLayer:s},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:d.data.supportsZ,defaultZ:(u?d.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==o.geometryToPlace?await e.create(p.tool):await e.place(o.geometryToPlace,{graphicProperties:{attributes:l,sourceLayer:s}})}async function be(e){return s([we(e),Ie(e)])}function we({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:a}=t,{fullTemplate:i}=t;if(!a||"2d"!==n?.type||F(i)||j(i))return null;const s=f(t=>Ee(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ie({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!X(a))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:d}=o,p=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>a,["cursor-update","vertex-add"],()=>{c.removeAll();const e=a.graphic?.geometry;if(!e||!ve(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=d.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=Te(e,p);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function ve(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function Te(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new G({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new D({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function Se(e,t){const r=await W(t).load(),n=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function Fe(e,t){const r=await Se(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)p(n,o.layerId,()=>[]).push(o);return n}function ke(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function je(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=Ae(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ue(t,i,a),d=Ve(l,Le(s,c),c);if(o&&xe(l,d,o),0===d.length)return t;const p=K(d,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of p)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of p){const{layer:e}=r;switch(null==h?h=ke(e):h.id!==e.layerId&&(m.push(h),h=ke(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??ke(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Ae(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Le(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Me(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Me(n,e),t.keyField);break}}return r}function Ue(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function Ve(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:a}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Me(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([a,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,a]):t.before.attributes[c]===o.after.attributes[e]&&n.push([a,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,a]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):n.push([r,a]):n.push([a,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,a]))}}}}return n}function Me(e,t){return`${e.layerId}:${t.id}`}function Oe(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function xe(e,t,r){const n=[];for(const a of e)Oe(a.layer,r)&&n.push(a);if(0===n.length)return;let o=[];for(const a of n){const r=a.layer;switch(a.operationType){case"delete":o=[...qe(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...qe(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...qe(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...qe(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function qe(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function ze(e,t={}){return F(e)||j(e)?{}:A(e)?{...e.prototype.attributes,...t}:L(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ee(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=le(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:o,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:o,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Pe(e.tooltipOptions,l,s)}function Pe(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Ce(e,t){return e.find(e=>e.layer===t)}function De(e,t){const r=Ce(e,t);if(null==r)throw new i("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function Re(e,t){return e?.find(e=>e.layer===t)}async function Ge(e,t,r,n){switch(t.type){case"3d":return Be(e,t,r,n);case"2d":return Ne(e,t,r,n)}}async function Be(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(H(t,r),n),a=new Map,i=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};J(o).forEach(({graphic:e})=>i(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return h(Promise.allSettled(a.map(async({layer:e})=>{const t=i.get(e),r=We(e);if(t.every(e=>M(e,r)))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=O(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ne(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let a=null;const i=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const i=new Set;a=J(o),a.forEach(({graphic:e})=>e&&i.add(e.layer));const s=e.filter(e=>i.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(i.map(async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=We(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return a?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function We(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ze(e,t,n,o){return Qe(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function Qe(e,t,r,n){const o=t.createQuery();o.objectIds=e,o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=r);const a=await t.queryFeatures(o,{signal:n});return m(n),a.features}async function $e(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await Je(e);const a={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(a.enableRotation=null!=o.rotation,a.enableScaling=null!=o.size),r.update(t,a)}async function Je(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:a,webStyleCache:i}=e;let s=!1;const{rotation:l,size:c}=a;for(const u of[l,c]){if(null==u)continue;const e=t.getAttribute(u.field);if(null!=e)u.setInitialValue(e);else{const e=await u.getDefaultValue(t.symbol,n.view);u.setInitialValue(e),t.setAttribute(u.field,e),s=!0}}if(s){const e="2d"===n.view?.type?n.view.scale:null;await me(t,i,e)}Pe(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function He(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ke(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function Xe(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let a=!1;const i=n.rotation,s=He(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),a=!0}}const l=n.size,c=Ke(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==o[r]&&t.setAttribute(r,i),a=!0}}return a}async function Ye({feature:e,featureClone:t,visualVariableAttributes:r,sketchLayer:n,sketchViewModel:o,view:a,onUpdate:i,webStyleCache:u,addUpdatingPromise:d,addHandle:p}){await me(t,u,"2d"===a.type?a.scale:null);let y=null;if("2d"===o?.view?.type){const e=f(e=>me(t,u,e));y=g(()=>o?.view?.scale,t=>e(t))}const m=t.sourceLayer,h=lt(a,m);await $e({graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u});let b=null;h.then(e=>b=e).catch(()=>{});const I=r.size,v=r.rotation,T=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==I||I.isUpdatingInteractively||I.field!==n||I.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),(null==b||b.requiredFields.includes(n))&&(r=!0))}r&&await me(t,u,"2d"===a.type?a.scale:null)}),S=o.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u};if("complete"===e.state){if(null===a.activeTool)return $e(s);const e=new AbortController,t=c(e);return p(t),d(w(()=>null===a.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),$e(s)}))}Xe(a,t,e,r)&&await me(t,u,"2d"===a.type?a.scale:null),i(ut(t),e)}),F=o.on(["undo","redo"],e=>{i(ut(e.graphics[0]),e)});return s([F,S,l(()=>o.cancel()),T,y])}async function _e(e,t,r,n){e.add(n);const o=r.sourceLayer,i=r.getAttribute(o.objectIdField);let c=null;function u(e){c?.abort(),c=a(async r=>{const n=await lt(t,o);m(r),n.setVisibility?.(i,e)})}return await tt(t,n),u(!1),s([et(t,n,e=>u(!e)),l(async()=>{u(!0);try{if(!t.destroyed){const e=await lt(t,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}function et(e,t,r){if("3d"===e.type){const n=new Z({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function tt(e,t){if("3d"===e.type){const r=new Z({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const rt={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function nt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function ot(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function at(e){return"unknown"===e?null:e}function it(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const st=e=>e.includes("-stop")||e.includes("vertex-"),lt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ct(e){return"createInteractiveEditSession"in e}function ut(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function dt(e){return e.acquireCursor("progress")}async function pt(e,t){const{template:r}=e;if(null==r)return null;if(k(r))return r.load();if(S(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function ft(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function yt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>ft(e.relationships)),t.flatMap(e=>e.edits)):null}function mt(e){if(null==e)return[];if(te(e))return e.data.layers;const t=oe(e)?e.activeWorkflow:e,r=t?.layer;return r?[r]:[]}function ht(){return new i("editing:multiple-layers-not-supported","UpdateFeaturesWorkflow does not support updating features from multiple layers.")}function gt({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&v(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function bt(e){if(!e.supportsMergeFeaturesWorkflow)throw new i("editing:unsupported-workflow","Merge features workflow requires that deleting features and updating their geometries are allowed.")}function wt(e){if(!e.supportsSplitFeatureWorkflow)throw new i("editing:unsupported-workflow","Split feature workflow requires that both creating features and updating their geometries are allowed.")}function It(e){const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;p(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}export{xe as appendAllUtilityNetworkAssociationRelationships,bt as assertMergeWorkflowCapabilities,wt as assertSplitWorkflowCapabilities,ot as avoidFeatureTemplateSelectionWithOnlyOneItem,ct as canCreateInteractiveEditSession,ut as cloneGraphicExceptMesh,Ae as createLayerIdMap,Le as createRelationshipKeyMap,he as createToolFromGeometryType,nt as createWorkflowSteps,It as featuresToFeatureInfos,Ge as fetchCandidates,Ze as fetchFullFeatures,Qe as fetchFullFeaturesByObjectId,Ve as findAllDependencies,qe as findChangesByGlobalId,Ce as findEditorItemForLayer,De as findEditorItemForLayerOrThrow,Re as findLayerInfo,Me as generateHashForRelationship,ze as getCreationAttributes,pt as getFullTemplateForCreationInfo,mt as getLayersFromWorkflow,ce as getRotationVariableAttribute,yt as getServiceEditsFromWorkflowData,Se as getServiceInfoForLayer,Fe as getServiceLayersById,pe as getSizeVariableAttribute,le as getVisualVariableAttributes,se as getVisualVariablesForLayer,_ as isBatchAttributeFormViewModel,ee as isCreateFeaturesWorkflow,ie as isParentWorkflow,ae as isSplitFeatureWorkflow,st as isTerminalUpdateEventType,re as isUpdateFeatureWorkflow,te as isUpdateFeaturesWorkflow,ne as isUpdateRecordWorkflow,oe as isUpdateWorkflow,Oe as isUtilityNetworkAssociationsTable,gt as makeMinimalAttributes,ht as makeMultipleSourceLayersError,je as orderEditsByRelationshipDependencies,it as prepareAttachmentsForCreateFeaturesWorkflow,ft as setRelationshipFields,Ye as setUpGeometryUpdate,be as setUpSketchCreateWatchers,Je as setVisualVariablesAndElevationInfoForUpdate,dt as showProgressCursor,rt as sizeDefaults,at as sizeVariableUnitToLengthUnit,ge as startCreatingNewFeature,$e as startUpdatingFeatureGeometry,_e as swapForEditingSession,me as updateGraphicSymbolWhenRequired,Xe as visualVariableInteractiveUpdate,lt as whenEditorLayerView,tt as whenGraphicDisplayed};
|
|
5
|
+
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import d from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as I}from"../../core/screenUtils.js";import{addMany as v}from"../../core/SetUtils.js";import{diff as T}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as F,isSharedTemplate as j,isSharedPresetTemplate as k,isStandardFeatureTemplate as A,isSharedFeatureTemplate as L}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as M,fixFields as O,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as q}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as E}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import D from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as J,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>d.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return ae(e)||ne(e)}function ee(e){return!!e&&"features"in e}function te(e){return null!=e&&"create-features"===e.type}function re(e){return!!e&&"feature"in e}function ne(e){return null!=e&&"update-features"===e.type}function oe(e){return null!=e&&"update-feature"===e.type}function ae(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function ie(e){return null!=e&&"update"===e.type}function se(e){return null!=e&&"merge-features"===e.type}function le(e){return null!=e&&"split-feature"===e.type}function ce(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function ue(e){return"merge"===e?.type}function de(e){return"split"===e?.type}function pe(e){return se(e)||le(e)}function fe(e){return"update-multiple"===e?.type}function ye(e){const t=e&&"renderer"in e?e.renderer:null;if(!ve(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===C(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function me(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ve(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ye(t);let o=null,a=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=he(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=we(n,r)}return{rotation:o,size:a}}function he(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,Ie((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ge(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function be(e,t,r){if(null==t)return 0;const{symbol:n}=B(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(ct.icon,(await e(o,ct.icon))[0])||ct.icon}case"text":return ct.text;case"line":return ct.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ge(await t(o,e.scale/ct.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/ct.viewScaleSizeFactor;default:return 0}}function we(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},a=E[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*a/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*a/2:e=>e*a,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>Ie(i(await be(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Ie(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:pt(e.valueUnit),axis:e.axis}}function Ie(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ve(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Te(e,t,r){const n=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function Se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:Q,optionsPerTool:r};if(S(t)){const o=t.defaultTool,a=F(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function Fe(e,t,r,n){const{creationInfo:o,fullTemplate:a}=r;if(!o)throw new i("featureworkflow","No creation info provided.");const s=o.layer,l=Be(a,o.attributeOverrides),{view:c}=e,u="2d"===c?.type;F(a)||k(a)||await Ne(e,s,l,n,u?c.scale:null);const{capabilities:d}=s;t.elevationInfo=s.elevationInfo;const p=Se(s.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:l,sourceLayer:s},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:d.data.supportsZ,defaultZ:(u?d.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==o.geometryToPlace?await e.create(p.tool):await e.place(o.geometryToPlace,{graphicProperties:{attributes:l,sourceLayer:s}})}async function je(e){return s([ke(e),Ae(e)])}function ke({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:a}=t,{fullTemplate:i}=t;if(!a||"2d"!==n?.type||F(i)||k(i))return null;const s=f(t=>Ne(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ae({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!X(a))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:d}=o,p=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>a,["cursor-update","vertex-add"],()=>{c.removeAll();const e=a.graphic?.geometry;if(!e||!Le(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=d.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=Ue(e,p);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function Le(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function Ue(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new G({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new D({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function Ve(e,t){const r=await Z(t).load(),n=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function Me(e,t){const r=await Ve(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)p(n,o.layerId,()=>[]).push(o);return n}function Oe(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function xe(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=qe(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ee(t,i,a),d=Pe(l,ze(s,c),c);if(o&&Re(l,d,o),0===d.length)return t;const p=K(d,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of p)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of p){const{layer:e}=r;switch(null==h?h=Oe(e):h.id!==e.layerId&&(m.push(h),h=Oe(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??Oe(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function qe(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function ze(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Ce(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Ce(n,e),t.keyField);break}}return r}function Ee(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function Pe(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:a}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Ce(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([a,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,a]):t.before.attributes[c]===o.after.attributes[e]&&n.push([a,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,a]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([a,r]):n.push([r,a]):n.push([a,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,a]))}}}}return n}function Ce(e,t){return`${e.layerId}:${t.id}`}function De(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Re(e,t,r){const n=[];for(const a of e)De(a.layer,r)&&n.push(a);if(0===n.length)return;let o=[];for(const a of n){const r=a.layer;switch(a.operationType){case"delete":o=[...Ge(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ge(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...Ge(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ge(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function Ge(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function Be(e,t={}){return F(e)||k(e)?{}:A(e)?{...e.prototype.attributes,...t}:L(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ne(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=me(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:o,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:o,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Ze(e.tooltipOptions,l,s)}function Ze(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function We(e,t){return e.find(e=>e.layer===t)}function Qe(e,t){const r=We(e,t);if(null==r)throw new i("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function $e(e,t){return e?.find(e=>e.layer===t)}async function Je(e,t,r,n){switch(t.type){case"3d":return He(e,t,r,n);case"2d":return Ke(e,t,r,n)}}async function He(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(H(t,r),n),a=new Map,i=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};J(o).forEach(({graphic:e})=>i(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return h(Promise.allSettled(a.map(async({layer:e})=>{const t=i.get(e),r=Xe(e);if(t.every(e=>M(e,r)))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=O(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ke(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let a=null;const i=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const i=new Set;a=J(o),a.forEach(({graphic:e})=>e&&i.add(e.layer));const s=e.filter(e=>i.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(i.map(async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Xe(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return a?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function Xe(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ye(e,t,n,o){return _e(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function _e(e,t,r,n){const o=t.createQuery();o.objectIds=e,o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,o.returnGeometry=!0,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=r);const a=await t.queryFeatures(o,{signal:n});return m(n),a.features}async function et(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await tt(e);const a={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(a.enableRotation=null!=o.rotation,a.enableScaling=null!=o.size),r.update(t,a)}async function tt(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:a,webStyleCache:i}=e;let s=!1;const{rotation:l,size:c}=a;for(const u of[l,c]){if(null==u)continue;const e=t.getAttribute(u.field);if(null!=e)u.setInitialValue(e);else{const e=await u.getDefaultValue(t.symbol,n.view);u.setInitialValue(e),t.setAttribute(u.field,e),s=!0}}if(s){const e="2d"===n.view?.type?n.view.scale:null;await Te(t,i,e)}Ze(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function rt(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function nt(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function ot(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let a=!1;const i=n.rotation,s=rt(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),a=!0}}const l=n.size,c=nt(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==o[r]&&t.setAttribute(r,i),a=!0}}return a}async function at({feature:e,featureClone:t,visualVariableAttributes:r,sketchLayer:n,sketchViewModel:o,view:a,onUpdate:i,webStyleCache:u,addUpdatingPromise:d,addHandle:p}){await Te(t,u,"2d"===a.type?a.scale:null);let y=null;if("2d"===o?.view?.type){const e=f(e=>Te(t,u,e));y=g(()=>o?.view?.scale,t=>e(t))}const m=t.sourceLayer,h=mt(a,m);await et({graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u});let b=null;h.then(e=>b=e).catch(()=>{});const I=r.size,v=r.rotation,T=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==I||I.isUpdatingInteractively||I.field!==n||I.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),(null==b||b.requiredFields.includes(n))&&(r=!0))}r&&await Te(t,u,"2d"===a.type?a.scale:null)}),S=o.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchLayer:n,sketchViewModel:o,sourceLayer:m,visualVariables:r,webStyleCache:u};if("complete"===e.state){if(null===a.activeTool)return et(s);const e=new AbortController,t=c(e);return p(t),d(w(()=>null===a.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),et(s)}))}ot(a,t,e,r)&&await Te(t,u,"2d"===a.type?a.scale:null),i(gt(t),e)}),F=o.on(["undo","redo"],e=>{i(gt(e.graphics[0]),e)});return s([F,S,l(()=>o.cancel()),T,y])}async function it(e,t,r,n){e.add(n);const o=r.sourceLayer,i=r.getAttribute(o.objectIdField);let c=null;function u(e){c?.abort(),c=a(async r=>{const n=await mt(t,o);m(r),n.setVisibility?.(i,e)})}return await lt(t,n),u(!1),s([st(t,n,e=>u(!e)),l(async()=>{u(!0);try{if(!t.destroyed){const e=await mt(t,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}function st(e,t,r){if("3d"===e.type){const n=new W({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function lt(e,t){if("3d"===e.type){const r=new W({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const ct={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function ut(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function dt(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function pt(e){return"unknown"===e?null:e}function ft(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const yt=e=>e.includes("-stop")||e.includes("vertex-"),mt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ht(e){return"createInteractiveEditSession"in e}function gt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function bt(e){return e.acquireCursor("progress")}async function wt(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(S(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function It(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function vt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>It(e.relationships)),t.flatMap(e=>e.edits)):null}function Tt(e){const t=ie(e)?e.activeWorkflow:e;if(null==t)return[];if(ne(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function St({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&v(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function Ft(e){if(!e.supportsMergeFeaturesWorkflow)throw new i("editing:unsupported-workflow","Merge features workflow requires that deleting features and updating their geometries are allowed.")}function jt(e){if(!e.supportsSplitFeatureWorkflow)throw new i("editing:unsupported-workflow","Split feature workflow requires that both creating features and updating their geometries are allowed.")}function kt(e){const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;p(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}export{Re as appendAllUtilityNetworkAssociationRelationships,Ft as assertMergeWorkflowCapabilities,jt as assertSplitWorkflowCapabilities,dt as avoidFeatureTemplateSelectionWithOnlyOneItem,ht as canCreateInteractiveEditSession,gt as cloneGraphicExceptMesh,qe as createLayerIdMap,ze as createRelationshipKeyMap,Se as createToolFromGeometryType,ut as createWorkflowSteps,kt as featuresToFeatureInfos,Je as fetchCandidates,Ye as fetchFullFeatures,_e as fetchFullFeaturesByObjectId,Pe as findAllDependencies,Ge as findChangesByGlobalId,We as findEditorItemForLayer,Qe as findEditorItemForLayerOrThrow,$e as findLayerInfo,Ce as generateHashForRelationship,Be as getCreationAttributes,wt as getFullTemplateForCreationInfo,Tt as getLayersFromWorkflow,he as getRotationVariableAttribute,vt as getServiceEditsFromWorkflowData,Ve as getServiceInfoForLayer,Me as getServiceLayersById,we as getSizeVariableAttribute,me as getVisualVariableAttributes,ye as getVisualVariablesForLayer,_ as isAnyUpdateLeafWorkflow,ee as isBatchAttributeFormViewModel,te as isCreateFeaturesWorkflow,re as isFeatureFormViewModel,se as isMergeFeaturesWorkflow,ue as isMergeWorkflowOptions,ce as isParentWorkflow,le as isSplitFeatureWorkflow,de as isSplitWorkflowOptions,yt as isTerminalUpdateEventType,oe as isUpdateFeatureWorkflow,ne as isUpdateFeaturesWorkflow,fe as isUpdateFeaturesWorkflowOptions,ae as isUpdateRecordWorkflow,ie as isUpdateWorkflow,De as isUtilityNetworkAssociationsTable,St as makeMinimalAttributes,xe as orderEditsByRelationshipDependencies,ft as prepareAttachmentsForCreateFeaturesWorkflow,It as setRelationshipFields,at as setUpGeometryUpdate,je as setUpSketchCreateWatchers,tt as setVisualVariablesAndElevationInfoForUpdate,bt as showProgressCursor,ct as sizeDefaults,pt as sizeVariableUnitToLengthUnit,Fe as startCreatingNewFeature,et as startUpdatingFeatureGeometry,it as swapForEditingSession,Te as updateGraphicSymbolWhenRequired,ot as visualVariableInteractiveUpdate,mt as whenEditorLayerView,lt as whenGraphicDisplayed,pe as workflowInfluencesOutcomeOfParent};
|