@arcgis/core 4.34.0 → 4.34.1
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/{9786e854ae9f40975cee.js → 0638a36eaacb56cf89fa.js} +1 -1
- package/assets/esri/core/workers/chunks/{151defe707bceb3a56a4.js → 222c2ae818353539cab2.js} +1 -1
- package/assets/esri/core/workers/chunks/{4b7c99f9a716a929178d.js → 70c7d3128c9242d10873.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ec6ad6d76b4755a4cf6.js → 9e09b5fd04ff1fb18888.js} +1 -1
- package/assets/esri/core/workers/chunks/{292403693cba4562a02d.js → bcf2bda17bda0210f898.js} +1 -1
- package/assets/esri/core/workers/chunks/{dec0ed841f9ff1ceff43.js → c0d787297d2128fe3c38.js} +1 -1
- package/assets/esri/themes/base/widgets/_UtilityNetworkTrace.scss +3 -0
- 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/interfaces.d.ts +23 -6
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/package.json +2 -2
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/time/timeZoneUtils.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/support/popupHitTest.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/popupAdapter.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/views/ui/UI.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflowData.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflowData.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as n,on as l,whenOnce as p,initial as d}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{isGraphicsLayer as m}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/draw/support/HighlightHelper.js";import g from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as f}from"../../views/support/HighlightDefaults.js";import v from"./Edits.js";import _ from"./SplitFeatureWorkflowData.js";import F from"./Workflow.js";import{createWorkflowSteps as M,updateFeatureWorkflowInternalGraphicsLayerTitle as b,swapForEditingSession as S,updateGraphicSymbolWhenRequired as k,makeMinimalAttributes as G,whenGraphicDisplayed as T,whenEditorLayerView as V}from"./workflowUtils.js";import{assertViewNot3D as I,assertSplitWorkflowCapabilities as j}from"./support/errors.js";import{getCompatibleSpitterGeometryType as E,ensureSplittableGeometry as H,makeNewFeatureAttributes as x,splitGeometry as L,canSplitByPoint as C,isSplitterGeometry as U}from"./support/splitFeatureUtils.js";import W from"../FeatureForm/FeatureFormViewModel.js";import P from"../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as z}from"../Sketch/support/sketchUtils.js";var A;const O=Symbol(),R=Symbol();let D=A=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 w({view:e,highlightName:f}):null,this._initializeFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r=z(t);if("mesh"!==r)return y(r,i?.geometry,e)}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}get noticeMessage(){return this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}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(I(e.viewModel,"split-feature"),j(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=E(H(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 n=new A({data:new _(s),defaultSplitterGeometryType:a,onCommit:Z(e.applyEdits)});return n._set("steps",A._createWorkflowSteps(n,o)),n}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async 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 v({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const n=r.clone();n.geometry=e,n.attributes=x(r.attributes,i.editorItem.layer);const l=new v({feature:n});return i.newFeatureEdits=l,l.trackChanges(),await this._setFeatureOnFormViewModel(n,"new"),l.submittable=a.submittable,{featureToCreate:n,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return M(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=H(r.originalFeature.geometry),a=E(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;C(i)&&o&&e.addHandles($(o,e.layer));const s=e._sketchViewModel;e.addHandles([l(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!U(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),n(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(O)&&o?e.addHandles(q(o,e.layer),O):"point"===i&&e.removeHandles(O)})],this.id),await s.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),n=await e._displayFeatureGraphics(s,o);e.addHandles(n,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,l=a.viewModel.view,p=[];if(!e||!t||!l)return i();const d=s(i=>Promise.all([k(e,this._webStyleCache,i),k(t,this._webStyleCache,i)]));await d("2d"===l.type?l.scale:null),"2d"===l.type&&p.push(n(()=>l.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t)));const{originalFeature:u}=a,c=u.layer,h=m(c)&&c.title===b&&c.internal?await J({editingGraphicsLayer:o,view:l,originalGraphicsLayer:c,editedGraphic:e}):await S(o,l,u,e);return p.push(h),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 L(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 W({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),k(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 P({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>this.addHandles(B(this)),exit:()=>this.removeHandles(R),viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],D.prototype,"activeFeature",null),e([u()],D.prototype,"allowSave",null),e([u()],D.prototype,"availableCreateTools",null),e([u()],D.prototype,"defaultSplitterGeometryType",void 0),e([u()],D.prototype,"formViewModel",null),e([u()],D.prototype,"hasInvalidFormTemplate",null),e([u()],D.prototype,"hasPreviousStep",null),e([u()],D.prototype,"helpMessage",null),e([u()],D.prototype,"layer",null),e([u()],D.prototype,"parent",null),e([u()],D.prototype,"type",void 0),e([u()],D.prototype,"updating",null),e([u()],D.prototype,"noticeMessage",null),e([u()],D.prototype,"_activeFeature",void 0),e([u()],D.prototype,"_formViewModel",void 0),e([u()],D.prototype,"_graphicsLayer",void 0),e([u()],D.prototype,"_highlightHelper",void 0),e([u()],D.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],D.prototype,"_sketchViewModel",void 0),D=A=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],D);const N=D;function Z(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),n=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=G(o,i.editorItem.layer)),await e(n,{addFeatures:[s],updateFeatures:[o]})}}function $(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new g({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function q(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const n=new Map;for(const i of r.featureSources)n.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of n)e.enabled=t})}function B(e){const t=e.data,{originalFeature:o,viewModel:s}=t,{view:l}=s;if(!l)return i();const p=new w({view:l}),u=n(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new w({view:l,highlightName:f}),h=n(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=n(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}async function J({editingGraphicsLayer:e,view:t,originalGraphicsLayer:a,editedGraphic:o}){function s(e){a.visible=e}return e.add(o),await T(t,o),s(!1),r([i(async()=>{s(!0);try{if(!t.destroyed){const e=await V(t,a).catch(()=>{});e&&!e.destroyed&&await p(()=>!e.updating)}}finally{e.remove(o)}})])}export{N as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as n,on as l,whenOnce as p,initial as d}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{isGraphicsLayer as m}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/draw/support/HighlightHelper.js";import f from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as g}from"../../views/support/HighlightDefaults.js";import v from"./Edits.js";import _ from"./SplitFeatureWorkflowData.js";import F from"./Workflow.js";import{createWorkflowSteps as M,updateFeatureWorkflowInternalGraphicsLayerTitle as b,swapForEditingSession as S,updateGraphicSymbolWhenRequired as k,makeMinimalAttributes as G,whenGraphicDisplayed as T,whenEditorLayerView as V}from"./workflowUtils.js";import{assertViewNot3D as I,assertSplitWorkflowCapabilities as j}from"./support/errors.js";import{getCompatibleSpitterGeometryType as E,ensureSplittableGeometry as H,makeNewFeatureAttributes as x,splitGeometry as L,canSplitByPoint as C,isSplitterGeometry as U}from"./support/splitFeatureUtils.js";import W from"../FeatureForm/FeatureFormViewModel.js";import P from"../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as z}from"../Sketch/support/sketchUtils.js";var A;const O=Symbol(),R=Symbol();let D=A=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 w({view:e,highlightName:g}):null,this._initializeFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r=z(t);if("mesh"!==r)return y(r,i?.geometry,e)}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}get noticeMessage(){return this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}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(I(e.viewModel,"split-feature"),j(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=E(H(s.feature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.feature.geometry?.type}'.`)}const n=new A({data:new _(s),defaultSplitterGeometryType:a,onCommit:Z(e.applyEdits)});return n._set("steps",A._createWorkflowSteps(n,o)),n}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.feature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new v({feature:o});i.existingFeatureEdits=s,s.trackChanges(i.initialFeature),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const n=r.clone();n.geometry=e,n.attributes=x(r.attributes,i.editorItem.layer);const l=new v({feature:n});return i.newFeatureEdits=l,l.trackChanges(),await this._setFeatureOnFormViewModel(n,"new"),l.submittable=a.submittable,{featureToCreate:n,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return M(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=H(r.feature.geometry),a=E(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;C(i)&&o&&e.addHandles($(o,e.layer));const s=e._sketchViewModel;e.addHandles([l(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!U(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),n(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(O)&&o?e.addHandles(q(o,e.layer),O):"point"===i&&e.removeHandles(O)})],this.id),await s.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),n=await e._displayFeatureGraphics(s,o);e.addHandles(n,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,l=a.viewModel.view,p=[];if(!e||!t||!l)return i();const d=s(i=>Promise.all([k(e,this._webStyleCache,i),k(t,this._webStyleCache,i)]));await d("2d"===l.type?l.scale:null),"2d"===l.type&&p.push(n(()=>l.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t)));const{feature:u}=a,c=u.layer,h=m(c)&&c.title===b&&c.internal?await J({editingGraphicsLayer:o,view:l,originalGraphicsLayer:c,editedGraphic:e}):await S(o,l,u,e);return p.push(h),r(p)}async _executeSplit(e){const{data:i}=this,{feature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await L(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 W({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),k(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 P({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>this.addHandles(B(this)),exit:()=>this.removeHandles(R),viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.initialFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],D.prototype,"activeFeature",null),e([u()],D.prototype,"allowSave",null),e([u()],D.prototype,"availableCreateTools",null),e([u()],D.prototype,"defaultSplitterGeometryType",void 0),e([u()],D.prototype,"formViewModel",null),e([u()],D.prototype,"hasInvalidFormTemplate",null),e([u()],D.prototype,"hasPreviousStep",null),e([u()],D.prototype,"helpMessage",null),e([u()],D.prototype,"layer",null),e([u()],D.prototype,"parent",null),e([u()],D.prototype,"type",void 0),e([u()],D.prototype,"updating",null),e([u()],D.prototype,"noticeMessage",null),e([u()],D.prototype,"_activeFeature",void 0),e([u()],D.prototype,"_formViewModel",void 0),e([u()],D.prototype,"_graphicsLayer",void 0),e([u()],D.prototype,"_highlightHelper",void 0),e([u()],D.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],D.prototype,"_sketchViewModel",void 0),D=A=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],D);const N=D;function Z(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),n=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=G(o,i.editorItem.layer)),await e(n,{addFeatures:[s],updateFeatures:[o]})}}function $(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new f({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function q(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const n=new Map;for(const i of r.featureSources)n.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of n)e.enabled=t})}function B(e){const t=e.data,{feature:o,viewModel:s}=t,{view:l}=s;if(!l)return i();const p=new w({view:l}),u=n(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new w({view:l,highlightName:g}),h=n(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=n(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}async function J({editingGraphicsLayer:e,view:t,originalGraphicsLayer:a,editedGraphic:o}){function s(e){a.visible=e}return e.add(o),await T(t,o),s(!1),r([i(async()=>{s(!0);try{if(!t.destroyed){const e=await V(t,a).catch(()=>{});e&&!e.destroyed&&await p(()=>!e.updating)}}finally{e.remove(o)}})])}export{N as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{property as
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import o from"../../views/interactive/sketch/SketchOptions.js";let s=class extends e{constructor(t){super(t),this.editorItem=null,this.newFeatureEdits=null,this.existingFeatureEdits=null,this.feature=null,this.initialFeature=null,this.sketchOptions=new o,this.snappingManager=null,this.splitResult=null,this.splitterGeometry=null,this.temporaryHighlightFeature=null,this.viewModel=null}initialize(){this.initialFeature||(this.initialFeature=this.feature)}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(t){null==t?this._clearOverride("timeZone"):this._override("timeZone",t)}getEditsForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:i}=this;return e?.feature===t?e:i?.feature===t?i:null}getRoleForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:i}=this;return e?.feature===t?"existing":i?.feature===t?"new":null}};t([i({constructOnly:!0})],s.prototype,"editorItem",void 0),t([i()],s.prototype,"newFeatureEdits",void 0),t([i()],s.prototype,"existingFeatureEdits",void 0),t([i()],s.prototype,"feature",void 0),t([i()],s.prototype,"initialFeature",void 0),t([i()],s.prototype,"parent",void 0),t([i({constructOnly:!0})],s.prototype,"sketchOptions",void 0),t([i()],s.prototype,"snappingManager",void 0),t([i()],s.prototype,"splitResult",void 0),t([i()],s.prototype,"splitterGeometry",void 0),t([i()],s.prototype,"temporaryHighlightFeature",void 0),t([i()],s.prototype,"timeZone",null),t([i()],s.prototype,"viewModel",void 0),s=t([r("esri.widgets.Editor.SplitFeatureWorkflowData")],s);const n=s;export{n as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{
|
|
5
|
+
import{__decorate as t}from"tslib";import{isSome as e,unique as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as o}from"../../core/handleUtils.js";import{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{EsriPromise as a}from"../../core/Promise.js";import{throwIfAborted as l,isAbortError as n}from"../../core/promiseUtils.js";import u from"../../core/ReactiveMap.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as d}from"../../layers/support/layerUtils.js";import c from"./Edits.js";import{fetchFullFeaturesByObjectId as m}from"./workflowUtils.js";let h=class extends a{constructor(t){super(t),this.editorItems=[],this.featureInfos=null,this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new u,this._fullFeatures=new u,this._pendingEdits=new u}initialize(){const t=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(t.signal).then(e=>{l(t.signal),this._initializeEdits(e)}).catch(t=>{if(n(t))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw t})),this.addHandles(o(t)),this._initializeEditorItemsByLayer()}get features(){return this.fullFeatures}get fullFeatures(){return Array.from(this._fullFeatures.values())}get initialFeatures(){return Array.from(this._pendingEdits.values()).map(t=>t.initialFeature).filter(e)}get layers(){const{featureInfos:t,features:s}=this;return t?.length?t.map(t=>t.layer):s.length?r(s.map(t=>t.sourceLayer).filter(e)):[]}set timeZone(t){this._set("timeZone",t),this._pendingEdits.forEach(e=>{e.timeZone=t})}getEditorItemForLayer(t){return this._editorItemsByLayer.get(t)}getFeatureTitle(t){return this._pendingEdits.get(t)?.displayTitle}getPendingEditsForFeature(t){const e=t.getObjectId();if(null!=e)return this._pendingEdits.get(this._fullFeatures.get(e)??t)}isSubmittable(t){const e=this._pendingEdits.get(t);return!!e&&(e.submittable||e.isAssociation)}stageDelete(){for(const t of this._pendingEdits.values())t.stageDelete()}_initializeEditorItemsByLayer(){for(const t of this.editorItems)this._editorItemsByLayer.set(t.layer,t)}_initializeEdits(t){const{timeZone:e}=this;for(const r of t){const t=new c({feature:r,timeZone:e});t.trackChanges(),this._pendingEdits.set(r,t)}}async _initializeFullFeatures(t){const{_fullFeatures:e,featureInfos:r,features:o,viewModel:a}=this,{spatialReference:l}=a.view,n=new Map;if(r?.length)for(const{layer:s,objectIds:i}of r)n.set(d(s)?s.parent:s,i);else if(o.length)for(const s of o){const t=s.getObjectId();if(null!=t){const e=s.sourceLayer??s.layer,r=d(e)?e.parent:e;i(n,r,()=>[]).push(t)}}const u=Array.from(n.entries()).map(async([r,o])=>{const i=await m(o,r,l,t);if(i.length!==o.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const a=r.objectIdField,n=(t,e)=>t.attributes[a]>e.attributes[a]?1:-1,u=o.sort(),p=i.sort(n);for(let t=0;t<u.length;t++)e.set(u[t],p[t]);return i});return(await Promise.all(u)).flat()}};t([p({constructOnly:!0})],h.prototype,"editorItems",void 0),t([p({constructOnly:!0})],h.prototype,"featureInfos",void 0),t([p()],h.prototype,"features",null),t([p()],h.prototype,"fullFeatures",null),t([p()],h.prototype,"initialFeatures",null),t([p()],h.prototype,"layers",null),t([p()],h.prototype,"parent",void 0),t([p()],h.prototype,"selectedFeature",void 0),t([p({constructOnly:!0})],h.prototype,"sketchOptions",void 0),t([p()],h.prototype,"snappingManager",void 0),t([p()],h.prototype,"timeZone",null),t([p()],h.prototype,"viewModel",void 0),t([p()],h.prototype,"_fullFeatures",void 0),h=t([f("esri.widgets.Editor.UpdateFeaturesWorkflowData")],h);const y=h;export{y as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as a}from"../../core/handleUtils.js";import{isAborted as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,abortHandle as a}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{isAborted as o}from"../../core/promiseUtils.js";import{watch as s}from"../../core/reactiveUtils.js";import{property as l}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 d from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as c}from"../../views/support/HighlightDefaults.js";import h from"./UpdateRecordWorkflowData.js";import p from"./Workflow.js";import{fetchFullFeatures as u}from"./workflowUtils.js";import m from"../FeatureForm/FeatureFormViewModel.js";var f;const g={exit:Symbol()};let w=class extends p{static{f=this}constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:s}=e,{view:l}=e.viewModel,n=s.feature;l&&(this._highlightHelper=new d({view:l,highlightName:c}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const h=new AbortController;this.addHandles(a(h)),this._updatingHandles.addPromise(u([n],n.sourceLayer,e.viewModel.view.spatialReference,h.signal).then(([e])=>{o(h)||(this._onFullFeatureLoaded(e),this._initializeFormViewModel())},e=>(r.getLogger(this).error("initialize()","Failed to fetch full feature for update workflow.",e),this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})}))))}get allowSave(){return!this.data.readOnly&&this.hasPendingEdits&&!this.updating}get editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItem.hasInvalidFormTemplate}get hasPendingEdits(){return this.data.edits.modified&&!this.data.readOnly}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(g.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:a,viewModel:r}=e,{attachmentsViewModel:o}=r,l=e.readOnly?{editing:!1}:a;o.set({capabilities:l,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i(()=>o.fileInfos.removeAll()),s(()=>o.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})],g.exit)}_initializeFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:a},readOnly:r}=this.data,o=this._formViewModel=new m({activeAssociation:e,editType:"UPDATE",feature:this.fullFeature,formTemplate:i,highlightHelper:this._highlightHelper,map:a?.map,spatialReference:a.spatialReference,timeZone:a?.timeZone,disabled:r});o.callbacks={...this.data.featureFormCallbacks,showAllRelatedRecords:e=>o.relationshipId=e.relationshipId,viewAssociatedLayers:e=>o.associationId=e.associationId,viewAssociatedFeatures:e=>o.associatedLayer=e.associatedLayer};const{initialFeature:l}=t;l&&o.overrideInitialFeature(l),this.addHandles([o.on("value-change",()=>{t.updateAttributes(o.getValues()),this.fullFeature.attributes=t.feature.attributes}),s(()=>a?.timeZone,e=>o.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 f({data:await h.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}static{this._onCommitFactory=e=>async t=>{const{edits:i}=t,{feature:a}=i;if(!a)return;const r=a.sourceLayer,o=a.clone();if(!i.attributesModified||i.stagedForDelete){const e=r.objectIdField;if(o.attributes={[e]:a.getAttribute(e)},"scene"===r.type&&null!=r.infoFor3D){const e=r.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,a.getAttribute(e))}}i.geometryModified&&!i.stagedForDelete||(o.geometry=null);const s=i.stagedForDelete?"deleteFeatures":"updateFeatures";await e(r,{[s]:[o]})}}};e([l()],w.prototype,"_formViewModel",void 0),e([l()],w.prototype,"allowSave",null),e([l()],w.prototype,"editorItem",null),e([l()],w.prototype,"formViewModel",null),e([l()],w.prototype,"fullFeature",void 0),e([l()],w.prototype,"hasInvalidFormTemplate",null),e([l()],w.prototype,"hasPendingEdits",null),e([l()],w.prototype,"layer",null),e([l()],w.prototype,"parent",null),e([l()],w.prototype,"saveActionLabel",null),e([l()],w.prototype,"shouldShowAttachments",null),e([l()],w.prototype,"shouldAllowAttachmentEditing",null),e([l()],w.prototype,"reliesOnOwnerAdminPrivileges",null),w=f=e([n("esri.widgets.Editor.UpdateRecordWorkflow")],w);export{w as UpdateRecordWorkflow,g as handleKeys};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import o from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{createResolver as n,debounce as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as U}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as ee,isGraphicForRelatableFeatureSupportedLayer as te}from"../Feature/support/featureUtils.js";var ie;let oe=ie=class extends O{constructor(e){super(e),this._workflowStack=new u(k),this._sketchStack=new u(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>x(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:o,...a}=e,r=new ie({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:o,...a}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(){const{formViewModel:e}=this;if(e&&(e.submit(),!e.submittable||T(e)&&re(e)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:t}=this;if(await(t?.commit()),!D(t))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===t?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new o("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:a})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:a})}finally{i.resolve()}}async startAddAssociation(e,t,i){const a=this._makeUpdatingResolver();try{const o=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(o)}catch(r){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{a.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new o("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=z(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new o("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!T(e))throw new o("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:a,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new o("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=ee(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new o("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await a(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const o of e)i(t,o)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!T(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:a,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(t))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:a,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!A(i)||S(i))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:a}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=a.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t={}){const i=C(e.sourceLayer)?L:P,{applyEditsCallback:o,applyEditsFeatureServiceCallback:a,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:o,applyEditsFeatureService:a,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await w(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:o,featureInfos:e,viewModel:a,...t});return await w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new o("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await a.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data;Z(e);const r=Q(this.data.viewModel.editorItems,W(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:o,editorItem:r,features:e,parent:s,viewModel:a,...t});return await w(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:a,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=Q(s.editorItems,e.sourceLayer),d=j.create({applyEdits:i,applyEditsFeatureService:o,editorItem:l,originalFeature:e,parent:n,sketchOptions:a,snappingManager:r,viewModel:s,...t});return await w(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const o of t){const t=e(o).finally(()=>o.destroy());this._updatingHandles.addPromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=n();return this._updatingHandles.addPromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:o}=e;if(!te(t))return;const a=i.relationships?.find(e=>e.id===o);if(!a)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"===a.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;a.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===o);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=ae(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=ae(i,a);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new o("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflowAndReconcile(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,a=await(e?.start()),r=i.peek();a?(r?.exit(),i.push(a)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new o("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:a}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:a+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return $(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,o=i.viewModel.view;o.activeTool=null;let r=null;e.addHandles(a(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const l=o.on("immediate-click",async a=>{const s=n();e._updatingHandles.addPromise(s.promise);try{t.location=a.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await a.defer(()=>new Promise((e,t)=>{d(r?.signal,()=>t(c())),e(B(s,o,a,r?.signal))}));if(p(r),i.candidates=n.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(a.stopPropagation(),1===i.candidates.length){const{rootFeatures:o}=i;o.removeAll(),o.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},E.TOOL),u=v(()=>null!=o.activeTool,()=>e.cancel({force:!0}),{once:!0});o.focus(),e.addHandles([l,u],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const o=new F({view:t,highlightName:U});e.addHandles([g(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>o.remove(e)),e.forEach(e=>o.add(e))},f),a(()=>o.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await se(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=l(async()=>{await w(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function ae(e,{keyField:t}){return e.getField(t)?.name??t}function re(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function se(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(J(i)){const{rootFeatureInfos:a}=t,r=a.length>0?a:K(t.rootFeatures.toArray());if(0===r.length)throw new o("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:a}=t,r=a.getItemAt(0);if(!r)throw new o("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await e.startMergingFeatures(a.toArray(),i.props):Y(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([m()],oe.prototype,"formViewModel",null),e([m()],oe.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([m()],oe.prototype,"activeSketchViewModel",null),e([m()],oe.prototype,"canDeleteAssociation",null),e([m()],oe.prototype,"activeWorkflow",null),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"data",void 0),e([m()],oe.prototype,"hasPreviousStep",null),e([m()],oe.prototype,"hasUpdatableCandidates",null),e([m()],oe.prototype,"nestedWorkflowCount",null),e([m()],oe.prototype,"shouldShowAttachments",null),e([m()],oe.prototype,"shouldAllowAttachmentEditing",null),e([m()],oe.prototype,"hasPendingEdits",null),e([m()],oe.prototype,"helpMessage",null),e([m()],oe.prototype,"noticeMessage",null),e([m()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],oe.prototype,"hasInvalidFormTemplate",null),oe=ie=e([y("esri.widgets.Editor.UpdateWorkflow")],oe);const ne=oe;export{ne as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import o from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{createResolver as n,debounce as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as U}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as ee,isGraphicForRelatableFeatureSupportedLayer as te}from"../Feature/support/featureUtils.js";var ie;let oe=ie=class extends O{constructor(e){super(e),this._workflowStack=new u(k),this._sketchStack=new u(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>x(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:o,...a}=e,r=new ie({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:o,...a}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(){const{formViewModel:e}=this;if(e&&(e.submit(),!e.submittable||T(e)&&re(e)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:t}=this;if(await(t?.commit()),!D(t))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===t?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new o("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:a})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:a})}finally{i.resolve()}}async startAddAssociation(e,t,i){const a=this._makeUpdatingResolver();try{const o=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(o)}catch(r){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{a.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new o("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=z(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new o("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!T(e))throw new o("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:a,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new o("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=ee(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new o("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await a(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const o of e)i(t,o)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!T(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:a,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(t))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:a,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!A(i)||S(i))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:a}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=a.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t={}){const i=C(e.sourceLayer)?L:P,{applyEditsCallback:o,applyEditsFeatureServiceCallback:a,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:o,applyEditsFeatureService:a,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await w(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:o,featureInfos:e,viewModel:a,...t});return await w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new o("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await a.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data;Z(e);const r=Q(this.data.viewModel.editorItems,W(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:o,editorItem:r,features:e,parent:s,viewModel:a,...t});return await w(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:a,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=Q(s.editorItems,e.sourceLayer),d=j.create({applyEdits:i,applyEditsFeatureService:o,editorItem:l,feature:e,parent:n,sketchOptions:a,snappingManager:r,viewModel:s,...t});return await w(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const o of t){const t=e(o).finally(()=>o.destroy());this._updatingHandles.addPromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=n();return this._updatingHandles.addPromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:o}=e;if(!te(t))return;const a=i.relationships?.find(e=>e.id===o);if(!a)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"===a.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;a.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===o);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=ae(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=ae(i,a);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new o("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflowAndReconcile(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,a=await(e?.start()),r=i.peek();a?(r?.exit(),i.push(a)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new o("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:a}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:a+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return $(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,o=i.viewModel.view;o.activeTool=null;let r=null;e.addHandles(a(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const l=o.on("immediate-click",async a=>{const s=n();e._updatingHandles.addPromise(s.promise);try{t.location=a.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await a.defer(()=>new Promise((e,t)=>{d(r?.signal,()=>t(c())),e(B(s,o,a,r?.signal))}));if(p(r),i.candidates=n.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(a.stopPropagation(),1===i.candidates.length){const{rootFeatures:o}=i;o.removeAll(),o.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},E.TOOL),u=v(()=>null!=o.activeTool,()=>e.cancel({force:!0}),{once:!0});o.focus(),e.addHandles([l,u],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const o=new F({view:t,highlightName:U});e.addHandles([g(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>o.remove(e)),e.forEach(e=>o.add(e))},f),a(()=>o.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await se(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=l(async()=>{await w(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function ae(e,{keyField:t}){return e.getField(t)?.name??t}function re(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function se(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(J(i)){const{rootFeatureInfos:a}=t,r=a.length>0?a:K(t.rootFeatures.toArray());if(0===r.length)throw new o("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:a}=t,r=a.getItemAt(0);if(!r)throw new o("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await e.startMergingFeatures(a.toArray(),i.props):Y(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([m()],oe.prototype,"formViewModel",null),e([m()],oe.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([m()],oe.prototype,"activeSketchViewModel",null),e([m()],oe.prototype,"canDeleteAssociation",null),e([m()],oe.prototype,"activeWorkflow",null),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"data",void 0),e([m()],oe.prototype,"hasPreviousStep",null),e([m()],oe.prototype,"hasUpdatableCandidates",null),e([m()],oe.prototype,"nestedWorkflowCount",null),e([m()],oe.prototype,"shouldShowAttachments",null),e([m()],oe.prototype,"shouldAllowAttachmentEditing",null),e([m()],oe.prototype,"hasPendingEdits",null),e([m()],oe.prototype,"helpMessage",null),e([m()],oe.prototype,"noticeMessage",null),e([m()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],oe.prototype,"hasInvalidFormTemplate",null),oe=ie=e([y("esri.widgets.Editor.UpdateWorkflow")],oe);const ne=oe;export{ne as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{substitute as e}from"../../../intl/substitute.js";import{css as t}from"../css.js";import{isCreateFeaturesWorkflow as o,isSplitFeatureWorkflow as i,isMergeFeaturesWorkflow as n,isUpdateFeaturesWorkflow as s,isBatchAttributeFormViewModel as a,isUpdateFeatureWorkflow as r}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as c}from"./FooterActions.js";import u from"./MergeFeaturesList.js";import{loadNoticesComponents as p,Notices as m}from"./Notices.js";import{loadPanelContentComponents as d,PanelContentSection as f,PanelContentSectionGroup as g,PanelContent as k}from"./PanelContent.js";import w from"./PendingFeatureList.js";import{loadCalciteComponents as b}from"../../support/componentsUtils.js";import{Heading as v,incrementHeadingLevel as h}from"../../support/Heading.js";import{classes as F}from"../../support/widgetUtils.js";import{tsx as y,tsxFragment as j}from"../../support/jsxFactory.js";import"@arcgis/toolkit/dom";const A=()=>Promise.all([b({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),p(),d()]);function C(e){const{editorViewModel:r,headingLevel:l,messages:p,renderAttachments:d,renderFeatureForm:b,renderBatchAttributeForm:F,renderSketchToolbar:A}=e,{activeFeatureCount:C,activeLeafWorkflow:S,activeWorkflow:T,formViewModel:B}=r;if(!S||!T||!B)return null;const V=a(B),x=o(S)&&!S.data.selectedPendingFeature||i(S)&&!S.activeFeature,z=n(S),I=S.shouldShowAttachments&&!V&&!B.activeRelationshipInput&&!B.activeAssociationInput,D=V?B.activeForm.inputs:B.inputs,W=o(S)&&D.every(e=>!e.visible)&&!I,H=null!=r.featureFormViewModel?.activeAssociationInput,P=!x&&!W&&!H,U=s(S)?F:b,
|
|
5
|
+
import{substitute as e}from"../../../intl/substitute.js";import{css as t}from"../css.js";import{isCreateFeaturesWorkflow as o,isSplitFeatureWorkflow as i,isMergeFeaturesWorkflow as n,isUpdateFeaturesWorkflow as s,isBatchAttributeFormViewModel as a,isUpdateFeatureWorkflow as r}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as c}from"./FooterActions.js";import u from"./MergeFeaturesList.js";import{loadNoticesComponents as p,Notices as m}from"./Notices.js";import{loadPanelContentComponents as d,PanelContentSection as f,PanelContentSectionGroup as g,PanelContent as k}from"./PanelContent.js";import w from"./PendingFeatureList.js";import{loadCalciteComponents as b}from"../../support/componentsUtils.js";import{Heading as v,incrementHeadingLevel as h}from"../../support/Heading.js";import{classes as F}from"../../support/widgetUtils.js";import{tsx as y,tsxFragment as j}from"../../support/jsxFactory.js";import"@arcgis/toolkit/dom";const A=()=>Promise.all([b({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),p(),d()]);function C(e){const{editorViewModel:r,headingLevel:l,messages:p,renderAttachments:d,renderFeatureForm:b,renderBatchAttributeForm:F,renderSketchToolbar:A}=e,{activeFeatureCount:C,activeLeafWorkflow:S,activeWorkflow:T,formViewModel:B}=r;if(!S||!T||!B)return null;const V=a(B),x=o(S)&&!S.data.selectedPendingFeature||i(S)&&!S.activeFeature,z=n(S),I=S.shouldShowAttachments&&!V&&!B.activeRelationshipInput&&!B.activeAssociationInput,D=V?B.activeForm.inputs:B.inputs,W=o(S)&&D.every(e=>!e.visible)&&!I,H=null!=r.featureFormViewModel?.activeAssociationInput,P=!x&&!W&&!H,U=W||o(S)&&!I&&!P&&!H,E=s(S)?F:b,N=W?y(f,null,y(w,{headingLevel:l,key:"pending-feature-list",workflow:S})):y(j,null,y(m,{activeFeatureCount:C,messages:p,workflow:T}),z?y(f,{class:t.mergeFeaturesListSection,key:"panel-section-merge"},y(u,{headingLevel:l,key:"merge-features-list",workflow:S})):void 0,y(f,{key:"panel-content-section-main"},y(g,null,x?y(w,{headingLevel:l,key:"pending-feature-list",workflow:S}):E(),I?y("div",{key:"attachments"},y(v,{level:h(l)},p.attachments),d()):null)));return y(j,null,P?M(S,e):void 0,U?A?.():void 0,y(k,{key:"attribute-panel-content"},N),y(c,{buttons:L(e)}))}function M(e,o){const i=[],n="3d"===o.editorViewModel.view?.type,{visibleElements:a}=o;if(a.zoomToButton&&o.editorViewModel.canZoomTo&&i.push(y("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>o.editorViewModel.zoomTo(),scale:"s",text:o.messages.zoomTo,title:o.messages.zoomTo})),a.splitButton&&r(e)&&e.editorItem.supportsSplitFeatureWorkflow&&!n&&o.onSplit){const{onSplit:e,messages:t}=o;i.push(y("calcite-action",{icon:"split-geometry",key:"split-button",onclick:e,scale:"s",text:t.split,title:t.split}))}if(a.mergeButton&&s(e)&&e.supportsMergeFeaturesWorkflow&&!n&&o.onMerge){const{onMerge:e,messages:t}=o;i.push(y("calcite-action",{icon:"merge",key:"merge-button",onclick:e,scale:"s",text:t.mergeFeatures,title:t.mergeFeatures}))}return i.length>0?y("calcite-action-bar",{class:F(t.sketchContainer,t.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal"},i):void 0}function L({editorViewModel:t,messages:o,messagesCommon:i,onDelete:n,onDeleteAssociation:s,onSave:a}){const{activeFeatureCount:r,activeLeafWorkflow:l,syncing:c}=t;if(!l)return[];const{page:u}=t;if("viewing-associated-features"===u||"viewing-associated-layers"===u)return[{appearance:"outline",onClick:()=>{const{featureFormViewModel:e}=t;null!=e?.associationId&&(e.associationId=null)},disabled:c,label:i.cancel,type:"button"}];const p=[],m=r>1?o.multiFeature:o.singleFeature,d=!l.allowSave||c,f=e(m[l.saveActionLabel],{count:r});p.push({appearance:"solid",onClick:a,disabled:d,label:f,type:"button"});const g={appearance:"outline",disabled:c,kind:"danger",label:e(m.delete,{count:r}),type:"button"};return t.shouldShowDeleteButton&&!t.featureFormHasAssociation&&n&&p.push({...g,onClick:n}),t.featureFormHasAssociation&&!t.shouldShowDeleteButton&&s&&p.push({...g,onClick:s,label:o.deleteAssociationTitle}),t.featureFormHasAssociation&&t.shouldShowDeleteButton&&s&&n&&p.push({...g,primaryLabel:i.delete,primaryText:i.delete,onClick:n,dropdownItems:[{onClick:s,label:o.deleteAssociationTitle}],type:"split-button"}),p}export{C as UpdateFeaturePanelContent,A as loadUpdateFeaturePanelContentComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as 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{isGraphic as D}from"../../support/guards.js";import R from"../../symbols/SimpleFillSymbol.js";import G from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Z}from"../../symbols/support/symbolUtils.js";import{getServices as W}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as $}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as J}from"../../views/support/drapedUtils.js";import{filterGraphicHits as H,hitTestSelectSimilarDistance as K}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as X}from"./support/dependencySort.js";import{isDrawGraphicTool as Y}from"../Sketch/support/sketchUtils.js";const _="updateFeatureWorkflow-internal",ee=()=>d.getLogger("esri.widgets.Editor.workflowUtils");function te(e){return se(e)||ae(e)}function re(e){return!!e&&"features"in e}function ne(e){return null!=e&&"create-features"===e.type}function oe(e){return!!e&&"feature"in e}function ae(e){return null!=e&&"update-features"===e.type}function ie(e){return null!=e&&"update-feature"===e.type}function se(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function le(e){return null!=e&&"update"===e.type}function ce(e){return null!=e&&"merge-features"===e.type}function ue(e){return null!=e&&"split-feature"===e.type}function de(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function pe(e){return"merge"===e?.type}function fe(e){return"split"===e?.type}function ye(e){return ce(e)||ue(e)}function me(e){return"update-multiple"===e?.type}function he(e){const t=e&&"renderer"in e?e.renderer:null;if(!Se(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 ge(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&Se(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=he(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=be(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=ve(n,r)}return{rotation:o,size:a}}function be(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,Te((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function we(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function Ie(e,t,r){if(null==t)return 0;const{symbol:n}=N(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(dt.icon,(await e(o,dt.icon))[0])||dt.icon}case"text":return dt.text;case"line":return dt.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return we(await t(o,e.scale/dt.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/dt.viewScaleSizeFactor;default:return 0}}function ve(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)=>Te(i(await Ie(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Te(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:yt(e.valueUnit),axis:e.axis}}function Te(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 Se(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 Fe(e,t,r){const n=await Z(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function je(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:$,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 ke(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)||k(a)||await We(e,s,l,n,u?c.scale:null);const{capabilities:d}=s;t.elevationInfo=s.elevationInfo;const p=je(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 Ae(e){return s([Le(e),Ue(e)])}function Le({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=>We(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ue({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!Y(a))return ee().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=Me(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 Me(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new B({angle:0,color:r,outline:new G({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new R({color:r,outline:new G({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new G({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}})}function Oe(e,t){const r=W(t),n=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function xe(e,t){const r=Oe(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 qe(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function ze(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=Ee(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ce(t,i,a),d=De(l,Pe(s,c),c);if(o&&Be(l,d,o),0===d.length)return t;const p=X(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=qe(e):h.id!==e.layerId&&(m.push(h),h=qe(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)??qe(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 Ee(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Pe(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Re(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(Re(n,e),t.keyField);break}}return r}function Ce(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 De(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=Re(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 Re(e,t){return`${e.layerId}:${t.id}`}function Ge(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 Be(e,t,r){const n=[];for(const a of e)Ge(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=[...Ne(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...Ne(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function Ne(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)||k(e)?{}:A(e)?{...e.prototype.attributes,...t}:L(e)?{...e.definition?.defaultValues,...t}:{...t}}async function We(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=ge(i);let c=await Z(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 Z(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}Qe(e.tooltipOptions,l,s)}function Qe(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 $e(e,t){return e.find(e=>e.layer===t)}function Je(e,t){const r=$e(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 He(e,t){return e?.find(e=>e.layer===t)}async function Ke(e,t,r,n){switch(t.type){case"3d":return Xe(e,t,r,n);case"2d":return Ye(e,t,r,n)}}async function Xe(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(K(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};H(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=_e(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 Ye(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=H(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=_e(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=J(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 _e(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function et(e,t,n,o){return tt(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function tt(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 rt(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await nt(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 nt(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 Fe(t,i,e)}Qe(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function ot(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function at(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function it(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=ot(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=at(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 st({feature:e,featureClone:t,visualVariableAttributes:r,sketchLayer:n,sketchViewModel:o,view:a,onUpdate:i,webStyleCache:u,addUpdatingPromise:d,addHandle:p}){await Fe(t,u,"2d"===a.type?a.scale:null);let y=null;if("2d"===o?.view?.type){const e=f(e=>Fe(t,u,e));y=g(()=>o?.view?.scale,t=>e(t))}const m=t.sourceLayer,h=gt(a,m);await rt({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 Fe(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 rt(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(),rt(s)}))}it(a,t,e,r)&&await Fe(t,u,"2d"===a.type?a.scale:null),i(wt(t),e)}),F=o.on(["undo","redo"],e=>{i(wt(e.graphics[0]),e)});return s([F,S,l(()=>o.cancel()),T,y])}async function lt(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 gt(t,o);m(r),n.setVisibility?.(i,e)})}return await ut(t,n),u(!1),s([ct(t,n,e=>u(!e)),l(async()=>{u(!0);try{if(!t.destroyed){const e=await gt(t,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}function ct(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function ut(e,t){if("3d"===e.type){const r=new Q({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const dt={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function pt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function ft(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 yt(e){return"unknown"===e?null:e}function mt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const ht=e=>e.includes("-stop")||e.includes("vertex-"),gt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function bt(e){return"createInteractiveEditSession"in e}function wt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function It(e){return e.acquireCursor("progress")}async function vt(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 Tt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function St(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>Tt(e.relationships)),t.flatMap(e=>e.edits)):null}function Ft(e){const t=le(e)?e.activeWorkflow:e;if(null==t)return[];if(ae(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function jt({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 kt(e){if(!At(e))return 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}))}function At(e){return 0===e.length||D(e[0])}export{Be as appendAllUtilityNetworkAssociationRelationships,ft as avoidFeatureTemplateSelectionWithOnlyOneItem,bt as canCreateInteractiveEditSession,wt as cloneGraphicExceptMesh,Ee as createLayerIdMap,Pe as createRelationshipKeyMap,je as createToolFromGeometryType,pt as createWorkflowSteps,Ke as fetchCandidates,et as fetchFullFeatures,tt as fetchFullFeaturesByObjectId,De as findAllDependencies,Ne as findChangesByGlobalId,$e as findEditorItemForLayer,Je as findEditorItemForLayerOrThrow,He as findLayerInfo,Re as generateHashForRelationship,Ze as getCreationAttributes,vt as getFullTemplateForCreationInfo,Ft as getLayersFromWorkflow,be as getRotationVariableAttribute,St as getServiceEditsFromWorkflowData,Oe as getServiceInfoForLayer,xe as getServiceLayersById,ve as getSizeVariableAttribute,ge as getVisualVariableAttributes,he as getVisualVariablesForLayer,te as isAnyUpdateLeafWorkflow,re as isBatchAttributeFormViewModel,ne as isCreateFeaturesWorkflow,oe as isFeatureFormViewModel,At as isGraphicsArray,ce as isMergeFeaturesWorkflow,pe as isMergeWorkflowOptions,de as isParentWorkflow,ue as isSplitFeatureWorkflow,fe as isSplitWorkflowOptions,ht as isTerminalUpdateEventType,ie as isUpdateFeatureWorkflow,ae as isUpdateFeaturesWorkflow,me as isUpdateFeaturesWorkflowOptions,se as isUpdateRecordWorkflow,le as isUpdateWorkflow,Ge as isUtilityNetworkAssociationsTable,jt as makeMinimalAttributes,ze as orderEditsByRelationshipDependencies,mt as prepareAttachmentsForCreateFeaturesWorkflow,Tt as setRelationshipFields,st as setUpGeometryUpdate,Ae as setUpSketchCreateWatchers,nt as setVisualVariablesAndElevationInfoForUpdate,It as showProgressCursor,dt as sizeDefaults,yt as sizeVariableUnitToLengthUnit,ke as startCreatingNewFeature,rt as startUpdatingFeatureGeometry,lt as swapForEditingSession,kt as toFeatureInfos,_ as updateFeatureWorkflowInternalGraphicsLayerTitle,Fe as updateGraphicSymbolWhenRequired,it as visualVariableInteractiveUpdate,gt as whenEditorLayerView,ut as whenGraphicDisplayed,ye as workflowInfluencesOutcomeOfParent};
|
|
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{isGraphic as D}from"../../support/guards.js";import R from"../../symbols/SimpleFillSymbol.js";import G from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Z}from"../../symbols/support/symbolUtils.js";import{getServices as W}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as $}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as J}from"../../views/support/drapedUtils.js";import{filterGraphicHits as H,hitTestSelectSimilarDistance as K}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as X}from"./support/dependencySort.js";import{isDrawGraphicTool as Y}from"../Sketch/support/sketchUtils.js";const _="updateFeatureWorkflow-internal",ee=()=>d.getLogger("esri.widgets.Editor.workflowUtils");function te(e){return se(e)||ae(e)}function re(e){return!!e&&"features"in e}function ne(e){return null!=e&&"create-features"===e.type}function oe(e){return!!e&&"feature"in e}function ae(e){return null!=e&&"update-features"===e.type}function ie(e){return null!=e&&"update-feature"===e.type}function se(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function le(e){return null!=e&&"update"===e.type}function ce(e){return null!=e&&"merge-features"===e.type}function ue(e){return null!=e&&"split-feature"===e.type}function de(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function pe(e){return"merge"===e?.type}function fe(e){return"split"===e?.type}function ye(e){return ce(e)||ue(e)}function me(e){return"update-multiple"===e?.type}function he(e){const t=e&&"renderer"in e?e.renderer:null;if(!Se(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 ge(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&Se(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=he(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=be(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;a=ve(n,r)}return{rotation:o,size:a}}function be(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,Te((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function we(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function Ie(e,t,r){if(null==t)return 0;const{symbol:n}=N(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(dt.icon,(await e(o,dt.icon))[0])||dt.icon}case"text":return dt.text;case"line":return dt.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return we(await t(o,e.scale/dt.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/dt.viewScaleSizeFactor;default:return 0}}function ve(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)=>Te(i(await Ie(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Te(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:yt(e.valueUnit),axis:e.axis}}function Te(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 Se(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 Fe(e,t,r){const n=await Z(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function je(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:$,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 ke(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)||k(a)||await We(e,s,l,n,u?c.scale:null);const{capabilities:d}=s;t.elevationInfo=s.elevationInfo;const p=je(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 Ae(e){return s([Le(e),Ue(e)])}function Le({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=>We(r,a.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ue({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const a=r.activeComponent;if(!n||!Y(a))return ee().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=Me(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 Me(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new B({angle:0,color:r,outline:new G({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new R({color:r,outline:new G({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new G({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}})}function Oe(e,t){const r=W(t),n=q(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function xe(e,t){const r=Oe(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 qe(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function ze(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:a}=e,i=Ee(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ce(t,i,a),d=De(l,Pe(s,c),c);if(o&&Be(l,d,o),0===d.length)return t;const p=X(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=qe(e):h.id!==e.layerId&&(m.push(h),h=qe(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)??qe(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 Ee(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Pe(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Re(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(Re(n,e),t.keyField);break}}return r}function Ce(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 De(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=Re(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 Re(e,t){return`${e.layerId}:${t.id}`}function Ge(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 Be(e,t,r){const n=[];for(const a of e)Ge(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=[...Ne(a.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(a.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([a.uniqueId,e.uniqueId]);break;case"add":o=[...Ne(a.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(a.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,a.uniqueId])}}}function Ne(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)||k(e)?{}:A(e)?{...e.prototype.attributes,...t}:L(e)?{...e.definition?.defaultValues,...t}:{...t}}async function We(e,r,n,o,a){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=ge(i);let c=await Z(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 Z(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}Qe(e.tooltipOptions,l,s)}function Qe(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 $e(e,t){return e.find(e=>e.layer===t)}function Je(e,t){const r=$e(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 He(e,t){return e?.find(e=>e.layer===t)}async function Ke(e,t,r,n){switch(t.type){case"3d":return Xe(e,t,r,n);case"2d":return Ye(e,t,r,n)}}async function Xe(e,t,r,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:i}=await r.defer(async()=>{const{results:o}=await h(K(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};H(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=_e(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 Ye(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=H(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=_e(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=J(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 _e(e){return O(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function et(e,t,n,o){return tt(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function tt(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.returnGeometry=!0,o.outSpatialReference=r);const a=await t.queryFeatures(o,{signal:n});return m(n),a.features}async function rt(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:o}=e;await nt(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 nt(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 Fe(t,i,e)}Qe(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function ot(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function at(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function it(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=ot(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=at(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 st({feature:e,featureClone:t,visualVariableAttributes:r,sketchLayer:n,sketchViewModel:o,view:a,onUpdate:i,webStyleCache:u,addUpdatingPromise:d,addHandle:p}){await Fe(t,u,"2d"===a.type?a.scale:null);let y=null;if("2d"===o?.view?.type){const e=f(e=>Fe(t,u,e));y=g(()=>o?.view?.scale,t=>e(t))}const m=t.sourceLayer,h=gt(a,m);await rt({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 Fe(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 rt(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(),rt(s)}))}it(a,t,e,r)&&await Fe(t,u,"2d"===a.type?a.scale:null),i(wt(t),e)}),F=o.on(["undo","redo"],e=>{i(wt(e.graphics[0]),e)});return s([F,S,l(()=>o.cancel()),T,y])}async function lt(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 gt(t,o);m(r),n.setVisibility?.(i,e)})}return await ut(t,n),u(!1),s([ct(t,n,e=>u(!e)),l(async()=>{u(!0);try{if(!t.destroyed){const e=await gt(t,o).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}function ct(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return s([e.trackGraphicState(n),g(()=>n.displaying,r)])}return g(()=>t.visible,r)}async function ut(e,t){if("3d"===e.type){const r=new Q({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const dt={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function pt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function ft(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 yt(e){return"unknown"===e?null:e}function mt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const ht=e=>e.includes("-stop")||e.includes("vertex-"),gt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function bt(e){return"createInteractiveEditSession"in e}function wt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function It(e){return e.acquireCursor("progress")}async function vt(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 Tt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function St(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>Tt(e.relationships)),t.flatMap(e=>e.edits)):null}function Ft(e){const t=le(e)?e.activeWorkflow:e;if(null==t)return[];if(ae(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function jt({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 kt(e){if(!At(e))return 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}))}function At(e){return 0===e.length||D(e[0])}export{Be as appendAllUtilityNetworkAssociationRelationships,ft as avoidFeatureTemplateSelectionWithOnlyOneItem,bt as canCreateInteractiveEditSession,wt as cloneGraphicExceptMesh,Ee as createLayerIdMap,Pe as createRelationshipKeyMap,je as createToolFromGeometryType,pt as createWorkflowSteps,Ke as fetchCandidates,et as fetchFullFeatures,tt as fetchFullFeaturesByObjectId,De as findAllDependencies,Ne as findChangesByGlobalId,$e as findEditorItemForLayer,Je as findEditorItemForLayerOrThrow,He as findLayerInfo,Re as generateHashForRelationship,Ze as getCreationAttributes,vt as getFullTemplateForCreationInfo,Ft as getLayersFromWorkflow,be as getRotationVariableAttribute,St as getServiceEditsFromWorkflowData,Oe as getServiceInfoForLayer,xe as getServiceLayersById,ve as getSizeVariableAttribute,ge as getVisualVariableAttributes,he as getVisualVariablesForLayer,te as isAnyUpdateLeafWorkflow,re as isBatchAttributeFormViewModel,ne as isCreateFeaturesWorkflow,oe as isFeatureFormViewModel,At as isGraphicsArray,ce as isMergeFeaturesWorkflow,pe as isMergeWorkflowOptions,de as isParentWorkflow,ue as isSplitFeatureWorkflow,fe as isSplitWorkflowOptions,ht as isTerminalUpdateEventType,ie as isUpdateFeatureWorkflow,ae as isUpdateFeaturesWorkflow,me as isUpdateFeaturesWorkflowOptions,se as isUpdateRecordWorkflow,le as isUpdateWorkflow,Ge as isUtilityNetworkAssociationsTable,jt as makeMinimalAttributes,ze as orderEditsByRelationshipDependencies,mt as prepareAttachmentsForCreateFeaturesWorkflow,Tt as setRelationshipFields,st as setUpGeometryUpdate,Ae as setUpSketchCreateWatchers,nt as setVisualVariablesAndElevationInfoForUpdate,It as showProgressCursor,dt as sizeDefaults,yt as sizeVariableUnitToLengthUnit,ke as startCreatingNewFeature,rt as startUpdatingFeatureGeometry,lt as swapForEditingSession,kt as toFeatureInfos,_ as updateFeatureWorkflowInternalGraphicsLayerTitle,Fe as updateGraphicSymbolWhenRequired,it as visualVariableInteractiveUpdate,gt as whenEditorLayerView,ut as whenGraphicDisplayed,ye as workflowInfluencesOutcomeOfParent};
|