UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) • 14.8 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as t}from"../chunks/tslib.es6.js";import{watch as i,initial as s,on as e}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import{loadCalciteComponents as a}from"./support/componentsUtils.js";import"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import{tsx as r}from"./support/jsxFactory.js";import d from"./UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js";import h from"./UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";import m from"./UtilityNetworkAssociations/VisibleElements.js";const A="esri-un-associations",u={action:`${A}__action`,actionRefresh:`${A}__action-refresh`,blockContent:`${A}__block-content`,blockSectionSettings:`${A}__block-section-settings`,combobox:`${A}__combobox`,comboboxItem:`${A}__combobox-item`,divControlsMain:`${A}__div-controls-main`,label:`${A}__label`,labelAndCombobox:`${A}__label-and-combobox`,labelAndSlider:`${A}__label-and-slider`,labelAndToggle:`${A}__label-and-toggle`,panel:`${A}__panel`,slider:`${A}__slider`,statusIconContainer:`${A}__status-icon-container`,statusIconWarning:`${A}__status-icon-warning`,switch:`${A}__switch`,switchContainer:`${A}__switch-container`,widgetContainer:`${A}__widget-container`};let w=class extends l{constructor(t,i){super(t,i),this._autoRefreshAssociations=!0,this._associationsOptionsEnabled=!1,this._maxAllowableAssociationsSliderMax=1e3,this._maxAllowableAssociationsSliderMin=250,this._maxAllowableAssociationsSliderStep=250,this.messages=null,this.messagesCommon=null,this.viewModel=new h,this.visibleElements=new m}initialize(){this.addHandles([i((()=>[this.view?.stationary,this.showAssociationsEnabled,this.includeConnectivityAssociations,this.includeStructuralAttachmentAssociations,this.maxAllowableAssociations]),(()=>{!0===this.autoRefreshAssociations&&(!0===this.showAssociationsEnabled?this.viewModel.showAssociations():this.viewModel.removeAssociations())})),i((()=>this.view?.map?.utilityNetworks),(t=>{t?.items.forEach((async(t,i)=>{t.loaded||await t.load(),0===i&&(this.utilityNetwork=t)}))}),s),e((()=>this.view?.map?.utilityNetworks),"change",(t=>{const i=t.target;t.added.forEach((async t=>{t.loaded||await t.load()})),t.removed.some((t=>t.layerUrl===this.utilityNetwork?.layerUrl))&&(this.utilityNetwork=null),this.utilityNetwork=i.length?i.getItemAt(0):null}))])}get autoRefreshAssociations(){return this._autoRefreshAssociations}set autoRefreshAssociations(t){this._autoRefreshAssociations=t}get connectivityAssociationsLineSymbol(){return this.viewModel.connectivityAssociationsLineSymbol}set connectivityAssociationsLineSymbol(t){this.viewModel.connectivityAssociationsLineSymbol=t}get icon(){return"view-associations"}set icon(t){this._overrideIfSome("icon",t)}get includeConnectivityAssociations(){return this.viewModel.includeConnectivityAssociations}set includeConnectivityAssociations(t){this.viewModel.includeConnectivityAssociations=t}get includeStructuralAttachmentAssociations(){return this.viewModel.includeStructuralAttachmentAssociations}set includeStructuralAttachmentAssociations(t){this.viewModel.includeStructuralAttachmentAssociations=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get maxAllowableAssociations(){return this.viewModel.maxAllowableAssociations}set maxAllowableAssociations(t){this.viewModel.maxAllowableAssociations=t}get maxAllowableAssociationsSliderMax(){return this._maxAllowableAssociationsSliderMax}set maxAllowableAssociationsSliderMax(t){t<=this.maxAllowableAssociationsSliderMin||(this._maxAllowableAssociationsSliderMax=t)}get maxAllowableAssociationsSliderMin(){return this._maxAllowableAssociationsSliderMin}set maxAllowableAssociationsSliderMin(t){t<0||t>=this.maxAllowableAssociationsSliderMax||(this._maxAllowableAssociationsSliderMin=t)}get maxAllowableAssociationsSliderStep(){return this._maxAllowableAssociationsSliderStep}set maxAllowableAssociationsSliderStep(t){this._maxAllowableAssociationsSliderStep=t}get showArrowsConnectivity(){return this.viewModel.showArrowsConnectivity}set showArrowsConnectivity(t){this.viewModel.showArrowsConnectivity=t}get showArrowsStructuralAttachment(){return this.viewModel.showArrowsStructuralAttachment}set showArrowsStructuralAttachment(t){this.viewModel.showArrowsStructuralAttachment=t}get showAssociationsEnabled(){return this.viewModel.showAssociationsEnabled}set showAssociationsEnabled(t){this.viewModel.showAssociationsEnabled=t}get structuralAttachmentAssociationsLineSymbol(){return this.viewModel.structuralAttachmentAssociationsLineSymbol}set structuralAttachmentAssociationsLineSymbol(t){this.viewModel.structuralAttachmentAssociationsLineSymbol=t}get utilityNetwork(){return this.viewModel.utilityNetwork}set utilityNetwork(t){this.viewModel.utilityNetwork=t}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}render(){const{label:t}=this;return r("div",{class:u.widgetContainer},r("calcite-block",{class:u.blockContent,collapsible:!0,heading:t},this._renderStatusIcon(),this.autoRefreshAssociations?this._renderShowAssociationsSwitch():this._renderRefreshAssociationsAction(),this._renderContent()))}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}_connectivityAssociationsSwitchChange(t){this.includeConnectivityAssociations=t.currentTarget.checked}_getLoadErrorMessagesAsNotices(t,i){return r("calcite-notice",{closable:!1,key:`error-notice-${i}`,kind:"warning",open:!0,scale:"s"},r("div",{slot:"message"},t))}_maxAllowableAssociationsSliderChange(t){this.maxAllowableAssociations=Number(t.currentTarget.value)}_refreshAssociations(){const{viewModel:t,viewModel:{state:i}}=this;"ready"!==i&&"warning"!==i||t.showAssociations()}_renderConnectivityAssociationsSettings(){const{messages:{input:{enableConnectivity:t}},visibleElements:{connectivityAssociationsSettings:i}}=this;if(i)return r("calcite-block-section",{class:u.blockSectionSettings,text:t},r(d,{id:`${this.id}-symbol-picker-connectivity`,lineSymbol:this.connectivityAssociationsLineSymbol,showArrows:this.showArrowsConnectivity,visibleElements:i}))}_renderConnectivityAssociationsToggle(){const{messages:{input:{enableConnectivity:t}}}=this;return r("div",{class:u.labelAndToggle,key:"connectivityAssociationsToggleDiv"},r("calcite-label",{class:u.label},t),r("calcite-switch",{bind:this,checked:this.includeConnectivityAssociations,disabled:!this._associationsOptionsEnabled&&this.autoRefreshAssociations,onCalciteSwitchChange:this._connectivityAssociationsSwitchChange}))}_renderComboboxItem({heading:t,value:i,selected:s}){return r("calcite-combobox-item",{class:u.comboboxItem,heading:t,selected:s,textLabel:t,value:i})}_renderContent(){const{viewModel:{loadErrors:t,state:i}}=this;return"disabled"===i?r("div",{class:u.divControlsMain,key:"loadErrorsDiv"},t.items.map(this._getLoadErrorMessagesAsNotices)):r("calcite-panel",{class:u.panel,disabled:"loading"===i},r("div",{class:u.divControlsMain},this._renderConnectivityAssociationsToggle(),this._renderStructuralAttachmentAssociationsToggle(),this._renderSettingsPane()))}_renderLoadingAction(t,i,s){return r("div",{key:t,slot:"control"},r("calcite-action",{id:i,loading:!0,text:s}),r("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:i},r("span",null,s)))}_renderMaxAllowableAssociationsSlider(){const{messages:{input:{maxAllowableAssociations:t}},visibleElements:{maxAllowableAssociationsSlider:i}}=this;if(i)return r("div",{class:u.labelAndSlider,key:"maxAllowableAssociationsSliderDiv"},r("calcite-label",{class:u.label},t),r("calcite-slider",{bind:this,class:u.slider,labelTicks:!0,max:this.maxAllowableAssociationsSliderMax,min:this.maxAllowableAssociationsSliderMin,scale:"s",snap:!0,step:this.maxAllowableAssociationsSliderStep,ticks:this.maxAllowableAssociationsSliderStep,value:this.maxAllowableAssociations,onCalciteSliderChange:this._maxAllowableAssociationsSliderChange}))}_renderRefreshAssociationsAction(){const{messages:{input:{refreshAssociations:t}},messagesCommon:{loading:i},viewModel:{state:s}}=this,e=`${this.id}-refresh-action`;if("disabled"!==s)return r("div",{class:u.actionRefresh,slot:"control"},r("calcite-action",{bind:this,class:u.action,icon:"refresh-f",id:e,loading:"loading"===s,onclick:this._refreshAssociations,text:t}),r("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:e},r("span",null,"loading"===s?i:t)))}_renderSettingsPane(){const{messagesCommon:{settings:t},visibleElements:{maxAllowableAssociationsSlider:i,connectivityAssociationsSettings:s,structuralAttachmentAssociationsSettings:e}}=this,o=(this.view?.map).utilityNetworks?.items;if(1!==o?.length||i||s||e)return r("calcite-block",{class:u.blockContent,collapsible:!0,heading:t},r("div",{class:u.divControlsMain},this._renderUtilityNetworkSettings(),this._renderMaxAllowableAssociationsSlider()),this._renderConnectivityAssociationsSettings(),this._renderStructuralAttachmentAssociationsSettings())}_renderShowAssociationsSwitch(){const{messages:{input:{enableAssociations:t}},messagesCommon:{loading:i},viewModel:{state:s}}=this,e=`${this.id}-show-associations-switch`;if("disabled"!==s)return"loading"===s?this._renderLoadingAction("loadingActionDiv",`${this.id}-loading-action`,i):r("div",{class:u.switchContainer,key:"switchDiv",slot:"control"},r("calcite-switch",{bind:this,checked:this.showAssociationsEnabled,class:u.switch,id:e,onCalciteSwitchChange:this._showAssociationsSwitchChange}),r("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:e},r("span",null,t)))}_renderStatusIcon(){const{messagesCommon:{executing:t},viewModel:{executionError:i,state:s}}=this;switch(s){case"disabled":return this._renderWarningIcon("statusDiv",`${this.id}-disabled-icon`,null);case"warning":return this._renderWarningIcon("statusDiv",`${this.id}-warning-icon`,i);case"executing":return this._renderLoadingAction("executingActionDiv",`${this.id}-executing-action`,t);default:return}}_renderStructuralAttachmentAssociationsSettings(){const{messages:{input:{enableStructuralAttachment:t}},visibleElements:{structuralAttachmentAssociationsSettings:i}}=this;if(i)return r("calcite-block-section",{class:u.blockSectionSettings,text:t},r(d,{id:`${this.id}-symbol-picker-structural-attachment`,lineSymbol:this.structuralAttachmentAssociationsLineSymbol,showArrows:this.showArrowsStructuralAttachment,visibleElements:i}))}_renderStructuralAttachmentAssociationsToggle(){const{messages:{input:{enableStructuralAttachment:t}}}=this;return r("div",{class:u.labelAndToggle,key:"structuralAttachmentAssociationsToggleDiv"},r("calcite-label",{class:u.label},t),r("calcite-switch",{bind:this,checked:this.includeStructuralAttachmentAssociations,disabled:!this._associationsOptionsEnabled&&this.autoRefreshAssociations,onCalciteSwitchChange:this._structuralAttAssociationsSwitchChange}))}_renderUtilityNetworkSettings(){const{messages:{input:{utilityNetwork:t}}}=this,i=(this.view?.map).utilityNetworks?.items;if(1===i?.length)return null;const s=i?.map((t=>{const i=t.title,s=t.layerUrl,e=t.layerUrl===this.utilityNetwork?.layerUrl;return this._renderComboboxItem({heading:i,value:s,selected:e})}));return r("div",{class:u.labelAndCombobox,key:"utilityNetworkComboboxDiv"},r("calcite-label",{class:u.label},t),r("calcite-combobox",{class:u.combobox,clearDisabled:!0,label:"",maxItems:3,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:t=>{const s=i?.find((i=>i.layerUrl===t.currentTarget.value));this.utilityNetwork=s}},s))}_showAssociationsSwitchChange({currentTarget:t}){const{viewModel:i}=this;this.showAssociationsEnabled=t.checked,this._associationsOptionsEnabled=t.checked,this.showAssociationsEnabled||i.removeAssociations()}_structuralAttAssociationsSwitchChange(t){this.includeStructuralAttachmentAssociations=t.currentTarget.checked}_renderWarningIcon(t,i,s){return s?r("div",{class:u.statusIconContainer,key:t,slot:"control"},r("calcite-icon",{class:u.statusIconWarning,icon:"exclamation-mark-triangle",id:i,scale:"s"}),r("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:i},r("span",null,s))):r("div",{class:u.statusIconContainer,key:t,slot:"control"},r("calcite-icon",{class:u.statusIconWarning,icon:"exclamation-mark-triangle",id:i,scale:"s"}))}};t([o()],w.prototype,"autoRefreshAssociations",null),t([o()],w.prototype,"connectivityAssociationsLineSymbol",null),t([o()],w.prototype,"icon",null),t([o()],w.prototype,"includeConnectivityAssociations",null),t([o()],w.prototype,"includeStructuralAttachmentAssociations",null),t([o()],w.prototype,"label",null),t([o()],w.prototype,"maxAllowableAssociations",null),t([o()],w.prototype,"maxAllowableAssociationsSliderMax",null),t([o()],w.prototype,"maxAllowableAssociationsSliderMin",null),t([o()],w.prototype,"maxAllowableAssociationsSliderStep",null),t([o(),c("esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations")],w.prototype,"messages",void 0),t([o(),c("esri/t9n/common")],w.prototype,"messagesCommon",void 0),t([o()],w.prototype,"showArrowsConnectivity",null),t([o()],w.prototype,"showArrowsStructuralAttachment",null),t([o()],w.prototype,"showAssociationsEnabled",null),t([o()],w.prototype,"structuralAttachmentAssociationsLineSymbol",null),t([o()],w.prototype,"utilityNetwork",null),t([o()],w.prototype,"view",null),t([o({type:h})],w.prototype,"viewModel",void 0),t([o({type:m,nonNullable:!0})],w.prototype,"visibleElements",void 0),w=t([n("esri.widgets.UtilityNetworkAssociations")],w);const b=w;export{b as default};