@arcgis/core 4.27.0-rc.0 → 4.27.0-rc.2
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/README.md +2 -2
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/actions/OrderBy.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0407bf97ad621c89a734.js +1 -0
- package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +1 -0
- package/assets/esri/core/workers/chunks/0a86c458916e83d6c523.js +1 -0
- package/assets/esri/core/workers/chunks/14145959a3dab1437818.js +1 -0
- package/assets/esri/core/workers/chunks/16db0bc87d87a7313dc4.js +1 -0
- package/assets/esri/core/workers/chunks/183e2e0cb86c1c640d94.js +1 -0
- package/assets/esri/core/workers/chunks/19d329b9d4ec2eff1d13.js +1 -0
- package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +1 -0
- package/assets/esri/core/workers/chunks/1f69fb9687de9ebfcf90.js +1 -0
- package/assets/esri/core/workers/chunks/2154d395f405be3cd3ba.js +1 -0
- package/assets/esri/core/workers/chunks/{33dbba3b7fc648437e50.js → 21e1f3b11e7d363b727a.js} +1 -1
- package/assets/esri/core/workers/chunks/{31a158c73994603c169d.js → 2446e336b1f7256d4fde.js} +1 -1
- package/assets/esri/core/workers/chunks/29290a44fd3b183c24e3.js +1 -0
- package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +1 -0
- package/assets/esri/core/workers/chunks/{f498c4d4831141125781.js → 2f5639886f577baedbca.js} +1 -1
- package/assets/esri/core/workers/chunks/33901eb1574e46abd9af.js +1 -0
- package/assets/esri/core/workers/chunks/{9c78ad5ab57e0d47ac43.js → 3ba2fcb9110230f8790c.js} +1 -1
- package/assets/esri/core/workers/chunks/3e239bfad611985e50fb.js +1 -0
- package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +1 -0
- package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
- package/assets/esri/core/workers/chunks/53ad34bf32f5f3d4fe18.js +1 -0
- package/assets/esri/core/workers/chunks/{97cdbec7532cfcdf9ad2.js → 595a2baa04d92de59558.js} +1 -1
- package/assets/esri/core/workers/chunks/{2e627c94e57c924e5917.js → 5e6471dd2a08e66b47d0.js} +79 -81
- package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +1 -0
- package/assets/esri/core/workers/chunks/{212d59764c275c763941.js → 659b7bad7281c0e2aed3.js} +1 -1
- package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +1 -0
- package/assets/esri/core/workers/chunks/6e562fa57c0347091154.js +1 -0
- package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +1 -0
- package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +1 -0
- package/assets/esri/core/workers/chunks/{e88cff2537be52da6531.js → 74fd2059ddda9083cbcc.js} +1 -1
- package/assets/esri/core/workers/chunks/7dc6774c77c822b68c99.js +1 -0
- package/assets/esri/core/workers/chunks/82a103a8b5382300889d.js +1 -0
- package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
- package/assets/esri/core/workers/chunks/{9849f64793f2ad39366b.js → 9290b0d330f02233d803.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
- package/assets/esri/core/workers/chunks/{36df72362b38759b895b.js → 9648a8f2b24f1ca3d637.js} +1 -1
- package/assets/esri/core/workers/chunks/{ad18fb7bb54a0c4bdb38.js → a20361b4d3bdd7d196ca.js} +1 -1
- package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +1 -0
- package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +1 -0
- package/assets/esri/core/workers/chunks/b2a423d9ce8bb784267c.js +1 -0
- package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
- package/assets/esri/core/workers/chunks/{df0453cdfe685d6436cc.js → b6dc41fce601b9d3480e.js} +1 -1
- package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +1 -0
- package/assets/esri/core/workers/chunks/c6617a937440701c0180.js +1 -0
- package/assets/esri/core/workers/chunks/d8607326a199dd994844.js +1 -0
- package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +1 -0
- package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
- package/assets/esri/core/workers/chunks/{39e473586579d11d6732.js → e2432871f1329f47465d.js} +1 -1
- package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +1 -0
- package/assets/esri/core/workers/chunks/{c83669cf08391a62fb72.js → f1da7b29eecad0e9efae.js} +1 -1
- package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
- package/assets/esri/core/workers/chunks/f505ebd4bd3bfb6c790d.js +1 -0
- package/assets/esri/core/workers/chunks/f6e68befe2812b90b40d.js +1 -0
- package/assets/esri/core/workers/chunks/{3c6c082157c916f8ddba.js → ffe61d5a6a9b34bee9d4.js} +1 -1
- package/assets/esri/themes/base/widgets/_Bookmarks.scss +5 -0
- package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
- package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
- package/assets/esri/themes/base/widgets/_Features.scss +5 -7
- package/assets/esri/themes/base/widgets/_Popup.scss +3 -3
- package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
- package/assets/esri/themes/base/widgets/_Swipe.scss +11 -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/chunks/DefaultMaterial.glsl.js +3 -2
- package/chunks/SSAO.glsl.js +1 -1
- package/chunks/ShadowCastAccumulate.glsl.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/core/timeUtils.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/DoubleArray.js +1 -1
- package/geometry/support/meshUtils/bounds.js +5 -0
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshVertexSpaceUtils.js +5 -0
- package/interfaces.d.ts +181 -33
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/controllers/StreamController.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/support/FeatureReductionBinning.js +1 -1
- package/layers/support/FeatureReductionCluster.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/rasterFunctions/colormaps.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/layers/video/videoUtils.js +5 -0
- package/package.json +2 -2
- package/renderers/support/utils.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/smartMapping/symbology/flow.js +1 -1
- package/statistics/utils.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/effects/EffectBuffer.js +1 -1
- package/symbols/cim/effects/EffectDonut.js +1 -1
- package/symbols/cim/effects/EffectOffset.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/features/Store2D.js +1 -1
- package/views/2d/layers/features/sources/StreamSource.js +1 -1
- package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/II3SMeshView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/webStyleUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
- package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +5 -0
- package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/webdoc/support/writeUtils.js +1 -1
- package/widgets/Bookmarks/css.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/Workflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/Feature/FeatureRelationship.js +1 -1
- package/widgets/FeatureForm/EditableInput.d.ts +2 -2
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
- package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.js +1 -1
- package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
- package/widgets/ValuePicker.js +1 -1
- package/assets/esri/core/workers/chunks/0b03165dbf289797cefa.js +0 -1
- package/assets/esri/core/workers/chunks/0c1c0024879f944f44c4.js +0 -1
- package/assets/esri/core/workers/chunks/13a48796905613bc1679.js +0 -1
- package/assets/esri/core/workers/chunks/1ea1104651ab15f9a13c.js +0 -1
- package/assets/esri/core/workers/chunks/2108cfc7921430f0b805.js +0 -1
- package/assets/esri/core/workers/chunks/2eacca322737aafd8f0c.js +0 -1
- package/assets/esri/core/workers/chunks/39577683e334eb4d904c.js +0 -1
- package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
- package/assets/esri/core/workers/chunks/3fe357df92afa1bee70a.js +0 -1
- package/assets/esri/core/workers/chunks/4d3deeb0ebd0ce8c1215.js +0 -1
- package/assets/esri/core/workers/chunks/576bddc3fa7d91a7e5bd.js +0 -1
- package/assets/esri/core/workers/chunks/623d6710a4f800c622ce.js +0 -1
- package/assets/esri/core/workers/chunks/6782cc3feb713676d544.js +0 -1
- package/assets/esri/core/workers/chunks/6e7178de0b2c3d2f7e6b.js +0 -1
- package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
- package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +0 -1
- package/assets/esri/core/workers/chunks/79d2baf392589588ef9b.js +0 -1
- package/assets/esri/core/workers/chunks/7bbdba52157da13a01fc.js +0 -1
- package/assets/esri/core/workers/chunks/7ec6be2bc0f354011e46.js +0 -1
- package/assets/esri/core/workers/chunks/84860b535a70ec448cfe.js +0 -1
- package/assets/esri/core/workers/chunks/9035d9e09a4e7cb94d37.js +0 -1
- package/assets/esri/core/workers/chunks/956b0fef7bc849415354.js +0 -1
- package/assets/esri/core/workers/chunks/9ab98321a4a7eaeeb018.js +0 -1
- package/assets/esri/core/workers/chunks/9cb7a68ff46e5c43e1d2.js +0 -1
- package/assets/esri/core/workers/chunks/a0f7f7f578521970c714.js +0 -1
- package/assets/esri/core/workers/chunks/a60eac45d3c65bd0216f.js +0 -1
- package/assets/esri/core/workers/chunks/aca5260f6984952a6e3d.js +0 -1
- package/assets/esri/core/workers/chunks/b05be356743fa5d24573.js +0 -1
- package/assets/esri/core/workers/chunks/ba6024465308c248170b.js +0 -1
- package/assets/esri/core/workers/chunks/d0983f808008920514f2.js +0 -1
- package/assets/esri/core/workers/chunks/dab832799bc06b0fec34.js +0 -1
- package/assets/esri/core/workers/chunks/e45d36aef2bc69ee9132.js +0 -1
- package/assets/esri/core/workers/chunks/e5bbd4cc5edbf7ab3624.js +0 -1
- package/assets/esri/core/workers/chunks/e700cf4d1f99291a4396.js +0 -1
- package/assets/esri/core/workers/chunks/f398a5cf33c3fd2522a5.js +0 -1
- package/assets/esri/core/workers/chunks/f4ee94a6cde4ea8837f1.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n}from"../../../core/promiseUtils.js";import{watch as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as y}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as b}from"../support/featureUtils.js";import{parseFormTemplateString as g,getFieldsInTitleAndDesc as F}from"../../FeatureForm/featureFormUtils.js";const _=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=u(this._queryController,_),this._queryFeatureCountDebounced=u(this._queryFeatureCountController,_),this._queryPageDebounced=u(this._queryPageController,_),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.handles.add([d((()=>[this.displayCount,this.graphic,this.layer,this.map,this.orderByFieldsFixedCasing,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),y),d((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),d((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>({feature:t,description:e?t.getAttribute(e):void 0,title:l?g(l,t.attributes,r.fieldsIndex):void 0}))).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?b(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,b=r?l:a,g=d.objectIdField,_=[...t.map((e=>e.field)),...F(d),g].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),q=new c({orderByFields:m,start:C,num:b,outFields:_,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:f.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_loaded",void 0),e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canLoad",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const f=m;export{f 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import d from"../Widget.js";import c from"./FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./support/FeatureElementInfo.js";import{loadCalciteComponents as h}from"../support/componentsUtils.js";import{isRTL as p}from"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as v}from"../support/jsxFactory.js";import{substitute as g}from"../../intl/substitute.js";const w="esri-feature",b=`${w}-relationship`,f={base:b,esriWidget:"esri-widget",listContainer:`${b}__list`,listItem:`${b}__list-item`,listItemHidden:`${b}__list-item--hidden`,listContainerQuerying:`${b}__list--querying`,featureObserver:`${w}__feature-observer`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingSpinnerContainer:`${w}__loading-container`,spinner:`${w}__loading-spinner`,iconLoading:"esri-icon-loading-indicator esri-rotating"},y={title:!0,description:!0};let F=class extends d{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.headingLevel=2,this.viewModel=new c,this.messages=null,this.messagesCommon=null,this.visibleElements={...y},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new u,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),r),i((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return h({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i}=this.viewModel;return!e&&!!t&&"ready"===i&&(t>s||0===s)}get displayListItems(){return this.displayShowAllButton||this.viewModel.relatedFeatureViewModels.length>0}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get featureCountDescription(){const{messages:e}=this,{featureCount:t}=this.viewModel;return g(e?.numberRecords,{number:t})}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...y,...e}}renderStickyLoading(){return"querying"===this.viewModel.state?v("div",{key:"sticky-loader",class:f.stickySpinnerContainer},this.renderLoadingIcon()):null}renderLoadingIcon(){return v("span",{class:this.classes(f.iconLoading,f.spinner)})}renderLoading(){return v("div",{key:"loading-container",class:f.loadingSpinnerContainer},this.renderLoadingIcon())}renderShowAllIconNode(){return v("calcite-icon",{scale:"s",icon:"list",slot:"content-end"})}renderChevronIconNode(){const e=p(this.container)?"chevron-left":"chevron-right";return v("calcite-icon",{scale:"s",icon:e,slot:"content-end"})}renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return v("calcite-list-item",{class:this.classes(f.listItem,{[f.listItemHidden]:i}),key:e.uid,label:s,description:e.description??"",onCalciteListItemSelect:()=>this.emit("select-record",{featureViewModel:e})},this.renderChevronIconNode())}renderShowAllListItem(){return this.displayShowAllButton?v("calcite-list-item",{key:"show-all-item",label:this.messages?.showAll,description:this.featureCountDescription,onCalciteListItemSelect:()=>this.emit("show-all-records")},this.renderShowAllIconNode()):null}renderNoRelatedFeaturesMessage(){return v("calcite-notice",{key:"no-related-features-message",icon:"information",open:!0,kind:"brand",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.noRelatedFeatures))}renderFeatureObserver(){return v("div",{key:"feature-observer",class:f.featureObserver,bind:this,afterCreate:this._relatedFeatureIntersectionObserverCreated})}renderList(){const{relatedFeatureViewModels:e}=this.viewModel;return v("calcite-list",null,e.toArray().map((e=>this.renderRelatedFeature(e))),this.renderShowAllListItem())}renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return v("div",{key:"list-container",class:this.classes(f.listContainer,{[f.listContainerQuerying]:"querying"===t})},e?this.renderList():"ready"===t?this.renderNoRelatedFeaturesMessage():null,this.renderStickyLoading(),this.renderFeatureObserver())}renderRelationshipNotFound(){return v("calcite-notice",{key:"relationship-not-found",icon:"exclamation-mark-triangle",open:!0,kind:"danger",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.relationshipNotFound))}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(f.base,f.esriWidget)},this._featureElementInfo?.render(),"loading"===e?this.renderLoading():"disabled"===e?this.renderRelationshipNotFound():this.renderRelatedFeatures())}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(i((()=>[e.title,e.state]),(()=>this.scheduleRender()),r),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([n()],F.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([n({readOnly:!0})],F.prototype,"displayShowAllButton",null),e([n({readOnly:!0})],F.prototype,"displayListItems",null),e([n()],F.prototype,"description",null),e([n({readOnly:!0})],F.prototype,"featureCountDescription",null),e([n()],F.prototype,"headingLevel",void 0),e([n()],F.prototype,"title",null),e([n({type:c})],F.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],F.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],F.prototype,"messagesCommon",void 0),e([n()],F.prototype,"visibleElements",void 0),e([l("visibleElements")],F.prototype,"castVisibleElements",null),F=e([a("esri.widgets.Feature.FeatureRelationship")],F);const _=F;export{_ 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return" ";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return" ";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>{const e=s._inputOrButtonNode;e&&(e.onblur=e=>{const t=e.relatedTarget;t&&t.className.includes("esri-date-picker")||s.close(!1)}),this.grid?.notifyResize()})),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
|
package/widgets/Features.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s}from"../core/reactiveUtils.js";import{throttle as r}from"../core/throttle.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import a from"./Feature.js";import c from"./Spinner.js";import d from"./Widget.js";import{CSS as u}from"./Feature/resources.js";import{FeatureContentMixin as h}from"./Feature/support/FeatureContentMixin.js";import p from"./Features/FeaturesViewModel.js";import m from"./Features/FeaturesVisibleElements.js";import{getPointFromGeometry as v}from"./Popup/actionUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as _}from"./support/decorators/messageBundle.js";import{vmEvent as g}from"./support/decorators/vmEvent.js";import{tsx as F}from"./support/jsxFactory.js";import{substitute as f}from"../intl/substitute.js";const M="esri-features",b={calciteModeLight:"calcite-mode-light",calciteModeDark:"calcite-mode-dark",esriWidget:"esri-widget",esriWidgetPanel:"esri-widget--panel",base:`${M}`,container:`${M}__container`,actionBar:`${M}__action-bar`,footerActions:`${M}__footer-actions`,featureMenuObserver:`${M}__feature-menu-observer`,actionExit:`${M}__action--exit`},y="selected-index",I=0,R="features-spinner";let x=class extends(h(d)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._exitRelatedRecordsActions=new WeakMap,this._featureSelectionActions=new WeakMap,this.icon=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.viewModel=new p,this.visibleElements=new m,this._renderAction=(e,t)=>{const i=this._getActionTitle(e);return F("calcite-action",{appearance:"solid",bind:this,icon:this._getActionIcon(e),onclick:this._triggerAction,"data-action-uid":e.uid,disabled:e.disabled,indicator:e.indicator,loading:e.active,active:"toggle"===e.type&&e.value,key:`action-${t}`,text:i},F("calcite-tooltip",{placement:"bottom",overlayPositioning:"fixed",label:i,slot:"tooltip"},i))},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._handleOpenRelatedFeature=e=>{this._openRelatedFeature(e)},this._displaySpinnerThrottled=r((()=>this._displaySpinner()),I),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop()))])}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect()}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _activeFlowItemWidget(){return this._relatedRecordsFlowItems.at(-1)??null}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new a({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),s=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>s?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(y),this.viewModel.open(e),this._addSelectedFeatureIndexHandle()}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return F("div",{class:this.classes(b.base,b.esriWidget,b.esriWidgetPanel)},this._renderContentContainer())}_renderFooter(){return this._featureNavigationVisible?F("div",{slot:"footer",class:b.footerActions,key:"footer-actions"},this._renderPagination(),this._renderFeatureMenuButton()):null}_renderFeatureMenuButton(){const{messages:e,messagesCommon:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=this.viewModel;return F("calcite-action-group",{layout:"horizontal"},s>0?F("calcite-action",{appearance:"solid",key:"feature-menu-loading-action",loading:!0,scale:"s",text:t.loading||"",label:t.loading||""}):F("calcite-action",{appearance:"solid",key:"feature-menu-button",bind:this,scale:"s",textEnabled:!0,label:e.selectFeature||"",text:f(e.pageText||"",{total:i,index:(o+1).toLocaleString(void 0,{minimumIntegerDigits:i.toString().length,useGrouping:!1})}),onclick:this._openFeatureMenu,icon:"list"},F("calcite-tooltip",{overlayPositioning:"fixed",label:e.selectFeature,placement:"bottom",slot:"tooltip"},e.selectFeature)))}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return F("calcite-action-group",{layout:"horizontal"},F("calcite-action",{appearance:"solid",label:e,text:e,iconFlipRtl:!0,icon:"chevron-left",scale:"s",onclick:this._previousFeature},F("calcite-tooltip",{placement:"bottom",overlayPositioning:"fixed",label:e,slot:"tooltip"},e)),F("calcite-action",{appearance:"solid",label:t,text:t,iconFlipRtl:!0,icon:"chevron-right",scale:"s",onclick:this._nextFeature},F("calcite-tooltip",{placement:"bottom",overlayPositioning:"fixed",label:t,slot:"tooltip"},t)))}_renderFeatureMenuItem(e,t){const{selectedFeatureViewModel:i}=this.viewModel,o=e===i;return F("calcite-list-item",{bind:this,key:`feature-menu-item-${e.uid}`,selected:o,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseover:this._setActiveFeature,onmouseleave:this._removeActiveFeature,"data-feature-index":t,onCalciteListItemSelect:this._selectFeature,label:e.title||this.messagesCommon.untitled})}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel;return e.length>1?F("calcite-list",{selectionMode:"single",selectionAppearance:"icon"},e.filter((e=>!!e.graphic)).map(((e,t)=>this._renderFeatureMenuItem(e,t)))):null}_renderContentFeature(){const{headingLevel:e,visibleElements:t}=this,{title:i,active:o}=this.viewModel,s=t.heading&&i?i:"";return F("calcite-flow-item",{bind:this,closed:!o,closable:t.closeButton,heading:s,headingLevel:e,onCalciteFlowItemClose:this.close,afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,key:"root-flow-item",onkeydown:this._onMainKeydown},this._renderActionBar(),F("div",{class:b.container},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r}=e;return t?F("calcite-flow-item",{bind:this,closable:!1,closed:!s,afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,loading:e.isLoadingFeature,heading:i.selectFeature,description:f(i.total,{total:r.length}),key:"feature-menu",onCalciteFlowItemBack:this._handleFeatureMenuBack},F("div",{class:b.container},this._renderFeatureMenu()),F("div",{class:b.featureMenuObserver,bind:this,afterCreate:this._featureMenuIntersectionObserverCreated}),F("calcite-button",{onclick:this._handleFeatureMenuBack,slot:"footer-actions",appearance:"transparent",width:"full"},o.back)):null}_renderContentContainer(){const{_relatedRecordsFlowItems:e}=this,{content:t}=this.viewModel,i=e.toArray();return F("calcite-flow",{key:t??"content"},this._renderContentFeature(),this._renderFeatureMenuContainer(),i.map((e=>this._renderRelatedRecordsFlowItem(e))),F("div",{key:"content-tooltips"},i.map((e=>this._renderRelatedRecordsFlowItemTooltips(e)))))}_renderActionBar(){return this.visibleElements.actionBar&&this.viewModel.allActions?.length?F("calcite-action-bar",{key:"header-action-bar",class:b.actionBar,layout:"horizontal",expandDisabled:!0},F("calcite-action-group",{layout:"horizontal"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?F("div",{class:u.contentNode,key:e,innerHTML:e}):this.renderNodeContent(e):null}_renderRelatedRecordsFlowItem(e){const{messages:t}=this,{visibleElements:i}=this,{active:o}=this.viewModel,s="graphic"in e&&!e.isTable;return F("calcite-flow-item",{bind:this,closed:!o,closable:i.closeButton,heading:e.title??"",description:this._getRelatedRecordsFlowItemDescription(e),onCalciteFlowItemBack:this._handleRelatedRecordsBackClick,onCalciteFlowItemClose:this.close,key:`flow-item-${e.viewModel.uid}`},F("calcite-action",{appearance:"transparent",class:b.actionExit,icon:"move-up",label:t.exitRelatedRecords,text:t.exitRelatedRecords,slot:"header-actions-start",bind:this,afterCreate:t=>this._storeExitRelatedRecordsAction(e,t),onclick:this._destroyRelatedRecordsFlowItemWidgets}),s?F("calcite-action",{appearance:"transparent",icon:"zoom-to-object",label:t.selectFeature,text:t.selectFeature,slot:"header-actions-end",bind:this,afterCreate:t=>this._storeFeatureSelectionAction(e,t),onclick:()=>this._handleOpenRelatedFeature(e)}):null,F("div",{class:b.container},e.render()))}_renderRelatedRecordsFlowItemTooltips(e){const{messages:t,_exitRelatedRecordsActions:i,_featureSelectionActions:o}=this,s=o.get(e);return[F("calcite-tooltip",{key:`exit-related-records-tooltip-${e.viewModel.uid}`,label:t.exitRelatedRecords,overlayPositioning:"fixed",referenceElement:i.get(e),placement:"top"},t.exitRelatedRecords),s?F("calcite-tooltip",{key:`select-related-record-tooltip-${e.viewModel.uid}`,label:t.selectFeature,overlayPositioning:"fixed",referenceElement:s,placement:"top"},t.selectFeature):null]}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon||"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",l="zoom-to-feature"===s?f(n,{messages:t}):"remove-selected-feature"===s?f(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?f(n,{messages:t}):e.title;return l&&r?f(l,r):l??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_storeFeatureSelectionAction(e,t){this._featureSelectionActions.set(e,t),this.scheduleRender()}_storeExitRelatedRecordsAction(e,t){this._exitRelatedRecordsActions.set(e,t),this.scheduleRender()}_getRelatedRecordsFlowItemDescription(e){return"featureCountDescription"in e?e.featureCountDescription:e.viewModel.description??""}_handleRelatedRecordsBackClick(){const e=this._relatedRecordsFlowItems.pop();e&&(this._exitRelatedRecordsActions.delete(e),this._featureSelectionActions.delete(e),"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=v(i);this.open({features:[t],location:null!=o?o:void 0})}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,y)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:R,position:"manual"}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,R),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([n()],x.prototype,"_focusFeatureMenuFlowItem",void 0),e([n()],x.prototype,"_relatedRecordsFlowItems",void 0),e([n()],x.prototype,"_focusRootFlowItem",void 0),e([n()],x.prototype,"_featureNavigationVisible",null),e([n()],x.prototype,"_activeFlowItemWidget",null),e([n()],x.prototype,"content",null),e([n()],x.prototype,"icon",void 0),e([n()],x.prototype,"featureMenuOpen",null),e([n()],x.prototype,"features",null),e([n()],x.prototype,"headingLevel",void 0),e([n()],x.prototype,"location",null),e([n()],x.prototype,"label",null),e([n(),_("esri/widgets/Features/t9n/Features")],x.prototype,"messages",void 0),e([n(),_("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([n()],x.prototype,"promises",null),e([n({readOnly:!0})],x.prototype,"selectedFeature",null),e([n()],x.prototype,"selectedFeatureIndex",null),e([n({readOnly:!0})],x.prototype,"selectedFeatureWidget",null),e([n()],x.prototype,"title",null),e([n()],x.prototype,"updateLocationEnabled",null),e([n()],x.prototype,"view",null),e([n({type:p}),g(["triggerAction","trigger-action"])],x.prototype,"viewModel",void 0),e([n({type:m,nonNullable:!0})],x.prototype,"visibleElements",void 0),e([n()],x.prototype,"visible",null),x=e([l("esri.widgets.Features")],x);const C=x;export{C as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s}from"../core/reactiveUtils.js";import{throttle as r}from"../core/throttle.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import a from"./Feature.js";import c from"./Spinner.js";import d from"./Widget.js";import{CSS as u}from"./Feature/resources.js";import{FeatureContentMixin as h}from"./Feature/support/FeatureContentMixin.js";import p from"./Features/FeaturesViewModel.js";import m from"./Features/FeaturesVisibleElements.js";import{getPointFromGeometry as v}from"./Popup/actionUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as _}from"./support/decorators/messageBundle.js";import{vmEvent as g}from"./support/decorators/vmEvent.js";import{tsx as F}from"./support/jsxFactory.js";import{substitute as f}from"../intl/substitute.js";const M="esri-features",b={calciteModeLight:"calcite-mode-light",calciteModeDark:"calcite-mode-dark",esriWidget:"esri-widget",esriWidgetPanel:"esri-widget--panel",base:`${M}`,container:`${M}__container`,contentFeature:`${M}__content-feature`,footer:`${M}__footer`,featureMenuObserver:`${M}__feature-menu-observer`,actionExit:`${M}__action--exit`},y="selected-index",I=0,R="features-spinner";let x=class extends(h(d)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._exitRelatedRecordsActions=new WeakMap,this._featureSelectionActions=new WeakMap,this.icon=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.viewModel=new p,this.visibleElements=new m,this._renderAction=(e,t)=>{const i=this._getActionTitle(e);return F("calcite-action",{appearance:"solid",bind:this,icon:this._getActionIcon(e),onclick:this._triggerAction,"data-action-uid":e.uid,disabled:e.disabled,indicator:e.indicator,loading:e.active,active:"toggle"===e.type&&e.value,key:`action-${t}`,text:i},F("calcite-tooltip",{placement:"bottom",overlayPositioning:"fixed",label:i,slot:"tooltip"},i))},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._handleOpenRelatedFeature=e=>{this._openRelatedFeature(e)},this._displaySpinnerThrottled=r((()=>this._displaySpinner()),I),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop()))])}loadDependencies(){return w({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect()}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _activeFlowItemWidget(){return this._relatedRecordsFlowItems.at(-1)??null}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new a({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),s=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>s?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(y),this.viewModel.open(e),this._addSelectedFeatureIndexHandle()}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return F("div",{class:this.classes(b.base,b.esriWidget,b.esriWidgetPanel)},this._renderContentContainer())}_renderFooter(){return this._featureNavigationVisible?F("div",{slot:"footer",class:b.footer,key:"footer-actions"},this._renderPagination(),this._renderFeatureMenuButton()):null}_renderFeatureMenuButton(){const{messages:e,messagesCommon:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=this.viewModel;return F("calcite-action-group",{layout:"horizontal"},s>0?F("calcite-action",{appearance:"solid",key:"feature-menu-loading-action",loading:!0,scale:"s",text:t.loading||"",label:t.loading||""}):F("calcite-action",{appearance:"solid",key:"feature-menu-button",bind:this,scale:"s",textEnabled:!0,label:e.selectFeature||"",text:f(e.pageText||"",{total:i,index:(o+1).toLocaleString(void 0,{minimumIntegerDigits:i.toString().length,useGrouping:!1})}),onclick:this._openFeatureMenu,icon:"list"},F("calcite-tooltip",{overlayPositioning:"fixed",label:e.selectFeature,placement:"bottom",slot:"tooltip"},e.selectFeature)))}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return F("calcite-action-group",{layout:"horizontal"},F("calcite-action",{appearance:"solid",label:e,text:e,iconFlipRtl:!0,icon:"chevron-left",scale:"s",onclick:this._previousFeature},F("calcite-tooltip",{placement:"bottom",overlayPositioning:"fixed",label:e,slot:"tooltip"},e)),F("calcite-action",{appearance:"solid",label:t,text:t,iconFlipRtl:!0,icon:"chevron-right",scale:"s",onclick:this._nextFeature},F("calcite-tooltip",{placement:"bottom",overlayPositioning:"fixed",label:t,slot:"tooltip"},t)))}_renderFeatureMenuItem(e,t){const{selectedFeatureViewModel:i}=this.viewModel,o=e===i;return F("calcite-list-item",{bind:this,key:`feature-menu-item-${e.uid}`,selected:o,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseover:this._setActiveFeature,onmouseleave:this._removeActiveFeature,"data-feature-index":t,onCalciteListItemSelect:this._selectFeature,label:e.title||this.messagesCommon.untitled})}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel;return e.length>1?F("calcite-list",{selectionMode:"single",selectionAppearance:"icon"},e.filter((e=>!!e.graphic)).map(((e,t)=>this._renderFeatureMenuItem(e,t)))):null}_renderContentFeature(){const{headingLevel:e,visibleElements:t}=this,{title:i,active:o}=this.viewModel,s=t.heading&&i?i:"";return F("calcite-flow-item",{bind:this,closed:!o,class:b.contentFeature,closable:t.closeButton,heading:s,headingLevel:e,onCalciteFlowItemClose:this.close,afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,key:"root-flow-item",onkeydown:this._onMainKeydown},this._renderActionBar(),F("div",{class:b.container},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r}=e;return t?F("calcite-flow-item",{bind:this,closable:!1,closed:!s,afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,loading:e.isLoadingFeature,heading:i.selectFeature,description:f(i.total,{total:r.length}),key:"feature-menu",onCalciteFlowItemBack:this._handleFeatureMenuBack},F("div",{class:b.container},this._renderFeatureMenu()),F("div",{class:b.featureMenuObserver,bind:this,afterCreate:this._featureMenuIntersectionObserverCreated}),F("calcite-button",{onclick:this._handleFeatureMenuBack,slot:"footer-actions",appearance:"transparent",width:"full"},o.back)):null}_renderContentContainer(){const{_relatedRecordsFlowItems:e}=this,{content:t}=this.viewModel,i=e.toArray();return F("calcite-flow",{key:t??"content"},this._renderContentFeature(),this._renderFeatureMenuContainer(),i.map((e=>this._renderRelatedRecordsFlowItem(e))),F("div",{key:"content-tooltips"},i.map((e=>this._renderRelatedRecordsFlowItemTooltips(e)))))}_renderActionBar(){return this.visibleElements.actionBar&&this.viewModel.allActions?.length?F("calcite-action-bar",{key:"header-action-bar",expandDisabled:!0,slot:"action-bar"},F("calcite-action-group",null,this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?F("div",{class:u.contentNode,key:e,innerHTML:e}):this.renderNodeContent(e):null}_renderRelatedRecordsFlowItem(e){const{messages:t}=this,{visibleElements:i}=this,{active:o}=this.viewModel,s="graphic"in e&&!e.isTable;return F("calcite-flow-item",{bind:this,closed:!o,closable:i.closeButton,heading:e.title??"",description:this._getRelatedRecordsFlowItemDescription(e),onCalciteFlowItemBack:this._handleRelatedRecordsBackClick,onCalciteFlowItemClose:this.close,key:`flow-item-${e.viewModel.uid}`},F("calcite-action",{appearance:"transparent",class:b.actionExit,icon:"move-up",label:t.exitRelatedRecords,text:t.exitRelatedRecords,slot:"header-actions-start",bind:this,afterCreate:t=>this._storeExitRelatedRecordsAction(e,t),onclick:this._destroyRelatedRecordsFlowItemWidgets}),s?F("calcite-action",{appearance:"transparent",icon:"zoom-to-object",label:t.selectFeature,text:t.selectFeature,slot:"header-actions-end",bind:this,afterCreate:t=>this._storeFeatureSelectionAction(e,t),onclick:()=>this._handleOpenRelatedFeature(e)}):null,F("div",{class:b.container},e.render()))}_renderRelatedRecordsFlowItemTooltips(e){const{messages:t,_exitRelatedRecordsActions:i,_featureSelectionActions:o}=this,s=o.get(e);return[F("calcite-tooltip",{key:`exit-related-records-tooltip-${e.viewModel.uid}`,label:t.exitRelatedRecords,overlayPositioning:"fixed",referenceElement:i.get(e),placement:"top"},t.exitRelatedRecords),s?F("calcite-tooltip",{key:`select-related-record-tooltip-${e.viewModel.uid}`,label:t.selectFeature,overlayPositioning:"fixed",referenceElement:s,placement:"top"},t.selectFeature):null]}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon||"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",l="zoom-to-feature"===s?f(n,{messages:t}):"remove-selected-feature"===s?f(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?f(n,{messages:t}):e.title;return l&&r?f(l,r):l??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_storeFeatureSelectionAction(e,t){this._featureSelectionActions.set(e,t),this.scheduleRender()}_storeExitRelatedRecordsAction(e,t){this._exitRelatedRecordsActions.set(e,t),this.scheduleRender()}_getRelatedRecordsFlowItemDescription(e){return"featureCountDescription"in e?e.featureCountDescription:e.viewModel.description??""}_handleRelatedRecordsBackClick(){const e=this._relatedRecordsFlowItems.pop();e&&(this._exitRelatedRecordsActions.delete(e),this._featureSelectionActions.delete(e),"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=v(i);this.open({features:[t],location:null!=o?o:void 0})}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,y)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:R,position:"manual"}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,R),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([n()],x.prototype,"_focusFeatureMenuFlowItem",void 0),e([n()],x.prototype,"_relatedRecordsFlowItems",void 0),e([n()],x.prototype,"_focusRootFlowItem",void 0),e([n()],x.prototype,"_featureNavigationVisible",null),e([n()],x.prototype,"_activeFlowItemWidget",null),e([n()],x.prototype,"content",null),e([n()],x.prototype,"icon",void 0),e([n()],x.prototype,"featureMenuOpen",null),e([n()],x.prototype,"features",null),e([n()],x.prototype,"headingLevel",void 0),e([n()],x.prototype,"location",null),e([n()],x.prototype,"label",null),e([n(),_("esri/widgets/Features/t9n/Features")],x.prototype,"messages",void 0),e([n(),_("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([n()],x.prototype,"promises",null),e([n({readOnly:!0})],x.prototype,"selectedFeature",null),e([n()],x.prototype,"selectedFeatureIndex",null),e([n({readOnly:!0})],x.prototype,"selectedFeatureWidget",null),e([n()],x.prototype,"title",null),e([n()],x.prototype,"updateLocationEnabled",null),e([n()],x.prototype,"view",null),e([n({type:p}),g(["triggerAction","trigger-action"])],x.prototype,"viewModel",void 0),e([n({type:m,nonNullable:!0})],x.prototype,"visibleElements",void 0),e([n()],x.prototype,"visible",null),x=e([l("esri.widgets.Features")],x);const C=x;export{C 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{fetchMessageBundle as u}from"../../intl/messages.js";import p from"../../layers/support/CodedValueDomain.js";import d from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as g,getFeaturesFromLayers as m}from"../../networks/support/utils.js";import{trace as y}from"../../rest/networks/trace.js";import f from"../../rest/networks/support/TraceLocation.js";import w from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as _}from"./support/GeometryHandler.js";import{GraphicHandler as b}from"./support/GraphicHandler.js";import{ResultAreaHandler as v}from"./support/ResultAreaHandler.js";const A=()=>u("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),R=()=>u("esri/core/t9n/Units");function I(e){return e instanceof p}function F(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function T(e){return void 0!==e.layerViews}let k=class extends(a(i.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._traces=[],this._traceResults=[],this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.utilityNetwork=null}initialize(){this._geometryHandler=new _,this._graphicHandler=new b,this._resultAreaHandler=new v;(async()=>{const[e,t]=await Promise.all([A(),R()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new r("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const s=e=>{const t=this.view?.popup;t&&(t.autoOpenEnabled=e)};return new Promise(((r,i)=>{s(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),r(i)})).catch((r=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(r)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const s=this.flags.map((async e=>{if(e.mapPoint){const s=new h({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),r={screenPoint:this.view.toScreen(s),mapPoint:s};await this.queryFlagByHitTest(r,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(s),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const s=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,s)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),s=[];for(const e in t)s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((t=>{const s=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)s.push(e.geometry);const r=Array(s.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,s,r)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:s}=this,{results:r}=e;if(s&&r)for(const i in r.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=r.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(l,s.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,s.spatialReference);s.graphics.add(e)}}}}addTerminal(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||s.selectedTerminals?.push(parseInt(e,10)))})),this._flags=s}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this._traceResults.length>0&&this._traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this._traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const s=e,r=new w({gdbVersion:this.gdbVersion,moment:null,traceType:s.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:s.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(s,this.utilityNetwork.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){s.resultArea={...this.resultAreaProperties};const e=[...s.results.elements];s.results.elements.length=0;const r=new Map;for(const t of e)r.has(t.globalId)||(r.set(t.globalId,!0),s.results.elements.push(t));const i=[...this._traceResults];i.splice(t,0,s),this._traceResults=i,null!==s.results&&(this.selectOnComplete&&this.mergeSelection(!0,s.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(s,s.graphicColor),this.enableResultArea&&s.resultArea.show&&this.addResultAreaToMap(s))}else{const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}this._activeProgress=!1}else{this._activeProgress=!1;const s=[...this._traceResults];s.splice(t,0,e),this._traceResults=s}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color??=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const s=[...this._traceResults];s.length>0&&s.forEach((s=>{s.trace.globalId===t.trace.globalId&&(s.graphicColor=e,s.graphicEnabled=!0)})),this._traceResults=s,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((s=>{s.type===e&&t&&s.mapGraphic&&(s.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const s=this._flags.some((e=>"starting-point"===e.type)),r=this._flags.filter((e=>null!==e.allTerminals));r.length>0&&(t=r.some((e=>e.selectedTerminals.length<=0)));let i=[];return s?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this._traceResults;if(t.length>0){const s=t.filter((t=>t.trace.globalId===e.globalId));s.length>0&&(this.removeResultGraphicFromView(s[0]),this.removeResultAreaToMap(s[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this._traceResults=t,0===t.length?(this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,s){if(!this.view)return;let r=[];if(r="convexhull"===this.resultAreaProperties?.type?this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,s,e.resultArea?.unit,!0),r&&r?.length>0)for(const i of r){const t=this.getResultAreaAttributes(e,i),s=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,y(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,s){const{messages:r}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+r.attributeStrings.globalid+":"+e.globalId+";"+r.attributeStrings.terminalid+":"+e.terminalId+";"+r.attributeStrings.x+":"+e.mapPoint?.x+";"+r.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(s,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof d){try{const t=e.map;await t.loadAll(),this._populateOutfields()}catch(r){this._populateOutfields()}return this.utilityNetwork}return null}const t=e.map,s=t.utilityNetworks?.at(0);if(s){await s.load(),this.utilityNetwork=s;try{await t.loadAll(),this._populateOutfields()}catch(r){}finally{this._populateOutfields()}return s}return null}manageFilterBarrier(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&"barrier"===t.type&&s.id===t.id&&(s.isFilterBarrier=e)})),this._flags=s}mergeSelection(e,t){let s=[];const r=[...this._traceResults],i=t.globalId;r.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!=t.results&&null!==t.results.elements&&(s=[...s,...t.results.elements??[]])})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const r=g(this.utilityNetwork,e),i=this._getUniqueMapLayerViews(t),a={layerUrl:r[0].layerUrl,objectIds:r[0].objectIds,outFields:["*"]},l=i.filter((e=>e.layer?.parsedUrl?.path===r[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const r=new s,i=e.layer;r.add(i);const l={layers:r,layerInfos:[a],returnGeometry:!0,outSpatialReference:t.spatialReference};return(await m(l))[0]})))).filter((e=>e.featureSet.features.length>0));return e.length>0?e:null}return null}queryFlagByHitTest(e,t,s){return this._lookupFlagByHit(e).then((e=>{const{view:r}=this;if(!r)return!1;if(e.length>0){const i=[...this._flags],a=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(i.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}})),this._flags=i,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const s=t.graphics;e.graphicEnabled=!1;s.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{t.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeResultAreaGrahicsLayer(){this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map)}removeResultAreaToMap(e){e.resultArea.show=!1,this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map)}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const s=[...this._flags];s.forEach((s=>{if(s.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const r=t.selectedTerminals.indexOf(parseInt(e,10));s.selectedTerminals?.splice(r,1)}})),this._flags=s}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this._traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this.view.graphics.removeAll(),this.removeResultAreaGrahicsLayer(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const s=g(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{e.layer?.parsedUrl?.path===s[0].layerUrl&&F(e)&&this._highlightHandler.push(e.highlight(s[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),s=[];for(const e in t)this.selectFeaturesById(t[e]),s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const s=[...this._traces];s.forEach((s=>{t===s.globalId&&(s.selected=e)})),this._traces=s}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).forEach((e=>{switch(e.layer.type){case"group":if(T(e))for(const s of e.layerViews)t.push(s);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((s=>{const r=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",s="";const r=e.layer;t=this._checkParentForData(r,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(s=e.attributes[i],"assetgroup"===a||"assettype"===a?s=this._checkSubtype(r,r.subtypeCode):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))}return{field:t,value:s.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const a=i.toLowerCase();if(a===s?.toLowerCase())if(r=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,a),""===s&&(t.templates&&t.templates.length>0?(s=t.templates[0]?.name,r=t.templates[0]?.name):(s=t.displayField,r=e.attributes[i]))}else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t));else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t))}return{field:s,value:r?r.toString():""}}_checkSubtype(e,t){let s=t;if("subtype-sublayer"===e.type){const r=this._checkParentForData(e,"subtypes");r?.length>0&&r.forEach((e=>{e.code===t&&(s=e.name)}))}else if(null!=e.types&&e.types.length>0){const r=e.types.filter((e=>e.id===t));r.length>0&&(s=r[0].name)}return s}_checkDomain(e,t,s){let r=s;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&I(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===s));e.length>0&&(r=e[0].name)}return r}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint).then((t=>{const s=[];if(t.results.length>0){const r=t.results.find((e=>null!==e.layer));if(r.graphic&&null!=r.graphic.geometry)if("polyline"===r.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(r.graphic.geometry,e.mapPoint,r.graphic.geometry.spatialReference),i=this._getDisplayField(r.graphic);r.graphic.terminalId=null,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=null,r.graphic.selectedTerminals=null,r.graphic.percentAlong=t,r.graphic.displayValue=i,r.graphic.mapPoint=r.mapPoint,s.push(r)}else if(("point"===r.graphic.geometry.type||"polygon"===r.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id||null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e??null,r.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],r.graphic.percentAlong=null,r.graphic.displayValue=t,r.graphic.mapPoint=r.mapPoint,s.push(r)}}return s}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this.view?.graphics.remove(e.mapGraphic)}};e([n()],k.prototype,"_activeProgress",void 0),e([n()],k.prototype,"_flags",void 0),e([n()],k.prototype,"_traces",void 0),e([n()],k.prototype,"_traceResults",void 0),e([n()],k.prototype,"defaultGraphicColor",void 0),e([n()],k.prototype,"enableResultArea",void 0),e([n()],k.prototype,"flags",void 0),e([n()],k.prototype,"gdbVersion",void 0),e([n()],k.prototype,"messages",void 0),e([n()],k.prototype,"messagesUnits",void 0),e([n()],k.prototype,"resultAreaProperties",null),e([n()],k.prototype,"selectedTraces",void 0),e([n()],k.prototype,"selectOnComplete",void 0),e([n()],k.prototype,"showGraphicsOnComplete",void 0),e([n()],k.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],k.prototype,"state",null),e([n()],k.prototype,"utilityNetwork",void 0),e([n({value:null})],k.prototype,"view",null),k=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],k);const S=k;export{S as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as a}from"../../core/HandleOwner.js";import l from"../../core/Logger.js";import{when as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Point.js";import{fetchMessageBundle as u}from"../../intl/messages.js";import p from"../../layers/support/CodedValueDomain.js";import d from"../../networks/UtilityNetwork.js";import{getObjectIdsFromElements as g,getFeaturesFromLayers as m}from"../../networks/support/utils.js";import{trace as y}from"../../rest/networks/trace.js";import f from"../../rest/networks/support/TraceLocation.js";import w from"../../rest/networks/support/TraceParameters.js";import{GeometryHandler as _}from"./support/GeometryHandler.js";import{GraphicHandler as b}from"./support/GraphicHandler.js";import{ResultAreaHandler as v}from"./support/ResultAreaHandler.js";const A=()=>u("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),R=()=>u("esri/core/t9n/Units");function I(e){return e instanceof p}function T(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function F(e){return void 0!==e.layerViews}let k=class extends(a(i.EventedAccessor)){constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._geometryHandler=null,this._graphicHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._traces=[],this._watchHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){this._geometryHandler=new _,this._graphicHandler=new b,this._resultAreaHandler=new v;(async()=>{const[e,t]=await Promise.all([A(),R()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e})}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new r("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e)}addFlagByHit(e,t){const s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise(((r,i)=>{s(!1),this._clickHandler?.remove(),this.emit("add-flag",{type:e}),this._clickHandler=this.view?.on("click",(a=>{this.queryFlagByHitTest(a,e,t).then((i=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-complete",{type:e,symbol:t}),r(i)})).catch((r=>{s(!0),this._clickHandler?.remove(),this.emit("add-flag-error",{type:e,symbol:t}),i(r)}))}))}))}async addFlagsOnLoad(){return new Promise((e=>{const t=[];this._watchHandler=o((()=>null!=this.view&&!this.view.updating),(async()=>{if(this._flags.length>0)e(t);else{const s=this.flags.map((async e=>{if(e.mapPoint){const s=new h({x:e.mapPoint.x,y:e.mapPoint.y,spatialReference:e.mapPoint.spatialReference.wkid}),r={screenPoint:this.view.toScreen(s),mapPoint:s};await this.queryFlagByHitTest(r,e.type)||("barrier"===e.type?t.push("barrier"):t.push("starting-point"))}}));await Promise.all(s),e(t)}}),{initial:!0})}))}addResultAreaToMap(e){if(e.resultArea.show=!0,null!==e.results?.aggregatedGeometry){const t=this._geometryHandler.mergeAggregatedToGeometries(e.results?.aggregatedGeometry);if(t.length>0){const s=Array(t.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,t,s)}}else{const t=this._groupResultsByNetworkSource(e.results.elements),s=[];for(const e in t)s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((t=>{const s=[];for(const e of t)for(const t of e)for(const e of t.featureSet.features)s.push(e.geometry);const r=Array(s.length).fill(e.resultArea?.distance);this.createResultAreaGeometries(e,s,r)})).catch((e=>{console.log(e)}))}}async addResultGraphicToView(e,t){const{view:s}=this,{results:r}=e;if(s&&r)for(const i in r.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=r.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const r=await this._geometryHandler.projectGeometry(l,s.spatialReference),i={globalid:e.trace.globalId};if(null!==r){const e=this._graphicHandler.makeGraphic(r,t.color,i,s.spatialReference);s.graphics.add(e)}}}}addTerminal(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||s.selectedTerminals?.push(parseInt(e,10)))})),this._flags=s}async callTrace(){const e=this._traces.filter((e=>e.selected));return e.length>0&&(this.traceResults.length>0&&this.traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this.traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const s=e,r=new w({gdbVersion:this.gdbVersion,moment:null,traceType:s.traceType,traceLocations:this._flags,namedTraceConfigurationGlobalId:s.globalId,traceConfiguration:null,outSpatialReference:null,resultTypes:null});await this.executeTrace(s,this.utilityNetwork.networkServiceUrl,r).then((e=>{if(e.hasOwnProperty("results")){const s={...e};if(null!==s.results){s.resultArea={...this.resultAreaProperties};const e=[...s.results.elements];s.results.elements.length=0;const r=new Map;for(const t of e)r.has(t.globalId)||(r.set(t.globalId,!0),s.results.elements.push(t));const i=[...this.traceResults];i.splice(t,0,s),this.traceResults=i,null!==s.results&&(this.selectOnComplete&&this.mergeSelection(!0,s.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(s,s.graphicColor),this.enableResultArea&&s.resultArea.show&&this.addResultAreaToMap(s))}else{const s=[...this.traceResults];s.splice(t,0,e),this.traceResults=s}this._activeProgress=!1}else{this._activeProgress=!1;const s=[...this.traceResults];s.splice(t,0,e),this.traceResults=s}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}changeResultAreaColor(e,t){e.resultArea&&(e.resultArea.color??=t,this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map))}changeResultGraphicColor(e,t){const s=[...this.traceResults];s.length>0&&s.forEach((s=>{s.trace.globalId===t.trace.globalId&&(s.graphicColor=e,s.graphicEnabled=!0)})),this.traceResults=s,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((s=>{s.type===e&&t&&s.mapGraphic&&(s.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]};let t=!1;const s=this._flags.some((e=>"starting-point"===e.type)),r=this._flags.filter((e=>null!==e.allTerminals));r.length>0&&(t=r.some((e=>e.selectedTerminals.length<=0)));let i=[];return s?(i=this._traces.filter((e=>e.selected)),i.length<=0?(e.status=!1,e.issues=["noTrace"],t&&(e.status=!1,e.issues=["noTrace","noTerminalSelected"])):t&&(e.status=!1,e.issues=["noTerminalSelected"])):(i=this._traces.filter((e=>!0===e.selected)),i.length>0?(e.status=!1,e.issues=["noStart"],t&&(e.status=!1,e.issues=["noStart","noTerminalSelected"])):(e.status=!1,e.issues=["noStart","noTrace"],t&&(e.status=!1,e.issues=["noStart","noTrace","noTerminalSelected"]))),e}checkSelectionExist(){let e=!1;return this._highlightHandler.some((t=>{t&&(e=!0)})),e}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const s=t.filter((t=>t.trace.globalId===e.globalId));s.length>0&&(this.removeResultGraphicFromView(s[0]),this.removeResultAreaToMap(s[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this.traceResults=t,0===t.length?(this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,s){if(!this.view||!this.resultAreaProperties)return;let r;if("convexhull"===this.resultAreaProperties?.type?r=this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):t&&(r=this._resultAreaHandler?.createBuffer(t,s,e.resultArea?.unit,!0)),r&&Array.isArray(r)){if(r.length>0)for(const i of r){const t=this.getResultAreaAttributes(e,i),s=this._resultAreaHandler?.createResultAreaGraphic(i,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);s&&this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}else{const t=this.getResultAreaAttributes(e,r),s=this._resultAreaHandler?.createResultAreaGraphic(r,t,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);s&&this._resultAreaHandler?.addResultAreaToMap(s,this.view.map)}}executeTrace(e,t,s){const r=this._processFlags(s.traceLocations);return s.traceLocations=r,y(t,s).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}getResultAreaAttributes(e,s){const{messages:r}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+r.attributeStrings.globalid+":"+e.globalId+";"+r.attributeStrings.terminalid+":"+e.terminalId+";"+r.attributeStrings.x+":"+e.mapPoint?.x+";"+r.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:this.gdbVersion,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:this._geometryHandler.calculateArea(s,e.resultArea?.areaUnit)}}getValidSources(){let e=[];const t=this.utilityNetwork.dataElement?.domainNetworks??[];for(const s of t)e=e.concat(s.junctionSources),e=e.concat(s.edgeSources);return e}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof d){try{const t=e.map;await t.loadAll(),this._populateOutfields()}catch(r){this._populateOutfields()}return this.utilityNetwork}return null}const t=e.map,s=t.utilityNetworks?.at(0);if(s){await s.load(),this.utilityNetwork=s;try{await t.loadAll(),this._populateOutfields()}catch(r){}finally{this._populateOutfields()}return s}return null}manageFilterBarrier(e,t){const s=[...this._flags];s.forEach((s=>{s.globalId===t.globalId&&"barrier"===t.type&&s.id===t.id&&(s.isFilterBarrier=e)})),this._flags=s}mergeSelection(e,t){let s=[];const r=[...this.traceResults],i=t.globalId;r.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!=t.results&&null!==t.results.elements&&(s=[...s,...t.results.elements??[]])})),this.selectResults([...new Set(s)])}async queryFeaturesById(e){const{view:t}=this;if(!t)return null;const r=g(this.utilityNetwork,e),i=this._getUniqueMapLayerViews(t),a={layerUrl:r[0].layerUrl,objectIds:r[0].objectIds,outFields:["*"]},l=i.filter((e=>e.layer?.parsedUrl?.path===r[0].layerUrl));if(l.length>0){const e=(await Promise.all(l.map((async e=>{const r=new s,i=e.layer;r.add(i);const l={layers:r,layerInfos:[a],returnGeometry:!0,outSpatialReference:t.spatialReference};return(await m(l))[0]})))).filter((e=>e.featureSet.features.length>0));return e.length>0?e:null}return null}queryFlagByHitTest(e,t,s){return this._lookupFlagByHit(e).then((e=>{const{view:r}=this;if(!r)return!1;if(e.length>0){const i=[...this._flags],a=s;return e.forEach((e=>{const s=e.graphic,l=s.attributes.hasOwnProperty("GLOBALID")?s.attributes.GLOBALID:s.attributes.globalid;if(i.filter((e=>e.globalId===l)).length<=0){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}else if(null!==s.percentAlong){const e=this._graphicHandler.getFlagGraphic(s.mapPoint,t,s,a);r.graphics.add(e),i.push({...s,type:t,globalId:s.attributes.globalid||s.attributes.GLOBALID,details:s,mapGraphic:e,id:i.length+1})}})),this._flags=i,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const s=t.graphics;e.graphicEnabled=!1;s.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId)).forEach((e=>{t.graphics.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeResultAreaGrahicsLayer(){this._resultAreaHandler?.removeResultAreaGrahicsLayer(this.view.map)}removeResultAreaToMap(e){e.resultArea.show=!1,this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map)}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const s=[...this._flags];s.forEach((s=>{if(s.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const r=t.selectedTerminals.indexOf(parseInt(e,10));s.selectedTerminals?.splice(r,1)}})),this._flags=s}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}reset(){this._flags=[],this.traceResults=[];const e=[...this._traces];e.forEach((e=>{e.selected=!1})),this._traces=e,this.view&&(this.view.graphics.removeAll(),this.removeResultAreaGrahicsLayer(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}))}selectFeaturesById(e){const{view:t}=this;if(!t)return;const s=g(this.utilityNetwork,e);this._getUniqueMapLayerViews(t).forEach((e=>{e.layer?.parsedUrl?.path===s[0].layerUrl&&T(e)&&this._highlightHandler.push(e.highlight(s[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this._groupResultsByNetworkSource(e),s=[];for(const e in t)this.selectFeaturesById(t[e]),s.push(this.queryFeaturesById(t[e]));Promise.all(s).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const s=[...this._traces];s.forEach((s=>{t===s.globalId&&(s.selected=e)})),this._traces=s}selectTracesOnLoad(){this.utilityNetwork.hasOwnProperty("sharedNamedTraceConfigurations")&&(this._traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this._traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}_getUniqueMapLayerViews(e){const t=[];return e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).forEach((e=>{switch(e.layer.type){case"group":if(F(e))for(const s of e.layerViews)t.push(s);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((s=>{const r=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:s,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}));else{const s=new f({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:null,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",s="";const r=e.layer;t=this._checkParentForData(r,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(s=e.attributes[i],"assetgroup"===a||"assettype"===a?s=this._checkSubtype(r,r.subtypeCode):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))):(s=this._checkDomain(r.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,r)))}return{field:t,value:s.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let s=t.displayField,r="";for(const i in e.attributes){const a=i.toLowerCase();if(a===s?.toLowerCase())if(r=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),s=t.typeIdField,r=this._checkSubtype(t,a),""===s&&(t.templates&&t.templates.length>0?(s=t.templates[0]?.name,r=t.templates[0]?.name):(s=t.displayField,r=e.attributes[i]))}else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t));else r=this._checkDomain(t.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,t))}return{field:s,value:r?r.toString():""}}_checkSubtype(e,t){let s=t;if("subtype-sublayer"===e.type){const r=this._checkParentForData(e,"subtypes");r?.length>0&&r.forEach((e=>{e.code===t&&(s=e.name)}))}else if(null!=e.types&&e.types.length>0){const r=e.types.filter((e=>e.id===t));r.length>0&&(s=r[0].name)}return s}_checkDomain(e,t,s){let r=s;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&I(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===s));e.length>0&&(r=e[0].name)}return r}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_groupResultsByNetworkSource(e){if(e.length>0){return this._groupBy(e,"networkSourceId")}return[]}_lookupFlagByHit(e){return this.view.hitTest(e.screenPoint).then((t=>{const s=[];if(t.results.length>0){const r=t.results.find((e=>null!==e.layer));if(r.graphic&&null!=r.graphic.geometry)if("polyline"===r.graphic.geometry.type){const t=this._geometryHandler.getPercentageAlong(r.graphic.geometry,e.mapPoint,r.graphic.geometry.spatialReference),i=this._getDisplayField(r.graphic);r.graphic.terminalId=null,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=null,r.graphic.selectedTerminals=null,r.graphic.percentAlong=t,r.graphic.displayValue=i,r.graphic.mapPoint=r.mapPoint,s.push(r)}else if(("point"===r.graphic.geometry.type||"polygon"===r.graphic.geometry.type)&&null!==this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(r.graphic),t=this._getDisplayField(r.graphic);r.graphic.terminalId=e?e.terminals[0].id||null:1,r.graphic.isFilterBarrier=!1,r.graphic.allTerminals=e??null,r.graphic.selectedTerminals=[e?e.terminals[0].id||null:1],r.graphic.percentAlong=null,r.graphic.displayValue=t,r.graphic.mapPoint=r.mapPoint,s.push(r)}}return s}))}async _populateOutfields(){const e=this.view?.map,t=this.getValidSources();e?.layers.forEach((e=>{"group"===e.type?e.layers.forEach((e=>{t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])}))}_removeGraphic(e){this.view?.graphics.remove(e.mapGraphic)}};e([n()],k.prototype,"_activeProgress",void 0),e([n()],k.prototype,"_flags",void 0),e([n()],k.prototype,"_traces",void 0),e([n()],k.prototype,"defaultGraphicColor",void 0),e([n()],k.prototype,"enableResultArea",void 0),e([n()],k.prototype,"flags",void 0),e([n()],k.prototype,"gdbVersion",void 0),e([n()],k.prototype,"messages",void 0),e([n()],k.prototype,"messagesUnits",void 0),e([n()],k.prototype,"resultAreaProperties",null),e([n()],k.prototype,"selectedTraces",void 0),e([n()],k.prototype,"selectOnComplete",void 0),e([n()],k.prototype,"showGraphicsOnComplete",void 0),e([n()],k.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],k.prototype,"state",null),e([n()],k.prototype,"traceResults",void 0),e([n()],k.prototype,"utilityNetwork",void 0),e([n({value:null})],k.prototype,"view",null),k=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],k);const S=k;export{S 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{geodesicBuffer as e,buffer as t,convexHull as r,geodesicArea as
|
|
5
|
+
import"../../../geometry.js";import{geodesicBuffer as e,buffer as t,convexHull as r,geodesicArea as n,planarArea as o,cut as i,planarLength as s}from"../../../geometry/geometryEngine.js";import a from"../../../geometry/Polyline.js";import{project as c,load as l}from"../../../geometry/projection.js";import p from"../../../geometry/SpatialReference.js";function f(e){return"polygon"===e.type||"polyline"===e.type}function u(e){return e.hasOwnProperty("points")}function y(e){return u(e)&&2===e.points.length}class g{createBuffer(r,n,o,i){if(Array.isArray(r)){if(r.length>0){const s=p.fromJSON(r[0].spatialReference);return s.isWGS84||s.isWebMercator?e(r,n,o):t(r,n,o,i)}return}const s=p.fromJSON(r.spatialReference);return s.isWGS84||s.isWebMercator?e(r,n[0],o):t(r,n[0],o)}createConvexHull(e){if(Array.isArray(e)){if(1===e.length&&y(e[0])){const t=r(e[0]);if(f(t))return t}return r(e,!0).filter(f)}const t=r(e);if(f(t))return t}calculateArea(e,t){const r=new p({wkid:e.spatialReference.wkid});return r.isWGS84||r.isWebMercator?parseFloat(n(e,t).toFixed(2)):parseFloat(o(e,t).toFixed(2))}mergeAggregatedToGeometries(e){const t=[],{line:r,multipoint:n,polygon:o}=e;return r&&t.push(r),n&&t.push(n),o&&t.push(o),t}getPercentageAlong(e,t,r){let n=e;const o=this._createPolyline(e.paths,r.wkid);if("point"===t.type){const e=t.x-50,a=t.x+50,l=[[e,t.y-50],[a,t.y+50]];n=this._createPolyline(l,t.spatialReference.wkid);n=c(n,r);const p=i(o,n);if(p.length>0){const e=s(o,"feet");let t;t=p[0].paths[0][0][0]===o.paths[0][0][0]?s(p[0],"feet"):s(p[1],"feet");return[t/e]}return[.5]}n=c(t,r);const a=i(o,n);if(a.length>0){const e=s(o,"feet");return[s(a[0],"feet")/e]}return[.5]}async projectGeometry(e,t){return await l(),c(e,t)}_createPolyline(e,t){return new a({hasZ:!1,hasM:!0,paths:e,spatialReference:{wkid:t}})}}export{g as GeometryHandler};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import r from"../../../layers/GraphicsLayer.js";import t from"../../../symbols/SimpleFillSymbol.js";import{GeometryHandler as o}from"./GeometryHandler.js";const a="utility-network-trace-result-area";function i(e){return!!e&&"graphics"===e.type}class n{constructor(){this.traceInformation={},this._geometryHandler=new o}addResultAreaToMap(e,r){const t=this._createGraphicLayer(r);t&&i(t)&&t.add(e)}changeResultAreaColor(e,r,o){const a=this._findGraphicsByTraceId(e,o);a&&a.forEach((e=>{const o=new t({color:r.color,style:"solid",outline:{color:r.color,width:1}});e.symbol=o}))}createBuffer(e,r,t,o){return this._geometryHandler.createBuffer(e,r,t,o)}createConvexHull(e,r,t){const o=this._geometryHandler.createConvexHull(e);return r>0?this.createBuffer(o,[r],t,!1):o}createResultAreaGraphic(r,o,a,i,n,s){const c=new t({color:s.color,style:"solid",outline:{color:s.color,width:1}}),l=[];for(const e in o)l.push({fieldName:e,label:"areaStatistic"===e?i.attributeStrings[e]+" ("+n.units[a]?.abbr+")":i.attributeStrings[e],value:o[e]});return new e({geometry:r,symbol:c,attributes:o,popupTemplate:{title:o.traceName,content:[{type:"fields",fieldInfos:l}]}})}removeResultArea(e,r){const t=r.findLayerById(a);if(t&&i(t)){const o=this._findGraphicsByTraceId(e,r);o&&t.removeMany(o)}}removeResultAreaGrahicsLayer(e){if(e){const r=e.findLayerById(a);r&&i(r)&&e.remove(r)}}_createGraphicLayer(e){if(!e.findLayerById(a)){const t=new r({id:a});return e.add(t),t}const t=e.findLayerById(a);return t&&i(t)?t:null}_findGraphicsByTraceId(e,r){const t=r.findLayerById(a);if(t&&i(t)){const r=t.graphics.filter((r=>r.attributes.traceId===e));return r.length>0?r.toArray():null}return null}}export{n as ResultAreaHandler};
|
|
5
|
+
import e from"../../../Graphic.js";import r from"../../../layers/GraphicsLayer.js";import t from"../../../symbols/SimpleFillSymbol.js";import{GeometryHandler as o}from"./GeometryHandler.js";const a="utility-network-trace-result-area";function i(e){return!!e&&"graphics"===e.type}class n{constructor(){this.traceInformation={},this._geometryHandler=new o}addResultAreaToMap(e,r){const t=this._createGraphicLayer(r);t&&i(t)&&t.add(e)}changeResultAreaColor(e,r,o){const a=this._findGraphicsByTraceId(e,o);a&&a.forEach((e=>{const o=new t({color:r.color,style:"solid",outline:{color:r.color,width:1}});e.symbol=o}))}createBuffer(e,r,t,o){return this._geometryHandler.createBuffer(e,r,t,o)}createConvexHull(e,r,t){const o=this._geometryHandler.createConvexHull(e);return r>0&&o?this.createBuffer(o,[r],t,!1):o}createResultAreaGraphic(r,o,a,i,n,s){const c=new t({color:s.color,style:"solid",outline:{color:s.color,width:1}}),l=[];for(const e in o)l.push({fieldName:e,label:"areaStatistic"===e?i.attributeStrings[e]+" ("+n.units[a]?.abbr+")":i.attributeStrings[e],value:o[e]});return new e({geometry:r,symbol:c,attributes:o,popupTemplate:{title:o.traceName,content:[{type:"fields",fieldInfos:l}]}})}removeResultArea(e,r){const t=r.findLayerById(a);if(t&&i(t)){const o=this._findGraphicsByTraceId(e,r);o&&t.removeMany(o)}}removeResultAreaGrahicsLayer(e){if(e){const r=e.findLayerById(a);r&&i(r)&&e.remove(r)}}_createGraphicLayer(e){if(!e.findLayerById(a)){const t=new r({id:a});return e.add(t),t}const t=e.findLayerById(a);return t&&i(t)?t:null}_findGraphicsByTraceId(e,r){const t=r.findLayerById(a);if(t&&i(t)){const r=t.graphics.filter((r=>r.attributes.traceId===e));return r.length>0?r.toArray():null}return null}}export{n as ResultAreaHandler};
|