Skip to content

Commit

Permalink
pr changes
Browse files Browse the repository at this point in the history
Signed-off-by: Abhay Pandey <[email protected]>
  • Loading branch information
abhaypersistent committed Oct 13, 2022
1 parent 0870fbe commit 6877e3e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const ConfigBarChartStyles = ({
const { data: vizData = {}, metadata: { fields = [] } = {} } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFieldName, schema) => {
(stateFieldName, max) => {
return (changes) => {
if (!schema?.props || changes <= schema?.props?.max) {
if (!max || changes <= max) {
handleConfigChange({
...vizState,
[stateFieldName]: changes,
Expand Down Expand Up @@ -74,15 +74,15 @@ export const ConfigBarChartStyles = ({
label: btn.name,
})),
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id,
handleButtonChange: handleConfigurationChange(schema.mapTo, schema),
handleButtonChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
return createDimensionComponent(params);
}
if (schema.eleType === 'input') {
params = {
title: schema.name,
numValue: vizState[schema.mapTo] || '',
handleInputChange: handleConfigurationChange(schema.mapTo, schema),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
vizState,
...schema.props,
};
Expand All @@ -97,7 +97,7 @@ export const ConfigBarChartStyles = ({
currentRange: vizState[schema.mapTo] || schema?.defaultState,
ticks: schema?.props?.ticks,
showTicks: schema?.props?.showTicks || false,
handleSliderChange: handleConfigurationChange(schema.mapTo, schema),
handleSliderChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
return createDimensionComponent(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const ConfigChartOptions = ({
const { data: vizData = {}, metadata: { fields = [] } = {}, tree_map } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFiledName, schema) => {
(stateFiledName, max) => {
return (changes) => {
if (!schema?.props?.max || changes <= schema?.props.max) {
if (!max || changes <= max) {
handleConfigChange({
...vizState,
[stateFiledName]: changes,
Expand Down Expand Up @@ -66,15 +66,15 @@ export const ConfigChartOptions = ({
...params,
colorPalettes: schema.options || [],
selectedColor: vizState[schema.mapTo] || schema.defaultState,
onSelectChange: handleConfigurationChange(schema.mapTo, schema),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

case ConfigChartOptionsEnum.singleColorPicker:
params = {
...params,
selectedColor: vizState[schema.mapTo] || schema.defaultState,
onSelectChange: handleConfigurationChange(schema.mapTo, schema),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -83,7 +83,7 @@ export const ConfigChartOptions = ({
...params,
selectedColor: vizState[schema.mapTo] || schema?.defaultState,
colorPalettes: schema.options || [],
onSelectChange: handleConfigurationChange(schema.mapTo, schema),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -95,7 +95,7 @@ export const ConfigChartOptions = ({
numberOfParents:
(tree_map?.dataConfig?.dimensions !== undefined &&
tree_map?.dataConfig.dimensions[0].parentFields.length) | 0,
onSelectChange: handleConfigurationChange(schema.mapTo, schema),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -104,7 +104,7 @@ export const ConfigChartOptions = ({
...params,
currentValue: vizState[schema.mapTo] || '',
numValue: vizState[schema.mapTo] || '',
handleInputChange: handleConfigurationChange(schema.mapTo, schema),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
minLimit: schema.props?.hasOwnProperty('minLimit')
? schema.props.minLimit
: NUMBER_INPUT_MIN_LIMIT,
Expand All @@ -116,7 +116,7 @@ export const ConfigChartOptions = ({
...params,
currentValue: vizState[schema.mapTo] || '',
name: schema.mapTo,
handleInputChange: handleConfigurationChange(schema.mapTo, schema),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -125,7 +125,7 @@ export const ConfigChartOptions = ({
...params,
maxRange: schema.props.max,
currentRange: vizState[schema.mapTo] || schema?.defaultState,
handleSliderChange: handleConfigurationChange(schema.mapTo, schema),
handleSliderChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -134,7 +134,7 @@ export const ConfigChartOptions = ({
...params,
title: schema.name,
currentValue: vizState[schema.mapTo],
onToggle: handleConfigurationChange(schema.mapTo, schema),
onToggle: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -148,7 +148,7 @@ export const ConfigChartOptions = ({
label: btn.name,
})),
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id,
handleButtonChange: handleConfigurationChange(schema.mapTo, schema),
handleButtonChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

Expand All @@ -158,7 +158,7 @@ export const ConfigChartOptions = ({
paddingTitle: schema.name,
advancedTitle: 'advancedTitle',
dropdownList: schema?.options || fields,
onSelectChange: handleConfigurationChange(schema.mapTo),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
isSingleSelection: schema.isSingleSelection,
selectedAxis: vizState[schema.mapTo] || schema.defaultState,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const ConfigLineChartStyles = ({
const { data: vizData = {}, metadata: { fields = [] } = {} } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFiledName, schema) => {
(stateFiledName, max) => {
return (changes) => {
if (!schema?.props?.max || changes <= schema?.props?.max) {
if (!max || changes <= max) {
handleConfigChange({
...vizState,
[stateFiledName]: changes,
Expand Down Expand Up @@ -88,7 +88,7 @@ export const ConfigLineChartStyles = ({
label: btn.name,
})),
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id,
handleButtonChange: handleConfigurationChange(schema.mapTo, schema),
handleButtonChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
} else if (schema.eleType === 'slider') {
params = {
Expand All @@ -99,13 +99,13 @@ export const ConfigLineChartStyles = ({
currentRange: vizState[schema.mapTo] || schema?.defaultState,
ticks: schema?.props?.ticks,
showTicks: schema?.props?.showTicks || false,
handleSliderChange: handleConfigurationChange(schema.mapTo, schema),
handleSliderChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
} else if (schema.eleType === 'input') {
params = {
...params,
numValue: vizState[schema.mapTo] || '',
handleInputChange: handleConfigurationChange(schema.mapTo, schema),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ export const SliderConfig: React.FC<Props> = ({
showInput
/>
</>
);
);

0 comments on commit 6877e3e

Please sign in to comment.