UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 6.98 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{substitute as t}from"../../intl.js";import{stripHTML as i}from"../../core/string.js";import{property as s,subclass as o}from"../../core/accessorSupport/decorators.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import{tsx as a}from"../support/widget.js";import c from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import d from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as p}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as u}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as m}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";var h;const w="esri-feature-utility-network-associations",y={base:w,listItemHidden:`${w}__list-item--hidden`},f="nested";let b=h=class extends d{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new c,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(y.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():i&&this.selectedLayer?a("calcite-list",{displayMode:f,filterEnabled:!0,filterLabel:this.messagesFeature.associationFilterPlaceholder,filterPlaceholder:this.messagesFeature.associationFilterPlaceholder,label:this.selectedLayer?.title??this.messagesCommon.untitled},this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):a("calcite-list",{displayMode:f,label:this.selectedLayer?.title??this.messagesCommon.untitled},Array.from(e.keys(),t=>this._renderTypeList(t,e.get(t)))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new h({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return u(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid),topLayerDisabled:this.topLayerDisabled},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:t,title:s}=e,o="loading"===t.state,l=this._findFlowItem(t),r=l<0&&this._isParentFeature(t),n=r||l>=0;return a("calcite-list-item",{class:o?y.listItemHidden:void 0,description:i(e.terminalName??""),key:`associated-feature-type-${t.uid}`,label:i(s),onCalciteListItemSelect:()=>this._handleFeatureClick(r,l,t)},u(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,m(e.association)?a("calcite-chip",{label:p(e.association),scale:"s",slot:"content-end"},p(e.association)):null,this._renderChevronIconNode(n))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain(e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()});else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex(t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)})??-1}_renderTooltips(e){return e.toArray().map(e=>this._renderItemTooltip(e))}_renderAssociatedFeatureList(e){return e.toArray().map(e=>this._renderAssociatedFeature(e))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,i){const{messagesFeature:s}=this,{displayCount:o}=this.viewModel,l=i.slice(0,o),r=l.length<i.length;return a("calcite-list-item",{expanded:!0,key:"show-all",label:e.title,value:e.id},a("calcite-chip",{label:String(i.length),scale:"s",slot:"content-end"},i.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(l),this._renderAssociatedFeatureList(l)],r?a("calcite-list-item",{description:t(s?.numberRecords,{number:i.length.toString()}),key:"show-all-item",label:s.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([s()],b.prototype,"description",void 0),e([s()],b.prototype,"featureVisibleElements",void 0),e([s()],b.prototype,"flowItems",void 0),e([s()],b.prototype,"flowType",void 0),e([s()],b.prototype,"listType",void 0),e([s()],b.prototype,"parentFeatureViewModel",void 0),e([s()],b.prototype,"title",void 0),e([s({type:c})],b.prototype,"viewModel",void 0),e([s({type:l,nonNullable:!0})],b.prototype,"visibleElements",void 0),b=h=e([o("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],b);const v=b;export{v as default};