mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix: Applying Dashboard Time Range Filters to Overwritten Charts (#25156)
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
parent
8b2a408dea
commit
f2523b26fa
@ -79,19 +79,15 @@ export const getSlicePayload = (
|
|||||||
adhocFilters = extractAddHocFiltersFromFormData(formDataFromSlice);
|
adhocFilters = extractAddHocFiltersFromFormData(formDataFromSlice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
// This loop iterates through the adhoc_filters array in formDataWithNativeFilters.
|
||||||
isEmpty(adhocFilters?.adhoc_filters) &&
|
// If a filter is of type TEMPORAL_RANGE and isExtra, it sets its comparator to
|
||||||
isEmpty(formDataFromSlice) &&
|
// 'No filter' and adds the modified filter to the adhocFilters array. This ensures that all
|
||||||
formDataWithNativeFilters?.adhoc_filters?.[0]?.operator ===
|
// TEMPORAL_RANGE filters are converted to 'No filter' when saving a chart.
|
||||||
Operators.TEMPORAL_RANGE
|
formDataWithNativeFilters?.adhoc_filters?.forEach(filter => {
|
||||||
) {
|
if (filter.operator === Operators.TEMPORAL_RANGE && filter.isExtra) {
|
||||||
adhocFilters.adhoc_filters = [
|
adhocFilters.adhoc_filters.push({ ...filter, comparator: 'No filter' });
|
||||||
{
|
}
|
||||||
...formDataWithNativeFilters.adhoc_filters[0],
|
});
|
||||||
comparator: 'No filter',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const formData = {
|
const formData = {
|
||||||
...formDataWithNativeFilters,
|
...formDataWithNativeFilters,
|
||||||
|
@ -302,7 +302,19 @@ describe('getSlicePayload', () => {
|
|||||||
formDataWithNativeFilters,
|
formDataWithNativeFilters,
|
||||||
dashboards,
|
dashboards,
|
||||||
owners,
|
owners,
|
||||||
formDataFromSlice,
|
{
|
||||||
|
datasource: '22__table',
|
||||||
|
viz_type: 'pie',
|
||||||
|
adhoc_filters: [
|
||||||
|
{
|
||||||
|
clause: 'WHERE',
|
||||||
|
subject: 'year',
|
||||||
|
operator: 'TEMPORAL_RANGE',
|
||||||
|
comparator: 'No filter',
|
||||||
|
expressionType: 'SIMPLE',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
);
|
);
|
||||||
expect(result).toHaveProperty('params');
|
expect(result).toHaveProperty('params');
|
||||||
expect(result).toHaveProperty('slice_name', sliceName);
|
expect(result).toHaveProperty('slice_name', sliceName);
|
||||||
@ -366,7 +378,6 @@ describe('getSlicePayload', () => {
|
|||||||
operator: 'TEMPORAL_RANGE',
|
operator: 'TEMPORAL_RANGE',
|
||||||
comparator: 'No filter',
|
comparator: 'No filter',
|
||||||
expressionType: 'SIMPLE',
|
expressionType: 'SIMPLE',
|
||||||
isExtra: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user