UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.23 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../chunks/tslib.es6.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{substitute as i}from"../../intl/substitute.js";import r from"./Grid/Column.js";import{css as s}from"./Grid/ColumnCSS.js";import{isIFeatureTableSupportedLayerWithRelationships as l,findRelationship as n}from"./support/tableUtils.js";const a={showRecordsButton:"esri-column__show-related-records-button"};let p=class extends r{constructor(t){super(t),this.flexGrow=1,this.icon="link",this.layer=null,this.relatedLayer=null,this.relationshipId=null,this.renderFunction=({root:t,rowData:e})=>{if(!e)return;const o=e.item,{layer:r,relatedLayer:n}=this;if(!o?.feature||!l(r)||!l(n))return;const{messages:p}=this,{index:c}=e,{feature:d,objectId:h}=o,{collapsed:u,showRelatedTableCallback:b,relationshipId:m}=this,y=o.relatedRecords,f=y?.find((t=>t.relationshipId===m))?.count??0,C=!u&&b&&p?.recordsCount?i(p.recordsCount,{count:f}):`${f}`,g=t=>{t.preventDefault(),u||this.showRelatedTableCallback?.({feature:d,index:c,layer:r,objectId:h,relatedLayer:n,relationshipId:m})},w=u?"":"chevron-right";if(t.firstChild){const e=t.firstChild;return e.textContent=C,e.onclick=g,void(e.iconEnd=w)}const v=this.createCalciteButton({className:`${a.showRecordsButton} ${s.contentFull}`,iconEnd:w,iconFlipRtl:"both",scale:"m",textContent:C,title:C,onclick:g});this.removeCellContent(t),t.appendChild(v)},this.resizable=!0,this.showRelatedTableCallback=null,this.textAlign="center",this.width="200px"}get _relationshipLabel(){return this.label||this.originRelationship?.name||this.layer.title||""}get collapsed(){return this._get("collapsed")||!1}set collapsed(t){t?this.set({flexGrow:0,resizable:!1,width:"80px"}):this.set({flexGrow:1,resizable:!0,width:"200px"}),this._set("collapsed",t)}get effectiveLabel(){return this.collapsed?"":this._relationshipLabel}get iconNode(){const{icon:t}=this;return t?this.createCalciteIcon({icon:t,textLabel:this._relationshipLabel}):null}get originRelationship(){const t=this.relationshipId;return this.relatedLayer.relationships?.find((({id:e})=>e===t))}get relationship(){return n(this.layer,this.relationshipId)}};t([e()],p.prototype,"_relationshipLabel",null),t([e()],p.prototype,"collapsed",null),t([e()],p.prototype,"effectiveLabel",null),t([e()],p.prototype,"flexGrow",void 0),t([e()],p.prototype,"icon",void 0),t([e()],p.prototype,"iconNode",null),t([e()],p.prototype,"layer",void 0),t([e()],p.prototype,"originRelationship",null),t([e()],p.prototype,"relatedLayer",void 0),t([e()],p.prototype,"relationship",null),t([e()],p.prototype,"relationshipId",void 0),t([e()],p.prototype,"renderFunction",void 0),t([e()],p.prototype,"resizable",void 0),t([e()],p.prototype,"showRelatedTableCallback",void 0),t([e()],p.prototype,"textAlign",void 0),t([e()],p.prototype,"width",void 0),p=t([o("esri.widgets.FeatureTable.RelationshipColumn")],p);const c=p;export{c as default};