@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 14.9 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{deprecateWidget as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{watch as e,initial as o,on as n}from"../core/reactiveUtils.js";import{property as a,subclass as l}from"../core/accessorSupport/decorators.js";import c from"../symbols/SimpleLineSymbol.js";import r from"./Widget.js";import{loadCalciteComponents as d}from"./support/componentsUtils.js";import{messageBundle as h,tsx as m}from"./support/widget.js";import A from"./UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js";import u from"./UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";import w from"./UtilityNetworkAssociations/VisibleElements.js";const b="esri-un-associations",p={action:`${b}__action`,blockContent:`${b}__block-content`,blockSectionSettings:`${b}__block-section-settings`,combobox:`${b}__combobox`,comboboxItem:`${b}__combobox-item`,divControlsMain:`${b}__div-controls-main`,label:`${b}__label`,labelAndCombobox:`${b}__label-and-combobox`,labelAndSlider:`${b}__label-and-slider`,labelAndToggle:`${b}__label-and-toggle`,panel:`${b}__panel`,slider:`${b}__slider`,statusIconWarning:`${b}__status-icon-warning`,switch:`${b}__switch`,widgetContainer:`${b}__widget-container`};let g=class extends r{constructor(t,e){super(t,e),this._autoRefreshAssociations=!0,this._associationsOptionsEnabled=!1,this._maxAllowableAssociationsSliderMax=1e3,this._maxAllowableAssociationsSliderMin=250,this._maxAllowableAssociationsSliderStep=250,this.messages=null,this.messagesCommon=null,this.viewModel=new u,this.visibleElements=new w,this.announceDeprecation=()=>{i(s.getLogger(this),"Utility Network Associations","arcgis-utility-network-associations",{version:"5.0"})}}initialize(){this.addHandles([e(()=>[this.view?.stationary,this.showAssociationsEnabled,this.includeConnectivityAssociations,this.includeStructuralAttachmentAssociations,this.maxAllowableAssociations],()=>{!0===this.autoRefreshAssociations&&(!0===this.showAssociationsEnabled?this.viewModel.showAssociations():this.viewModel.removeAssociations())}),e(()=>this.view?.map?.utilityNetworks,t=>{t?.items.forEach(async(t,i)=>{t.loaded||await t.load(),0===i&&(this.utilityNetwork=t)})},o),n(()=>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 m("div",{class:p.widgetContainer},m("calcite-block",{class:p.blockContent,collapsible:!0,heading:t},this._renderStatusIcon(),this.autoRefreshAssociations?this._renderShowAssociationsSwitch():this._renderRefreshAssociationsAction(),this._renderContent()),this._renderWarningIconTooltip(),this._renderStatusIconTooltip(),this._renderShowAssociationsTooltip(),this._renderRefreshAssociationsActionTooltip())}loadDependencies(){return d({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 m("calcite-notice",{closable:!1,key:`error-notice-${i}`,kind:"warning",open:!0,scale:"s"},m("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 m("calcite-block-section",{class:p.blockSectionSettings,text:t},m(A,{id:`${this.id}-symbol-picker-connectivity`,lineSymbol:this.connectivityAssociationsLineSymbol,showArrows:this.showArrowsConnectivity,visibleElements:i}))}_renderConnectivityAssociationsToggle(){const{messages:{input:{enableConnectivity:t}}}=this;return m("div",{class:p.labelAndToggle,key:"connectivityAssociationsToggleDiv"},m("calcite-label",{class:p.label},t),m("calcite-switch",{bind:this,checked:this.includeConnectivityAssociations,disabled:!this._associationsOptionsEnabled&&this.autoRefreshAssociations,onCalciteSwitchChange:this._connectivityAssociationsSwitchChange}))}_renderComboboxItem({heading:t,value:i,selected:s}){return m("calcite-combobox-item",{class:p.comboboxItem,heading:t,selected:s,value:i})}_renderContent(){const{viewModel:{loadErrors:t,state:i}}=this;return"disabled"===i?m("div",{class:p.divControlsMain,key:"loadErrorsDiv"},t.items.map(this._getLoadErrorMessagesAsNotices)):m("calcite-panel",{class:p.panel,disabled:"loading"===i},m("div",{class:p.divControlsMain},this._renderConnectivityAssociationsToggle(),this._renderStructuralAttachmentAssociationsToggle(),this._renderSettingsPane()))}_renderLoadingIcon(){const{messagesCommon:{executing:t,loading:i},viewModel:{state:s}}=this,e=`${this.id}-status-action`;return m("calcite-action",{class:p.statusIconWarning,icon:"spinner",id:e,loading:!0,scale:"s",slot:"actions-end",text:"executing"===s?t:i})}_renderMaxAllowableAssociationsSlider(){const{messages:{input:{maxAllowableAssociations:t}},visibleElements:{maxAllowableAssociationsSlider:i}}=this;if(i)return m("div",{class:p.labelAndSlider,key:"maxAllowableAssociationsSliderDiv"},m("calcite-label",{class:p.label},t),m("calcite-slider",{bind:this,class:p.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}},viewModel:{state:i}}=this,s=`${this.id}-refresh-action`;return m("calcite-action",{bind:this,class:p.action,disabled:"disabled"===i,icon:"refresh-f",id:s,loading:"loading"===i,onclick:this._refreshAssociations,slot:"actions-end",text:t})}_renderRefreshAssociationsActionTooltip(){const{messages:{input:{refreshAssociations:t}}}=this,i=`${this.id}-refresh-action`;return m("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:i,topLayerDisabled:this.topLayerDisabled},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 m("calcite-block",{class:p.blockContent,collapsible:!0,heading:t},m("div",{class:p.divControlsMain},this._renderUtilityNetworkSettings(),this._renderMaxAllowableAssociationsSlider()),this._renderConnectivityAssociationsSettings(),this._renderStructuralAttachmentAssociationsSettings())}_renderShowAssociationsSwitch(){const{viewModel:{state:t}}=this,i=`${this.id}-show-associations-switch`;return m("calcite-switch",{bind:this,checked:this.showAssociationsEnabled,class:p.switch,disabled:"disabled"===t,id:i,slot:"actions-end",onCalciteSwitchChange:this._showAssociationsSwitchChange})}_renderShowAssociationsTooltip(){const{messages:{input:{enableAssociations:t}}}=this,i=`${this.id}-show-associations-switch`;return m("calcite-tooltip",{referenceElement:i,topLayerDisabled:this.topLayerDisabled},t)}_renderStatusIcon(){const{viewModel:{state:t}}=this;switch(t){case"disabled":case"warning":return this._renderWarningIcon();case"loading":case"executing":return this._renderLoadingIcon();default:return}}_renderStatusIconTooltip(){const{messagesCommon:{executing:t,loading:i},viewModel:{state:s}}=this,e=`${this.id}-status-action`;return m("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:e,topLayerDisabled:this.topLayerDisabled},"executing"===s?t:i)}_renderStructuralAttachmentAssociationsSettings(){const{messages:{input:{enableStructuralAttachment:t}},visibleElements:{structuralAttachmentAssociationsSettings:i}}=this;if(i)return m("calcite-block-section",{class:p.blockSectionSettings,text:t},m(A,{id:`${this.id}-symbol-picker-structural-attachment`,lineSymbol:this.structuralAttachmentAssociationsLineSymbol,showArrows:this.showArrowsStructuralAttachment,visibleElements:i}))}_renderStructuralAttachmentAssociationsToggle(){const{messages:{input:{enableStructuralAttachment:t}}}=this;return m("div",{class:p.labelAndToggle,key:"structuralAttachmentAssociationsToggleDiv"},m("calcite-label",{class:p.label},t),m("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 m("div",{class:p.labelAndCombobox,key:"utilityNetworkComboboxDiv"},m("calcite-label",{class:p.label},t),m("calcite-combobox",{class:p.combobox,clearDisabled:!0,label:"",maxItems:3,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,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(){const t=`${this.id}-warning-action`;return m("calcite-icon",{class:p.statusIconWarning,icon:"exclamation-mark-triangle",id:t,scale:"s",slot:"actions-end"})}_renderWarningIconTooltip(){const{viewModel:{executionError:t,state:i}}=this,s=`${this.id}-warning-action`;if("warning"===i)return m("calcite-tooltip",{referenceElement:s,topLayerDisabled:this.topLayerDisabled},t)}};t([a()],g.prototype,"autoRefreshAssociations",null),t([a({type:c})],g.prototype,"connectivityAssociationsLineSymbol",null),t([a()],g.prototype,"icon",null),t([a()],g.prototype,"includeConnectivityAssociations",null),t([a()],g.prototype,"includeStructuralAttachmentAssociations",null),t([a()],g.prototype,"label",null),t([a()],g.prototype,"maxAllowableAssociations",null),t([a()],g.prototype,"maxAllowableAssociationsSliderMax",null),t([a()],g.prototype,"maxAllowableAssociationsSliderMin",null),t([a()],g.prototype,"maxAllowableAssociationsSliderStep",null),t([a(),h("esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations")],g.prototype,"messages",void 0),t([a(),h("esri/t9n/common")],g.prototype,"messagesCommon",void 0),t([a()],g.prototype,"showArrowsConnectivity",null),t([a()],g.prototype,"showArrowsStructuralAttachment",null),t([a()],g.prototype,"showAssociationsEnabled",null),t([a({type:c})],g.prototype,"structuralAttachmentAssociationsLineSymbol",null),t([a()],g.prototype,"utilityNetwork",null),t([a()],g.prototype,"view",null),t([a({type:u})],g.prototype,"viewModel",void 0),t([a({type:w,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=t([l("esri.widgets.UtilityNetworkAssociations")],g);const y=g;export{y as default};