From 6c0f8ba63897e98b3bf9f3a2d33dbfe0401e7848 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Wed, 3 Aug 2016 14:21:33 +0200 Subject: [PATCH 1/2] table-mode: handle nodes w/ no value for sorted column gracefully - put empty values below those that have a value. +-----+-----+ |3 |5 | |4 |4 | |5 |3 | |null |null | |null |null | +-----+-----+ --- .../components/node-details/node-details-table.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/app/scripts/components/node-details/node-details-table.js b/client/app/scripts/components/node-details/node-details-table.js index bc403712a..fa3b81eda 100644 --- a/client/app/scripts/components/node-details/node-details-table.js +++ b/client/app/scripts/components/node-details/node-details-table.js @@ -87,7 +87,7 @@ function getMetaDataSorters(nodes) { } -function getSortedNodes(nodes, columns, sortBy, sortedDesc) { +function sortNodes(nodes, columns, sortBy, sortedDesc) { const sortedNodes = _.sortBy( nodes, getValueForSortBy(sortBy || getDefaultSortBy(columns, nodes)), @@ -101,6 +101,19 @@ function getSortedNodes(nodes, columns, sortBy, sortedDesc) { } +function getSortedNodes(nodes, columns, sortBy, sortedDesc) { + const getValue = getValueForSortBy(sortBy || getDefaultSortBy(columns, nodes)); + const withAndWithoutValues = _.groupBy(nodes, (n) => { + const v = getValue(n); + return v !== null && v !== undefined; + }); + const withValues = sortNodes(withAndWithoutValues.true, columns, sortBy, sortedDesc); + const withoutValues = sortNodes(withAndWithoutValues.false, columns, sortBy, sortedDesc); + + return _.concat(withValues, withoutValues); +} + + function getColumnsWidths(headers) { return headers.map((h, i) => { // From d02cb25495484ba907610c38c2144c8be13e6cad Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Wed, 3 Aug 2016 17:25:09 +0200 Subject: [PATCH 2/2] Tidyup JS: make keys in grouping dict more sensible true/false are confusing. --- .../scripts/components/node-details/node-details-table.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/app/scripts/components/node-details/node-details-table.js b/client/app/scripts/components/node-details/node-details-table.js index fa3b81eda..ba09c3003 100644 --- a/client/app/scripts/components/node-details/node-details-table.js +++ b/client/app/scripts/components/node-details/node-details-table.js @@ -105,10 +105,10 @@ function getSortedNodes(nodes, columns, sortBy, sortedDesc) { const getValue = getValueForSortBy(sortBy || getDefaultSortBy(columns, nodes)); const withAndWithoutValues = _.groupBy(nodes, (n) => { const v = getValue(n); - return v !== null && v !== undefined; + return v !== null && v !== undefined ? 'withValues' : 'withoutValues'; }); - const withValues = sortNodes(withAndWithoutValues.true, columns, sortBy, sortedDesc); - const withoutValues = sortNodes(withAndWithoutValues.false, columns, sortBy, sortedDesc); + const withValues = sortNodes(withAndWithoutValues.withValues, columns, sortBy, sortedDesc); + const withoutValues = sortNodes(withAndWithoutValues.withoutValues, columns, sortBy, sortedDesc); return _.concat(withValues, withoutValues); }