From 44d2da291d679dbadebe9404e3763be823cbae5c Mon Sep 17 00:00:00 2001 From: at055612 Date: Wed, 20 Feb 2019 22:49:51 +0000 Subject: [PATCH] gh-31 Fix incorect sort direction logic in computeUniqueValues --- war/vis/Common.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/war/vis/Common.js b/war/vis/Common.js index 57f916a..7f32781 100644 --- a/war/vis/Common.js +++ b/war/vis/Common.js @@ -1216,10 +1216,11 @@ if(!visualisations) { // If there isn't then the order will be insertion order into the // sets. if (obj.hasOwnProperty('sortDirections')) { - if (obj.sortDirections[fieldIndex] === commonConstants.sortDescending) { + var sortDirection = obj.sortDirections[fieldIndex]; + if (sortDirection === commonConstants.sortDescending) { obj.unique[fieldIndex].reverse(); obj.visibleUnique[fieldIndex].reverse(); - } else { + } else if (sortDirection === commonConstants.sortAscending){ obj.unique[fieldIndex].sort(); obj.visibleUnique[fieldIndex].sort(); } @@ -1278,10 +1279,11 @@ if(!visualisations) { // If there isn't then the order will be insertion order into the // sets. if (data.hasOwnProperty('keySortDirection')) { - if (data.keySortDirection === commonConstants.sortDescending) { + var sortDirection = data.keySortDirection; + if (sortDirection === commonConstants.sortDescending) { data.uniqueKeys.reverse(); data.visibleUniqueKeys.reverse(); - } else { + } else if (sortDirection === commonConstants.sortDescending) { data.uniqueKeys.sort(); data.visibleUniqueKeys.sort(); }