12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import e from"../../PopupTemplate.js";import r from"../../core/Error.js";import{fetchMessageBundle as i}from"../../intl/messages.js";import{getFieldAndExpressionInfos as n,getContentFromFieldInfos as t}from"./support/utils.js";async function o(e){const{layer:i,renderer:n}=e;await i.load();const t=n||i.renderer;if("unique-value"!==t.type)throw new r("relationship-popup:invalid-parameters","renderer.type must be 'unique-value'");const o=t.authoringInfo;if(!o||"relationship"!==o.type)throw new r("relationship-popup:invalid-parameters","renderer.authoringInfo.type must be 'relationship'");if(!(o.field1&&o.field1.field&&o.field2&&o.field2.field))throw new r("relationship-popup:invalid-parameters","'field1' and/or 'field2' properties are missing in renderer.authoringInfo");return{layer:i,renderer:t}}async function a(r,i,o="divide"){const{fieldInfos:a,expressionInfos:s}=await n({renderer:r,layer:i,normFieldExpressionTemplate:o});return new e({content:await t(i,{fieldInfos:a,expressionInfos:s}),fieldInfos:a,expressionInfos:s})}function s(e){const r=e.authoringInfo;return!(!r.field1.normalizationField&&!r.field2.normalizationField)}async function p(e){const[{renderer:r,layer:n},t]=await Promise.all([o(e),i("esri/smartMapping/t9n/smartMapping")]),p={name:"relationship",title:t.relationshipPopupTitle,value:await a(r,n)},l=[];return s(r)&&l.push({name:"relationship-percent",title:t.relationshipNormFieldAsPercent,value:await a(r,n,"percentage")}),{primaryTemplate:p,secondaryTemplates:l}}export{p as getTemplates};
|