mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
feat(deck-gl): Enable individual deck.gl layer selection in FilterScope tree (#33769)
Co-authored-by: richardfn <richard.fogaca@appsilon.com> Co-authored-by: amaannawab923 <amaannawab923@gmail.com>
This commit is contained in:
committed by
GitHub
parent
11215b092a
commit
85034b9748
@@ -29,10 +29,50 @@ import {
|
||||
import { OPERATOR_ENUM_TO_OPERATOR_TYPE } from '../explore/constants';
|
||||
import { translateToSql } from '../explore/components/controls/FilterControl/utils/translateToSQL';
|
||||
|
||||
const findMatchingFilterKey = (
|
||||
filterClause: QueryObjectFilterClause & {
|
||||
filterDataMapping?: Record<string, any[]>;
|
||||
layerFilterScope?: Record<string, any>;
|
||||
},
|
||||
): string | null => {
|
||||
if (!filterClause.filterDataMapping) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { col, op } = filterClause;
|
||||
const val = 'val' in filterClause ? filterClause.val : undefined;
|
||||
|
||||
for (const [key, filters] of Object.entries(filterClause.filterDataMapping)) {
|
||||
if (Array.isArray(filters)) {
|
||||
const matchingFilter = filters.find(
|
||||
filter =>
|
||||
filter.col === col &&
|
||||
filter.op === op &&
|
||||
JSON.stringify(filter.val) === JSON.stringify(val),
|
||||
);
|
||||
|
||||
if (matchingFilter) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const simpleFilterToAdhoc = (
|
||||
filterClause: QueryObjectFilterClause,
|
||||
filterClause: QueryObjectFilterClause & {
|
||||
filterDataMapping?: Record<string, any[]>;
|
||||
layerFilterScope?: Record<string, any>;
|
||||
},
|
||||
clause: Clauses = Clauses.Where,
|
||||
) => {
|
||||
// Find matching filter key
|
||||
const matchingFilterKey = findMatchingFilterKey(filterClause);
|
||||
const filterScope = matchingFilterKey
|
||||
? filterClause.layerFilterScope?.[matchingFilterKey]
|
||||
: undefined;
|
||||
|
||||
let result: AdhocFilter;
|
||||
if (isAdhocColumn(filterClause.col)) {
|
||||
result = {
|
||||
@@ -60,6 +100,7 @@ export const simpleFilterToAdhoc = (
|
||||
if (filterClause.isExtra) {
|
||||
Object.assign(result, {
|
||||
isExtra: true,
|
||||
layerFilterScope: filterScope,
|
||||
filterOptionName: `filter_${Math.random()
|
||||
.toString(36)
|
||||
.substring(2, 15)}_${Math.random().toString(36).substring(2, 15)}`,
|
||||
|
||||
Reference in New Issue
Block a user