From 74fb1250de94eaba22631e605712f1dbec1fcdc9 Mon Sep 17 00:00:00 2001 From: James Hadfield Date: Sat, 4 Aug 2018 17:57:46 -0700 Subject: [PATCH] fix bug in available dataset parsing dataset matching now considers all previous entries in the hierarchy, not just the parent --- src/components/controls/choose-dataset.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/controls/choose-dataset.js b/src/components/controls/choose-dataset.js index 7cb89a2dd..3f49a4fee 100644 --- a/src/components/controls/choose-dataset.js +++ b/src/components/controls/choose-dataset.js @@ -10,6 +10,10 @@ const renderBareDataPath = (source, fields) => ( ); +const checkEqualityOfArrays = (arr1, arr2, upToIdx) => { + return arr1.slice(0, upToIdx).every((value, index) => value === arr2[index]); +}; + @connect((state) => { return { available: state.controls.available, @@ -33,17 +37,19 @@ class ChooseDataset extends React.Component { this.props.available.forEach((d) => { if (options[0].indexOf(d[0]) === -1) options[0].push(d[0]); - }) + }); for (let idx=1; idx { - if (ds[idx-1] === selected[idx-1] && options[idx].indexOf(ds[idx]) === -1) { - options[idx].push(ds[idx]); + this.props.available.forEach((query) => { + /* if the parents (and their parents etc) of this choice match, + then we add that as a valid option */ + if (checkEqualityOfArrays(query, selected, idx) && options[idx].indexOf(query[idx]) === -1) { + options[idx].push(query[idx]); } - }) + }); } const selectors = [];