mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[WIP] [explorev2] Refactor filter into FieldSet (#1981)
* [explorev2] Refactor filter into FieldSet * Fixed tests * Added tests * Modifications based on comments
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/* eslint camelcase: 0 */
|
||||
import { defaultFormData } from '../stores/store';
|
||||
import * as actions from '../actions/exploreActions';
|
||||
import { addToArr, removeFromArr, alterInArr } from '../../../utils/reducerUtils';
|
||||
import { now } from '../../modules/dates';
|
||||
import { getExploreUrl } from '../exploreUtils';
|
||||
|
||||
@@ -41,37 +40,6 @@ export const exploreReducer = function (state, action) {
|
||||
[actions.SET_DATASOURCE]() {
|
||||
return Object.assign({}, state, { datasource: action.datasource });
|
||||
},
|
||||
[actions.SET_FILTER_COLUMN_OPTS]() {
|
||||
return Object.assign({}, state, { filterColumnOpts: action.filterColumnOpts });
|
||||
},
|
||||
[actions.ADD_FILTER]() {
|
||||
const newFormData = addToArr(state.viz.form_data, 'filters', action.filter);
|
||||
const newState = Object.assign(
|
||||
{},
|
||||
state,
|
||||
{ viz: Object.assign({}, state.viz, { form_data: newFormData }) }
|
||||
);
|
||||
return newState;
|
||||
},
|
||||
[actions.REMOVE_FILTER]() {
|
||||
const newFormData = removeFromArr(state.viz.form_data, 'filters', action.filter);
|
||||
return Object.assign(
|
||||
{},
|
||||
state,
|
||||
{ viz: Object.assign({}, state.viz, { form_data: newFormData }) }
|
||||
);
|
||||
},
|
||||
[actions.CHANGE_FILTER]() {
|
||||
const changes = {};
|
||||
changes[action.field] = action.value;
|
||||
const newFormData = alterInArr(
|
||||
state.viz.form_data, 'filters', action.filter, changes);
|
||||
return Object.assign(
|
||||
{},
|
||||
state,
|
||||
{ viz: Object.assign({}, state.viz, { form_data: newFormData }) }
|
||||
);
|
||||
},
|
||||
[actions.SET_FIELD_VALUE]() {
|
||||
let newFormData = Object.assign({}, state.viz.form_data);
|
||||
if (action.fieldName === 'datasource') {
|
||||
|
||||
Reference in New Issue
Block a user