From 5efc031f73c87d45426b3fd75a6f6854377105e6 Mon Sep 17 00:00:00 2001 From: Curtis McCully Date: Wed, 31 May 2023 11:10:27 -0400 Subject: [PATCH] Fixes to not display units if there are no values. --- src/mixins/messageFormatMixin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mixins/messageFormatMixin.js b/src/mixins/messageFormatMixin.js index 8783212..2eea274 100644 --- a/src/mixins/messageFormatMixin.js +++ b/src/mixins/messageFormatMixin.js @@ -45,12 +45,14 @@ export var messageFormatMixin = { if (!_.isEmpty(message[i].orbital_elements)){ message[i].orbital_elements = _.omitBy(message[i].orbital_elements, field => field === null || (_.isEmpty(field) && !_.isBoolean(field))); } + message[i] = _.omitBy(message[i], (value, key) => key.includes('unit') && key.replace('_unit', '') in message[i] && message[i][key.replace('_unit', '')] === null); message[i] = _.omitBy(message[i], field => field === null || (_.isEmpty(field) && !_.isBoolean(field))); if (!_.isEmpty(message[i].aliases)){ message[i].aliases = message[i].aliases.split(','); } } - return message; + // Remove empty objects + return message.filter(obj => Object.keys(obj).length !== 0); }, flattenExtraData: function(extra_data) { const keywordSections = ['targets', 'references', 'event_id', 'astrometry', 'spectroscopy'];