From 85d3e1786f5e085ea2899c59deee8c7c5e636bc5 Mon Sep 17 00:00:00 2001 From: Sergio Soler Sanchis Date: Mon, 16 Oct 2017 16:57:36 +0200 Subject: [PATCH] possibility to display values of index nested fieldsin the POI's tooltip --- public/POIs.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/POIs.js b/public/POIs.js index 9d07bbd..9ce2b2a 100644 --- a/public/POIs.js +++ b/public/POIs.js @@ -155,8 +155,17 @@ define(function (require) { POIs.prototype._popupContent = function (hit) { let dlContent = ''; + const nestedField = function (object, field) { + const isNested = field.split('.').length > 1; + if (isNested === false){ + return object[field] + } + const nestedFieldsArray = field.split('.'); + const firstField = nestedFieldsArray.splice(0, 1); + return nestedField(object[firstField], nestedFieldsArray.join('.')); + } this.popupFields.forEach(function(field) { - dlContent += `
${field}
${hit._source[field]}
` + dlContent += `
${field}
${nestedField(hit._source,field)}
` }); return `
${dlContent}
`; }