Skip to content

Commit

Permalink
opacity in url
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsingal committed Jan 16, 2018
1 parent 2e8e23a commit 00ca013
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions app/scripts/pages/explore/explore-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const updateZIndex = createThunkAction('updateZIndex', () => (dispatch) =
dispatch(updateURLParams());
});
export const updateOpacity = createThunkAction('updateOpacity', () => (dispatch) => {
dispatch(updateActiveDatasets());
dispatch(updateURLParams());
});
export const receiveDatasets = createAction('receiveDatasets');
Expand All @@ -65,6 +66,34 @@ export const setDataFilters = createAction('explore-dataset-filters/setDataFilte
export const setGraphFilter = createAction('explore-dataset-filters/setGraphFilter');
export const clearFilters = createAction('explore-dataset-filters/clearFilters');

export const setDatasetFilter = createAction('explore-dataset-filters/setDatasetFilter');
export const updateDataFilters = createAction('explore-dataset-filters/updateDataFilters');
export const setInitialFilterStatus = createThunkAction('explore-dataset-filters/setInitialFilterStatus', () => (dispatch, getState) => {
const { data, originalData, filters } = getState().explorePage.datasetFilters;
const newdata = Object.assign({}, data);
// const _originalData = Object.assign({}, originalData);

if (!Object.keys(data).length) {
dispatch(updateDataFilters({}));
return;
}
if (!Object.keys(filters).length) {
dispatch(updateDataFilters({ ...originalData }));
return;
}

const newData = getSelectedElements(newdata, filters);

Object.keys(filters).forEach((filterKey) => {
const filterValues = filters[filterKey];
const dataTree = newData[filterKey] || [];

dataTree.forEach(child => selectElementsFromTree(child, filterValues));
});

dispatch(updateDataFilters(newData));
});

export const onClearFilters = createThunkAction('explore-dataset-filters/onClearFilters', () => (dispatch) => {
dispatch(clearFilters());
dispatch(setInitialFilterStatus());
Expand All @@ -88,8 +117,6 @@ export const fetchDatasets = createThunkAction('fetchDatasets', () => (dispatch)
})
.then((json) => {
const datasets = wriAPISerializer(json);
// const nexgdpDatasets = datasets.filter(d => (d.provider === 'nexgddp'));
// console.log(nexgdpDatasets);
dispatch(receiveDatasets(datasets));
dispatch(updateActiveDatasets());
})
Expand Down Expand Up @@ -122,37 +149,6 @@ export const setBoundaries = createThunkAction('setBoundaries', () => (dispatch)
dispatch(updateURLParams());
});

export const setDatasetFilter = createAction('explore-dataset-filters/setDatasetFilter');
export const updateDataFilters = createAction('explore-dataset-filters/updateDataFilters');
export const setInitialFilterStatus = createThunkAction('explore-dataset-filters/setInitialFilterStatus', () => (dispatch, getState) => {
const { data, originalData, filters } = getState().explorePage.datasetFilters;
const _data = Object.assign({}, data);
const _originalData = Object.assign({}, originalData);

if (!Object.keys(data).length) {
dispatch(updateDataFilters({}));
return;
}
if (!Object.keys(filters).length) {
dispatch(updateDataFilters({ ...originalData }));
return;
}

// const newData = Object.assign({}, data);

const newData = getSelectedElements(_data, filters);

Object.keys(filters).forEach((filterKey) => {
const filterValues = filters[filterKey];
const dataTree = newData[filterKey] || [];

dataTree.forEach(child => selectElementsFromTree(child, filterValues));
});

dispatch(updateDataFilters(newData));
});


// URL
export const initialURLParams = createThunkAction('initialURLParams', () => (dispatch, getState) => {
const { routing } = getState();
Expand Down

0 comments on commit 00ca013

Please sign in to comment.