select and deselect

This commit is contained in:
Colin Megill
2017-11-02 06:34:50 -07:00
parent 764f082d24
commit b5f068abf9
12 changed files with 134 additions and 90 deletions
-1
View File
@@ -17,7 +17,6 @@ const Cells = (state = {
});
case "request cells error":
return Object.assign({}, state, {
cells: null,
loading: false,
error: action.data
});
+3
View File
@@ -1,10 +1,13 @@
import { combineReducers, createStore, applyMiddleware } from 'redux';
import updateURLMiddleware from "../middleware/updateURLMiddleware";
import thunk from "redux-thunk";
import initialize from "./initialize";
import cells from "./cells";
import selectedMetadata from "./selectedMetadata";
const Reducer = combineReducers({
initialize,
cells,
selectedMetadata,
})
+29
View File
@@ -0,0 +1,29 @@
const Initialize = (state = {
data: null,
loading: null,
error: null,
}, action) => {
switch (action.type) {
case "initialize started":
return Object.assign({}, state, {
loading: true,
error: null
});
case "initialize success":
return Object.assign({}, state, {
error: null,
loading: false,
data: action.data,
});
case "initialize error":
return Object.assign({}, state, {
data: null,
loading: false,
error: action.data
});
default:
return state;
}
};
export default Initialize;
+3 -3
View File
@@ -3,7 +3,7 @@ import _ from "lodash";
/************************************************************************
*************************************************************************
1. This is all of the state that will be stored in the URL query params.
1. This is state that will be stored in the URL query params.
1a. It is reasonably important it be kept in the same place,
because if initial load or back button etc, we'll hear about that
and manually reconstruct the state from the url, overriding whatever
@@ -25,7 +25,7 @@ const selectedMetadata = (
// console.log("onURLchange sees: ", state, parsed)
return state;
}
case "categorical metadata filter selected": {
case "categorical metadata filter selected success": {
if (!state[action.metadataField]) { /* we don't have the field, which means this is a simple insertion */
/* {} becomes {Location: ["Tumor"]} */
return Object.assign({}, state, {[action.metadataField]: [action.value]});
@@ -43,7 +43,7 @@ const selectedMetadata = (
this the category button is selected when it's clicked (it's bold, etc),
so we can fire a different action to save us some nesting logic here
*/
case "categorical metadata filter deselected": {
case "categorical metadata filter deselected success": {
/* remove the value the user just selected from the appropriate array */
let updatedField = _.without(state[action.metadataField], action.value);
/* if the array now looks like this {Location: []} */