mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix: Table chart column config issue (#19841)
* Fix table chart column config issue * resolve comment
This commit is contained in:
parent
35db7fb6c5
commit
9376940282
@ -131,11 +131,30 @@ export default function exploreReducer(state = {}, action) {
|
||||
},
|
||||
[actions.SET_FIELD_VALUE]() {
|
||||
const new_form_data = state.form_data;
|
||||
const old_metrics_data = state.form_data.metrics;
|
||||
const new_column_config = state.form_data.column_config;
|
||||
const { controlName, value, validationErrors } = action;
|
||||
new_form_data[controlName] = value;
|
||||
|
||||
const vizType = new_form_data.viz_type;
|
||||
|
||||
// if the controlName is metrics, and the metric column name is updated,
|
||||
// need to update column config as well to keep the previou config.
|
||||
if (controlName === 'metrics' && old_metrics_data && new_column_config) {
|
||||
value.forEach((item, index) => {
|
||||
if (
|
||||
item.label !== old_metrics_data[index].label &&
|
||||
!!new_column_config[old_metrics_data[index].label]
|
||||
) {
|
||||
new_column_config[item.label] =
|
||||
new_column_config[old_metrics_data[index].label];
|
||||
|
||||
delete new_column_config[old_metrics_data[index].label];
|
||||
}
|
||||
});
|
||||
new_form_data.column_config = new_column_config;
|
||||
}
|
||||
|
||||
// Use the processed control config (with overrides and everything)
|
||||
// if `controlName` does not existing in current controls,
|
||||
const controlConfig =
|
||||
@ -148,9 +167,18 @@ export default function exploreReducer(state = {}, action) {
|
||||
...getControlStateFromControlConfig(controlConfig, state, action.value),
|
||||
};
|
||||
|
||||
const column_config = {
|
||||
...state.controls.column_config,
|
||||
...(new_column_config && { value: new_column_config }),
|
||||
};
|
||||
|
||||
const newState = {
|
||||
...state,
|
||||
controls: { ...state.controls, [action.controlName]: control },
|
||||
controls: {
|
||||
...state.controls,
|
||||
[controlName]: control,
|
||||
...(controlName === 'metrics' && { column_config }),
|
||||
},
|
||||
};
|
||||
|
||||
const rerenderedControls = {};
|
||||
|
Loading…
Reference in New Issue
Block a user