Skip to content

Commit

Permalink
Fix property value undefined check (#276) (#284)
Browse files Browse the repository at this point in the history
If property value is false, property is not added.
Replace check with undefined to accept false value.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] authored Feb 22, 2023
1 parent c50d92b commit 9a10e4b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions public/model/documentLayerFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ const openSearchGeoJSONMap = new Map<string, string>([

const getFieldValue = (data: any, name: string) => {
if (!name) {
return null;
return undefined;
}
const keys = name.split('.');
return keys.reduce((pre, cur) => {
return pre?.[cur];
}, data);
};

const getCurrentStyleLayers = (maplibreRef: MaplibreRef) => {
return maplibreRef.current?.getStyle().layers || [];
};

const getGeoFieldType = (layerConfig: DocumentLayerSpecification) => {
return layerConfig?.source?.geoFieldType;
};
Expand Down Expand Up @@ -84,8 +80,8 @@ const buildProperties = (document: any, fields: string[]) => {
return property;
}
fields.forEach((field) => {
const fieldValue = getFieldValue(document._source, field);
if (fieldValue) {
const fieldValue: string | undefined = getFieldValue(document._source, field);
if (fieldValue !== undefined) {
property[field] = fieldValue;
}
});
Expand Down

0 comments on commit 9a10e4b

Please sign in to comment.