UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 4.23 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import{IdentifiableMixin as e}from"../../core/Identifiable.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as i,initial as o,on as a}from"../../core/reactiveUtils.js";import{property as r,subclass as n}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";import{isAssociatedFeatureSupportedLayer as p}from"../Feature/support/featureUtils.js";import u from"./EditableInput.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";let c=class extends(e(u)){constructor(t){super(t),this.group=null,this.type="utilityNetworkAssociations",this.featureItem=null,this._updatingHandlesSetUp=new l,this.addHandles([i(()=>({feature:this.feature,element:this.element,layer:this.layer}),t=>this._createAssociationVM(t),o),i(()=>this.feature,()=>this._setFeatureItem()),i(()=>this.associatedLayer,(t,e)=>this._updateLayerEditHandle(t,e),o)])}destroy(){this._associationsVM?.destroy(),this._updatingHandlesSetUp.destroy()}get activeAssociationType(){return this._associationsVM?.activeAssociationType}get associatedFeatures(){const{associatedLayer:t}=this;if(t)return this.associatedFeatureInfos.get(t)}get associatedFeatureInfos(){const{_associationsVM:t}=this;if(!t?.associationFeatures?.size||!t?.utilityNetwork)return new Map;const{associationFeatures:e}=t,s=new Map;return e.forEach((t,e)=>{s.set(e,t)}),s}get associatedLayer(){return this._get("associatedLayer")}set associatedLayer(t){this._associationsVM.showAllEnabled=null!=t,this._set("associatedLayer",t)}get associationsViewModel(){return this._associationsVM}get canAddAssociation(){const{editable:t,utilityNetwork:e}=this;return!(!e||!this.loaded)&&t}get editable(){return this.evaluatedEditableExpression??!0}get featureCount(){return this._associationsVM?.featureCount??0}get viewModel(){return this._associationsVM}get loaded(){return"loading"!==this._associationsVM?.state&&!this._updatingHandlesSetUp.updating}get map(){return this._get("map")}set map(t){t&&this._associationsVM?.set("map",t),this._set("map",t)}get utilityNetwork(){return this._associationsVM?.utilityNetwork}get associationTypes(){return this._associationsVM?.associationTypes??this.element.associationTypes}get visible(){const{utilityNetwork:t}=this;return!!t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._associationsVM?.state||"querying"===this._associationsVM?.state}async refresh(){await s(this._associationsVM.refresh())}_updateLayerEditHandle(t,e){e&&"layerId"in e&&this.removeHandles(e?.layerId),p(t)&&this.addHandles(a(()=>t,"edits",()=>this.refresh()),t.layerId)}_createAssociationVM(t){const{feature:e,element:s,layer:i}=t;if(this._associationsVM?.destroy(),!e||!s||!i)return;const{map:o,associationTypes:a}=this;p(i)&&(this._associationsVM=new d({graphic:e,layer:i,map:o,associationTypes:a,source:"featureForm",title:this.label,description:this.description}))}_setFeatureItem(){this._updatingHandlesSetUp.addPromise((async()=>{const{feature:t,layer:e}=this;t&&e&&"getFeatureTitle"in e&&(this.featureItem={feature:t,label:await e.getFeatureTitle(t)})})())}};t([r()],c.prototype,"_associationsVM",void 0),t([r()],c.prototype,"activeAssociationType",null),t([r()],c.prototype,"associatedFeatures",null),t([r()],c.prototype,"associatedFeatureInfos",null),t([r()],c.prototype,"associatedLayer",null),t([r()],c.prototype,"associationsViewModel",null),t([r()],c.prototype,"canAddAssociation",null),t([r()],c.prototype,"editable",null),t([r()],c.prototype,"featureCount",null),t([r()],c.prototype,"viewModel",null),t([r()],c.prototype,"group",void 0),t([r()],c.prototype,"loaded",null),t([r()],c.prototype,"map",null),t([r()],c.prototype,"utilityNetwork",null),t([r()],c.prototype,"associationTypes",null),t([r({readOnly:!0})],c.prototype,"type",void 0),t([r()],c.prototype,"visible",null),t([r()],c.prototype,"updating",null),t([r()],c.prototype,"featureItem",void 0),c=t([n("esri.widgets.FeatureForm.UtilityNetworkAssociationInput")],c);const y=c;export{y as default};