From 7b3313e108330298356f19042d61a18a2daf5d29 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Thu, 7 Dec 2017 14:38:42 -0800 Subject: [PATCH] consume custom middleware in reducer, set initial allCells & selected --- src/reducers/controls.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/reducers/controls.js b/src/reducers/controls.js index 7c96385a..8f2b5f4b 100644 --- a/src/reducers/controls.js +++ b/src/reducers/controls.js @@ -8,6 +8,7 @@ const Controls = (state = { colorAccessor: null, colorScale: null, graphBrushSelection: null, + continuousSelection: null, axesHaveBeenDrawn: false, }, action) => { switch (action.type) { @@ -19,12 +20,14 @@ const Controls = (state = { _ranges: action.data.data.ranges }); case "request cells success": - const graphMap = {} - _.each(action.data.data.graph, (g) => { graphMap[g[0]] = [g[1], g[2]] }) + const graphMap = {}; + const currentCellSelection = action.data.data.metadata.slice(0); + _.each(action.data.data.graph, (g) => { graphMap[g[0]] = [g[1], g[2]] }); + _.each(currentCellSelection, (cell) => { cell["__selected__"] = true } ); return Object.assign({}, state, { allCellsOnClient: action.data.data, - currentCellSelection: action.data.data.metadata, + currentCellSelection, graphMap, graphBrushSelection: null, /* if we are getting new cells from the server, the layout (probably? definitely?) just changed, so this is now irrelevant, and we WILL need to call a function to reset state of this kind when cells success happens */ }); @@ -36,13 +39,15 @@ const Controls = (state = { axesHaveBeenDrawn: true }); case "continuous selection using parallel coords brushing": { + console.log("controls reducer", action) return Object.assign({}, state, { - currentCellSelection: action.data, + continuousSelection: action.data, }); } case "graph brush selection change": return Object.assign({}, state, { - graphBrushSelection: action.brushCoords + graphBrushSelection: action.brushCoords, /* this has already been applied in middleware but store it for next time */ + currentCellSelection: action.newSelection /* this comes from middleware */ }) case "graph brush deselect": return Object.assign({}, state, {