From 0ff360ced31885ce51e38e50de56322156787fec Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 14 Mar 2016 11:53:28 -0700 Subject: [PATCH] [Timelines] Remove excessive ternaries ...to improve readability of logic to determine which columns are needed for a given group of domain objects for CSV export, as requested during code review, https://github.com/nasa/openmctweb/pull/728#discussion_r55910477 --- .../src/actions/TimelineCSVExporter.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/platform/features/timeline/src/actions/TimelineCSVExporter.js b/platform/features/timeline/src/actions/TimelineCSVExporter.js index 17d8941865..edf06bec7b 100644 --- a/platform/features/timeline/src/actions/TimelineCSVExporter.js +++ b/platform/features/timeline/src/actions/TimelineCSVExporter.js @@ -88,21 +88,26 @@ define([ domainObjects.forEach(function (domainObject) { var model = domainObject.getModel(), - compositionLength = model.composition ? - model.composition.length : 0, - relationshipLength = (model.relationships || {}).modes ? - model.relationships.modes.length : - 0, - metadataProperties = - domainObject.useCapability('metadata') || []; + composition = model.composition, + relationships = model.relationships, + modes = relationships && relationships.modes, + metadataProperties = domainObject.useCapability('metadata'); - maxComposition = Math.max(maxComposition, compositionLength); - maxRelationships = Math.max(maxRelationships, relationshipLength); + if (composition) { + maxComposition = Math.max(maxComposition, composition.length); + } - foundTimespan = - foundTimespan || domainObject.hasCapability('timespan'); + if (modes) { + maxRelationships = Math.max(maxRelationships, modes.length); + } - metadataProperties.forEach(addMetadataProperty); + if (domainObject.hasCapability('timespan')) { + foundTimespan = true; + } + + if (metadataProperties) { + metadataProperties.forEach(addMetadataProperty); + } }); if (foundTimespan) { @@ -153,4 +158,4 @@ define([ }; return TimelineCSVExporter; -}); \ No newline at end of file +});