Skip to content

Commit

Permalink
fix: hide filter if no callback is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
dv-usama-ansari committed Nov 15, 2023
1 parent 35bab5e commit 059860c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 54 deletions.
56 changes: 28 additions & 28 deletions src/vis/EagerVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function EagerVis({
colors = null,
shapes = DEFAULT_SHAPES,
selectionCallback = () => null,
filterCallback = () => null,
filterCallback,
setExternalConfig = () => null,
closeCallback = () => null,
showCloseButton = false,
Expand Down Expand Up @@ -209,33 +209,33 @@ export function EagerVis({
externalConfig
? { consistent: null, current: externalConfig }
: columns.filter((c) => c.type === EColumnTypes.NUMERICAL).length > 1
? {
consistent: null,
current: {
type: ESupportedPlotlyVis.SCATTER,
numColumnsSelected: [],
color: null,
numColorScaleType: ENumericalColorScaleType.SEQUENTIAL,
shape: null,
dragMode: EScatterSelectSettings.RECTANGLE,
alphaSliderVal: 0.5,
} as BaseVisConfig,
}
: {
consistent: null,
current: {
type: ESupportedPlotlyVis.BAR,
multiples: null,
group: null,
direction: EBarDirection.HORIZONTAL,
display: EBarDisplayType.ABSOLUTE,
groupType: EBarGroupingType.STACK,
numColumnsSelected: [],
catColumnSelected: null,
aggregateColumn: null,
aggregateType: EAggregateTypes.COUNT,
} as BaseVisConfig,
},
? {
consistent: null,
current: {
type: ESupportedPlotlyVis.SCATTER,
numColumnsSelected: [],
color: null,
numColorScaleType: ENumericalColorScaleType.SEQUENTIAL,
shape: null,
dragMode: EScatterSelectSettings.RECTANGLE,
alphaSliderVal: 0.5,
} as BaseVisConfig,
}
: {
consistent: null,
current: {
type: ESupportedPlotlyVis.BAR,
multiples: null,
group: null,
direction: EBarDirection.HORIZONTAL,
display: EBarDisplayType.ABSOLUTE,
groupType: EBarGroupingType.STACK,
numColumnsSelected: [],
catColumnSelected: null,
aggregateColumn: null,
aggregateType: EAggregateTypes.COUNT,
} as BaseVisConfig,
},
);

const setExternalConfigRef = useSyncedRef(setExternalConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/vis/VisSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ICommonVisSideBarProps } from './interfaces';

export function VisSidebar({
columns,
filterCallback = () => null,
filterCallback,
optionsConfig,
config = null,
setConfig = null,
Expand Down
38 changes: 13 additions & 25 deletions src/vis/bar/BarVisSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,12 @@ import { GroupSelect } from './GroupSelect';
import { EBarDirection, EBarDisplayType, EBarGroupingType, IBarConfig } from './interfaces';

const defaultConfig = {
group: {
enable: true,
customComponent: null,
},
multiples: {
enable: true,
customComponent: null,
},
direction: {
enable: true,
customComponent: null,
},
filter: {
enable: true,
customComponent: null,
},
groupType: {
enable: true,
customComponent: null,
},
display: {
enable: true,
customComponent: null,
},
direction: { enable: true, customComponent: null },
display: { enable: true, customComponent: null },
filter: { enable: true, customComponent: null },
group: { enable: true, customComponent: null },
groupType: { enable: true, customComponent: null },
multiples: { enable: true, customComponent: null },
};

export function BarVisSidebar({
Expand Down Expand Up @@ -114,7 +96,13 @@ export function BarVisSidebar({
<BarDirectionButtons callback={(direction: EBarDirection) => setConfig({ ...config, direction })} currentSelected={config.direction} />
)
: null}
{mergedOptionsConfig.filter.enable ? mergedOptionsConfig.filter.customComponent || <FilterButtons callback={filterCallback} /> : null}
{mergedOptionsConfig.filter.enable ? (
mergedOptionsConfig.filter.customComponent ? (
mergedOptionsConfig.filter.customComponent
) : filterCallback ? (
<FilterButtons callback={filterCallback} />
) : null
) : null}
</>
);
}

0 comments on commit 059860c

Please sign in to comment.