UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.35 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 e}from"../../chunks/tslib.es6.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import l from"./BuildingNumericFilterViewModel.js";import{findFieldInfoByModelName as i}from"./support/buildingLayerUtils.js";import{getValueFromFilters as r}from"./support/filterUtils.js";import{getDomainInfo as o}from"./support/validation.js";const a="demolishedphase",d="createdphase";let n=class extends l{constructor(e){super(e),this._createdPhaseFieldName=null,this._demolishedPhaseFieldName=null,this._parseValueFromFilter=e=>{const s=this._createdPhaseFieldName,t=new RegExp(`${s}\\s*<=\\s*(\\d+)\\s*OR\\s*${s}\\s*IS\\s*NULL`,"gi"),l=this._demolishedPhaseFieldName,i=new RegExp(`${l}\\s*>\\s*(\\d+)\\s*OR\\s*${l}\\s*IS\\s*NULL`,"gi");for(const{filterExpression:r}of e.filterBlocks?.items??[]){const e=r?t.exec(r)??i.exec(r):null;if(e)return parseInt(e[1],10)}return null}}get filterExpressions(){if(!this.enabled)return{solid:null,xRay:null};const e=[],s=this._createdPhaseFieldName;s&&e.push(`(${s} <= ${this.value} OR ${s} IS NULL)`);const t=this._demolishedPhaseFieldName;t&&e.push(`(${t} > ${this.value} OR ${t} IS NULL)`);const l=e.join(" AND ");return{solid:l,xRay:l}}get _lastValue(){const e=this.allowedValues;return e.length>0?e[e.length-1]:0}_setup(){const e=[];this.layers.forEach((s=>{const t=i(s,d);null!=t&&(this._createdPhaseFieldName=t.fieldName,e.push(t));const l=i(s,a);null!=l&&(this._demolishedPhaseFieldName=l.fieldName,e.push(l))})),this._domainInfo=o(e);const s=this._valueBeforeReady;if(this._set("state","ready"),this._valueBeforeReady=null,this.allowedValues.length>0){const e=s??r(this.layers,this._parseValueFromFilter);this.select(e??this._lastValue)}else this.clear()}};e([s({readOnly:!0})],n.prototype,"filterExpressions",null),e([s()],n.prototype,"_createdPhaseFieldName",void 0),e([s()],n.prototype,"_demolishedPhaseFieldName",void 0),e([s({readOnly:!0})],n.prototype,"_lastValue",null),n=e([t("esri.widgets.BuildingExplorer.BuildingPhase")],n);const h=n;export{h as default};