Skip to content
Snippets Groups Projects
Commit cf7d2ac9 authored by esikkala's avatar esikkala
Browse files

Add selector for visible result values

parent 4f2772de
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,10 @@ import ExpansionPanel from '@material-ui/core/ExpansionPanel';
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import { getVisibleResults } from '../selectors';
import {
getVisibleResults,
getVisibleValues
} from '../selectors';
import {
updateQuery,
......@@ -133,7 +136,7 @@ let MapApp = (props) => {
const { classes, error, theme, drawerIsOpen, mapReady } = props;
const anchor = 'left';
//console.log(props.results);
console.log(props.resultValues);
let resultsView = '';
if (props.results.length > 0) {
......@@ -265,6 +268,7 @@ let MapApp = (props) => {
const mapStateToProps = (state) => ({
search: state.search,
results: getVisibleResults(state),
resultValues: getVisibleValues(state),
drawerIsOpen: state.options.drawerIsOpen,
mapReady: state.options.mapReady,
error: state.error,
......@@ -309,6 +313,7 @@ MapApp.propTypes = {
updateResultFormat: PropTypes.func.isRequired,
resultFormat: PropTypes.string.isRequired,
results: PropTypes.array,
resultValues: PropTypes.object
};
MapApp = connect(
......
......@@ -16,3 +16,22 @@ export const getVisibleResults = createSelector(
}
}
);
export const getVisibleValues = createSelector(
[ getVisibleResults ],
(visibleResults) => {
let typeLabels = [];
let broaderAreaLabels = [];
let sources = [];
for (const result of visibleResults) {
typeLabels.push(result.typeLabel);
broaderAreaLabels.push(result.broaderAreaLabel);
sources.push(result.source);
}
return {
typeLabels: Array.from(new Set(typeLabels)),
broaderAreaLabels: Array.from(new Set(broaderAreaLabels)),
sources: Array.from(new Set(sources)),
};
}
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment