You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
16 KiB
33 lines
16 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../../chunks/tslib.es6 ../../geometry ../../Graphic ../../arcade/featureset/support/FeatureSetQueryInterceptor ../../core/Accessor ../../core/arrayUtils ../../core/Identifiable ../../core/Logger ../../core/promiseUtils ../../core/reactiveUtils ../../core/throttle ../../core/accessorSupport/decorators/property ../../core/accessorSupport/decorators/cast ../../core/has ../../core/accessorSupport/decorators/subclass ../../popup/content/TextContent ../../time/timeZoneUtils ./FeatureAttachments/FeatureAttachmentsViewModel ./FeatureContent/FeatureContentViewModel ./FeatureExpression/FeatureExpressionViewModel ./FeatureFields/FeatureFieldsViewModel ./FeatureMedia/FeatureMediaViewModel ./FeatureRelationship/FeatureRelationshipViewModel ./support/arcadeFeatureUtils ./support/featureUtils ./support/relatedFeatureUtils ../../geometry/Point".split(" "), |
|
function(m,k,A,B,C,D,E,F,x,u,G,n,H,U,I,J,K,L,y,M,N,w,O,P,p,t,Q){var v;const z={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0};k=v=class extends E.IdentifiableMixin(C){constructor(a){super(a);this._featureAbortController=this._error=null;this._graphicChangedThrottled=G.throttle(this._graphicChanged,1,this);this._graphicExpressionAttributes=this._expressionAttributes=null;this.abilities={...z};this.content= |
|
null;this.contentViewModels=[];this.description=null;this.defaultPopupTemplateEnabled=!1;this.location=this.lastEditInfo=this.formattedAttributes=null;this.relatedInfos=new Map;this.title="";this.view=null;this._isAllowedContentType=b=>{const {abilities:c}=this;return"attachments"===b.type&&!!c.attachmentsContent||"custom"===b.type&&!!c.customContent||"fields"===b.type&&!!c.fieldsContent||"media"===b.type&&!!c.mediaContent||"text"===b.type&&!!c.textContent||"expression"===b.type&&!!c.expressionContent|| |
|
"relationship"===b.type&&!!c.relationshipContent};this.addHandles(u.watch(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),u.initial))}initialize(){this.addHandles(this._graphicChangedThrottled)}destroy(){this._clear();this._cancelFeatureQuery();this.graphic=this._error=null;this._destroyContentViewModels();this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled): |
|
null}get _fieldInfoMap(){return p.createFieldInfoMap(p.getAllFieldInfos(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return p.getSourceLayer(this.graphic)}castAbilities(a){return{...z,...a}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(a){this._set("graphic",a?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(a){this._override("spatialReference", |
|
a)}get timeZone(){return this.view?.timeZone??K.system}set timeZone(a){this._overrideIfSome("timeZone",a)}get map(){return this.view?.map||null}set map(a){this._override("map",a)}get waitingForContent(){return!!this._featureAbortController}setActiveMedia(a,b){a=this.contentViewModels[a];a instanceof w&&a.setActiveMedia(b)}nextMedia(a){a=this.contentViewModels[a];a instanceof w&&a.next()}previousMedia(a){a=this.contentViewModels[a];a instanceof w&&a.previous()}async updateGeometry(){const {graphic:a, |
|
spatialReference:b,_sourceLayer:c}=this;await c?.load();var d=c?.objectIdField;d&&a&&c&&(d=a?.attributes?.[d],null!=d&&(d=[d],!a.geometry&&(d=(await p.querySourceLayer({layer:c,graphic:a,outFields:[],objectIds:d,returnGeometry:!0,spatialReference:b}))?.geometry)))&&(a.geometry=d)}_clear(){this._set("title","");this._set("content",null);this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery();this._error=null;this._clear();const {graphic:a}=this;if(a){var b=new AbortController; |
|
this._featureAbortController=b;try{await this._queryFeature({signal:b.signal})}catch(c){x.isAbortError(c)||(this._error=c,F.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:a,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===b&&(this._featureAbortController=null)}}_cancelFeatureQuery(){const {_featureAbortController:a}=this;a&&a.abort();this._featureAbortController=null}_compileContentElement(a,b){if("attachments"=== |
|
a.type)return this._compileAttachments(a,b);if("custom"===a.type)return this._compileCustom(a,b);if("fields"===a.type)return this._compileFields(a,b);if("media"===a.type)return this._compileMedia(a,b);if("text"===a.type)return this._compileText(a,b);if("expression"===a.type)return this._compileExpression(a,b);if("relationship"===a.type)return this._compileRelationship(a,b)}_compileContent(a){this._destroyContentViewModels();if(this.graphic)return Array.isArray(a)?a.filter(this._isAllowedContentType).map((b, |
|
c)=>this._compileContentElement(b,c)).filter(D.isSome):"string"===typeof a?this._compileText(new J({text:a}),0).text:a}_destroyContentViewModels(){this.removeHandles("relationship-view-models");this.removeHandles("content-view-models");this.contentViewModels.forEach(a=>a&&!a.destroyed&&a.destroy());this._set("contentViewModels",[])}_matchesFeature(a,b){a=a?.graphic?.getObjectId();b=b?.getObjectId();return null!=a&&null!=b&&a===b}_setRelatedFeaturesViewModels({relatedFeatureViewModels:a,relatedFeatures:b, |
|
map:c}){const {view:d,spatialReference:e,timeZone:h}=this;b?.filter(Boolean).forEach(l=>{a.some(g=>this._matchesFeature(g,l))||a.add(new v({abilities:{relationshipContent:!1},map:c,view:d,spatialReference:e,timeZone:h,graphic:l}))});a.forEach(l=>{b?.find(g=>this._matchesFeature(l,g))||a.remove(l)})}_setExpressionContentVM(a,b){const c=this.formattedAttributes,{contentElement:d,contentElementViewModel:e}=a;a=d?.type;e&&a&&("fields"===a&&(this._createFieldsFormattedAttributes({contentElement:d,contentElementIndex:b, |
|
formattedAttributes:c}),e.set(this._createFieldsVMParams(d,b))),"media"===a&&(this._createMediaFormattedAttributes({contentElement:d,contentElementIndex:b,formattedAttributes:c}),e.set(this._createMediaVMParams(d,b))),"text"===a&&e.set(this._createTextVMParams(d)))}_compileRelationship(a,b){const {displayCount:c,orderByFields:d,relationshipId:e,title:h,description:l}=a,{_sourceLayer:g,graphic:f,map:q}=this;if(p.isRelatableFeatureSupportedLayer(g)){var r=new O({displayCount:c,graphic:f,orderByFields:d, |
|
relationshipId:e,layer:g,map:q,...this._compileTitleAndDesc({title:h,description:l})});this.contentViewModels[b]=r;this.addHandles(u.on(()=>r.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(r)),"relationship-view-models");return a}}_compileExpression(a,b){const {expressionInfo:c}=a,{graphic:d,map:e,spatialReference:h,view:l,location:g}=this,f=new M({expressionInfo:c,graphic:d,interceptor:v.interceptor,map:e,spatialReference:h,view:l,location:g});this.contentViewModels[b]=f;this.addHandles(u.watch(()=> |
|
f.contentElementViewModel,()=>this._setExpressionContentVM(f,b),u.initial),"content-view-models");return a}_compileAttachments(a,b){const {graphic:c}=this,{description:d,title:e}=a;this.contentViewModels[b]=new L({graphic:c,...this._compileTitleAndDesc({title:e,description:d})});return a}_compileCustom(a,b){const {graphic:c}=this,{creator:d,destroyer:e}=a;this.contentViewModels[b]=new y({graphic:c,creator:d,destroyer:e});return a}_compileTitleAndDesc({title:a,description:b}){const {_fieldInfoMap:c, |
|
_sourceLayer:d,graphic:e,formattedAttributes:h}=this,l=e?.attributes,g=this._expressionAttributes,f=h.global;return{title:p.substituteFieldsInLinksAndAttributes({attributes:l,fieldInfoMap:c,globalAttributes:f,expressionAttributes:g,layer:d,text:a}),description:p.substituteFieldsInLinksAndAttributes({attributes:l,fieldInfoMap:c,globalAttributes:f,expressionAttributes:g,layer:d,text:b})}}_createFieldsVMParams(a,b){const c=this._effectivePopupTemplate,d=this.formattedAttributes,e={...d?.global,...d?.content[b]}; |
|
b=(a?.fieldInfos||c?.fieldInfos)?.filter(({fieldName:g})=>!!g&&(p.isExpressionField(g)||p.isRelatedField(g)||e.hasOwnProperty(g)));const {description:h,title:l}=a;return{attributes:e,expressionInfos:c?.expressionInfos,fieldInfos:b,...this._compileTitleAndDesc({title:l,description:h})}}_compileFields(a,b){const c=a.clone();a=new N(this._createFieldsVMParams(a,b));this.contentViewModels[b]=a;c.fieldInfos=a.formattedFieldInfos.slice(0);return c}_createMediaVMParams(a,b){const {abilities:c,graphic:d, |
|
_fieldInfoMap:e,_effectivePopupTemplate:h,relatedInfos:l,_sourceLayer:g,_expressionAttributes:f}=this,q=this.formattedAttributes,r=d?.attributes??{},{description:R,mediaInfos:S,title:T}=a;return{abilities:{chartAnimation:c.chartAnimation},activeMediaInfoIndex:a.activeMediaInfoIndex||0,attributes:r,isAggregate:d?.isAggregate,layer:g,fieldInfoMap:e,formattedAttributes:{...q?.global,...q?.content[b]},expressionAttributes:f,mediaInfos:S,popupTemplate:h,relatedInfos:l,...this._compileTitleAndDesc({title:T, |
|
description:R})}}_compileMedia(a,b){const c=a.clone();a=new w(this._createMediaVMParams(a,b));c.mediaInfos=a.formattedMediaInfos.slice(0);this.contentViewModels[b]=a;return c}_createTextVMParams(a){const {graphic:b,_fieldInfoMap:c,_sourceLayer:d,_expressionAttributes:e}=this;a&&a.text&&(a.text=p.substituteFieldsInLinksAndAttributes({attributes:b?.attributes??{},fieldInfoMap:c,globalAttributes:this.formattedAttributes?.global??{},expressionAttributes:e,layer:d,text:a.text}));return{graphic:b,creator:a.text}}_compileText(a, |
|
b){a=a.clone();this.contentViewModels[b]=new y(this._createTextVMParams(a));return a}_compileLastEditInfo(){const {_effectivePopupTemplate:a,_sourceLayer:b,graphic:c,timeZone:d}=this;if(a){var {lastEditInfoEnabled:e}=a,h=b?.editFieldsInfo;if(e&&h)return p.formatEditInfo(h,c?.attributes,d,b)}}_compileTitle(a){const {_fieldInfoMap:b,_sourceLayer:c,graphic:d,_expressionAttributes:e}=this;return p.substituteFieldsInLinksAndAttributes({attributes:d?.attributes??{},fieldInfoMap:b,globalAttributes:this.formattedAttributes?.global?? |
|
{},expressionAttributes:e,layer:c,text:a})}async _getTitle(){const {_effectivePopupTemplate:a,graphic:b}=this;return b?p.graphicCallback({type:"title",value:a?.title,event:{graphic:b}}):null}async _getContent(){const {_effectivePopupTemplate:a,graphic:b}=this;return b?p.graphicCallback({type:"content",value:a?.content,event:{graphic:b}}):null}async _queryFeature(a){const {_featureAbortController:b,_sourceLayer:c,graphic:d,_effectivePopupTemplate:e}=this,h=this.map,l=this.view,g=this.spatialReference, |
|
f=this.location;if(b===this._featureAbortController&&d){await p.queryUpdatedFeature({graphic:d,popupTemplate:e,layer:c,spatialReference:g},a);var {content:{value:q},title:{value:r}}=await x.eachAlways({content:this._getContent(),title:this._getTitle()});({expressionAttributes:{value:a}}=await x.eachAlways({checkForRelatedFeatures:this._checkForRelatedFeatures(a),expressionAttributes:P.createCompiledExpressions({expressionInfos:e?.expressionInfos,spatialReference:g,graphic:d,map:h,interceptor:v.interceptor, |
|
view:l,options:a,location:f})}));b===this._featureAbortController&&d&&(this._expressionAttributes=a,this._graphicExpressionAttributes={...d.attributes,...a},this._set("formattedAttributes",this._createFormattedAttributes(q)),this._set("title",this._compileTitle(r)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(q)||null))}}_createMediaFormattedAttributes({contentElement:a,contentElementIndex:b,formattedAttributes:c}){const {_effectivePopupTemplate:d, |
|
graphic:e,relatedInfos:h,_sourceLayer:l,_fieldInfoMap:g,_graphicExpressionAttributes:f,timeZone:q}=this;c.content[b]=p.formatAttributes({fieldInfos:d?.fieldInfos,graphic:e,attributes:{...f,...a.attributes},layer:l,fieldInfoMap:g,relatedInfos:h,timeZone:q})}_createFieldsFormattedAttributes({contentElement:a,contentElementIndex:b,formattedAttributes:c}){if(a.fieldInfos){const {graphic:d,relatedInfos:e,_sourceLayer:h,_fieldInfoMap:l,_graphicExpressionAttributes:g,timeZone:f}=this;c.content[b]=p.formatAttributes({fieldInfos:a.fieldInfos, |
|
graphic:d,attributes:{...g,...a.attributes},layer:h,fieldInfoMap:l,relatedInfos:e,timeZone:f})}}_createFormattedAttributes(a){const {_effectivePopupTemplate:b,graphic:c,relatedInfos:d,_sourceLayer:e,_fieldInfoMap:h,_graphicExpressionAttributes:l,timeZone:g}=this,f={global:p.formatAttributes({fieldInfos:b?.fieldInfos,graphic:c,attributes:l,layer:e,fieldInfoMap:h,relatedInfos:d,timeZone:g}),content:[]};Array.isArray(a)&&a.forEach((q,r)=>{"fields"===q.type&&this._createFieldsFormattedAttributes({contentElement:q, |
|
contentElementIndex:r,formattedAttributes:f});"media"===q.type&&this._createMediaFormattedAttributes({contentElement:q,contentElementIndex:r,formattedAttributes:f})});return f}_checkForRelatedFeatures(a){const {graphic:b,_effectivePopupTemplate:c}=this;return this._queryRelatedInfos(b,p.getAllFieldInfos(c),a)}async _queryRelatedInfos(a,b,c){const {relatedInfos:d,_sourceLayer:e}=this;d.clear();const h=null!=e?.associatedLayer?await e?.associatedLayer.load(c):e;if(h&&a&&b.filter(f=>!!f.fieldName&&p.isRelatedField(f.fieldName))?.length){b.forEach(f=> |
|
this._configureRelatedInfo(f,h));var l=await t.queryLayerInfos({relatedInfos:d,layer:h},c);Object.keys(l).forEach(f=>{const q=d.get(f.toString());f=l[f]?.value;q&&f&&(q.layerInfo=f.data)});var g=await t.queryRelatedFeatures({graphic:a,relatedInfos:d,layer:h},c);Object.keys(g).forEach(f=>{t.setRelatedFeatures(g[f]?.value,d.get(f.toString()))})}}_configureRelatedInfo(a,b){const {relatedInfos:c}=this,d=t.getRelatedFieldInfo(a.fieldName||"");if(d){var {layerId:e,fieldName:h}=d;e&&(b=c.get(e.toString())|| |
|
t.createRelatedInfo(e,b))&&(t.updateRelatedInfo({relatedInfo:b,fieldName:h,fieldInfo:a}),this.relatedInfos.set(e,b))}}};k.interceptor=new B.FeatureSetQueryInterceptor(p.preLayerQueryCallback,p.preRequestCallback);m.__decorate([n.property()],k.prototype,"_error",void 0);m.__decorate([n.property()],k.prototype,"_featureAbortController",void 0);m.__decorate([n.property({readOnly:!0})],k.prototype,"_effectivePopupTemplate",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"_fieldInfoMap",null); |
|
m.__decorate([n.property({readOnly:!0})],k.prototype,"_sourceLayer",null);m.__decorate([n.property()],k.prototype,"abilities",void 0);m.__decorate([H.cast("abilities")],k.prototype,"castAbilities",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"content",void 0);m.__decorate([n.property({readOnly:!0})],k.prototype,"contentViewModels",void 0);m.__decorate([n.property()],k.prototype,"description",void 0);m.__decorate([n.property({type:Boolean})],k.prototype,"defaultPopupTemplateEnabled", |
|
void 0);m.__decorate([n.property({readOnly:!0})],k.prototype,"isTable",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"state",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"formattedAttributes",void 0);m.__decorate([n.property({type:A,value:null})],k.prototype,"graphic",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"lastEditInfo",void 0);m.__decorate([n.property({type:Q})],k.prototype,"location",void 0);m.__decorate([n.property({readOnly:!0})],k.prototype,"relatedInfos", |
|
void 0);m.__decorate([n.property()],k.prototype,"spatialReference",null);m.__decorate([n.property()],k.prototype,"timeZone",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"title",void 0);m.__decorate([n.property()],k.prototype,"map",null);m.__decorate([n.property({readOnly:!0})],k.prototype,"waitingForContent",null);m.__decorate([n.property()],k.prototype,"view",void 0);return k=v=m.__decorate([I.subclass("esri.widgets.Feature.FeatureViewModel")],k)}); |