UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 6.57 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import{deprecateWidget as e}from"../core/deprecate.js";import o from"../core/Logger.js";import{property as i,subclass as s}from"../core/accessorSupport/decorators.js";import n from"./Widget.js";import{loadCalciteComponents as a}from"./support/componentsUtils.js";import{messageBundle as c,tsx as l}from"./support/widget.js";import r from"./UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js";const d="esri-un-validate-topology",p={action:`${d}__action`,container:`${d}__container`,content:`${d}__content`,controlsContainer:`${d}__controls-container`,statusIcon:`${d}__status-icon`,statusIconBlank:`${d}__status-icon-blank`,statusIconError:`${d}__status-icon-error`,statusIconSuccess:`${d}__status-icon-success`};let u=class extends n{constructor(t,i){super(t,i),this.messages=null,this.viewModel=new r,this.announceDeprecation=()=>{e(o.getLogger(this),"Utility Network Validate Topology","arcgis-utility-network-validate-topology",{version:"5.0"})}}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get extentToValidate(){return this.viewModel.extentToValidate}set extentToValidate(t){this.viewModel.extentToValidate=t}get icon(){return"check-circle"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.label??""}set label(t){this._overrideIfSome("label",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{state:t}=this.viewModel;return"disabled"===t?l("div",{class:p.container},l("calcite-block",{class:p.content,collapsible:!1,expanded:!0,heading:this.label},this._renderLoadErrorStatusIcon(),this._renderLoadErrorsNotices())):l("div",{class:p.container},l("calcite-block",{class:p.content,collapsible:!0,expanded:!1,heading:this.label},this._renderStatusIcon(),this._renderValidateTopologyAction(),this._renderControls()),this._renderStatusIconTooltip(),this._renderValidateTopologyActionTooltip())}_extentOptionSelectChange(t){this.extentToValidate=t.currentTarget.value}_getLoadErrorMessagesAsNotices(t,e){return l("calcite-notice",{closable:!1,key:"error-notice-"+e,kind:"warning",open:!0,scale:"s"},l("div",{slot:"message"},t))}_handleValidateTopologyAction(){this.viewModel.validateTopology().catch(()=>{})}_renderControls(){const{state:t}=this.viewModel;return"failed"===t?l("div",{class:p.controlsContainer},this._renderExtentOptionSelect(),this._renderStatusNotice()):this._renderExtentOptionSelect()}_renderExtentOptionSelect(){const{messages:{input:{currentExtent:t,entireExtent:e,extentToValidate:o}},viewModel:{extentToValidate:i,state:s}}=this;return l("div",{key:"selectExtentDiv"},l("calcite-select",{bind:this,disabled:"loading"===s||"executing"===s,label:o,onCalciteSelectChange:this._extentOptionSelectChange},l("calcite-option",{selected:"current"===i,value:"current"},t),l("calcite-option",{selected:"entire"===i,value:"entire"},e)))}_renderLoadErrorsNotices(){const{loadErrors:t}=this.viewModel;return l("div",{class:p.controlsContainer,key:"loadErrorsDiv"},t.items.map(this._getLoadErrorMessagesAsNotices))}_renderLoadErrorStatusIcon(){return l("calcite-icon",{class:p.statusIconError,icon:"exclamation-mark-triangle",scale:"s",slot:"actions-end"})}_renderStatusIcon(){const{messages:{status:{executing:t}},viewModel:{state:e}}=this,o=`${this.id}-validation-status-action`,i=`${this.id}-blank-icon`,s=`${this.id}-error-status-icon`,n=`${this.id}-success-status-icon`,a=t=>{setTimeout(()=>{t.textContent=""},3500)};switch(e){case"executing":return l("calcite-action",{class:p.statusIcon,icon:"spinner",id:o,loading:!0,scale:"s",slot:"actions-end",text:t});case"success":return l("calcite-icon",{afterCreate:a,class:p.statusIconSuccess,icon:"check-circle",id:n,scale:"s",slot:"actions-end"});case"failed":return l("calcite-icon",{class:p.statusIconError,icon:"exclamation-mark-triangle",id:s,scale:"s",slot:"actions-end"});default:return l("calcite-icon",{class:p.statusIconBlank,icon:"blank",id:i,scale:"s",slot:"actions-end"})}}_renderStatusIconTooltip(){const{messages:{status:{executing:t,success:e}},viewModel:{executionError:o,state:i}}=this,s=`${this.id}-validation-status-action`,n=`${this.id}-error-status-icon`,a=`${this.id}-success-status-icon`;switch(i){case"executing":return l("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:s,topLayerDisabled:this.topLayerDisabled},l("span",null,t));case"success":return l("calcite-tooltip",{referenceElement:a,topLayerDisabled:this.topLayerDisabled},l("span",null,e));case"failed":return l("calcite-tooltip",{referenceElement:n,topLayerDisabled:this.topLayerDisabled},l("span",null,o));default:return}}_renderStatusNotice(){const{executionError:t}=this.viewModel;return l("div",{key:"executionErrorDiv"},l("calcite-notice",{closable:!0,kind:"warning",open:!0,scale:"s"},l("div",{slot:"message"},t)))}_renderValidateTopologyActionTooltip(){const{messages:{input:{validateTopology:t},status:{loading:e}},viewModel:{state:o}}=this,i=`${this.id}-validation-action`;return l("calcite-tooltip",{closeOnClick:!0,referenceElement:i,topLayerDisabled:this.topLayerDisabled},l("span",null,"loading"===o?e:t))}_renderValidateTopologyAction(){const{messages:{input:{validateTopology:t}},viewModel:{state:e}}=this,o=`${this.id}-validation-action`;return l("calcite-action",{bind:this,class:p.action,disabled:"executing"===e,icon:"play-f",id:o,loading:"loading"===e,onclick:this._handleValidateTopologyAction,slot:"actions-end",text:t})}};t([i()],u.prototype,"extentToValidate",null),t([i()],u.prototype,"icon",null),t([i()],u.prototype,"label",null),t([i(),c("esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology")],u.prototype,"messages",void 0),t([i()],u.prototype,"utilityNetwork",null),t([i()],u.prototype,"view",null),t([i({type:r})],u.prototype,"viewModel",void 0),u=t([s("esri.widgets.UtilityNetworkValidateTopology")],u);const g=u;export{g as default};