Skip to content

Commit

Permalink
#1674 : rename to minValue and maxvalue and code changes related to S…
Browse files Browse the repository at this point in the history
…lider component

Signed-off-by: srikant <[email protected]>
  • Loading branch information
srikant-ch5 committed Jan 29, 2024
1 parent bfb5c72 commit fe9a27e
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ class SliderControl extends React.Component {
this.handleChange = this.handleChange.bind(this);
this.uuid = uuid4();
this.id = ControlUtils.getControlId(props.propertyId, this.uuid);
this.state = {
value: props.value,
min: props.control.min_value,
max: props.control.max_value,
step: props.control.increment
};
}

handleChange(e) {
Expand All @@ -47,30 +41,32 @@ class SliderControl extends React.Component {
render() {
const minLabel = this.props.controller.getResource(`${this.props.control.name}.min.label`, null);
const maxLabel = this.props.controller.getResource(`${this.props.control.name}.max.label`, null);
const minValue = this.props.control.minValue || 0;
const maxValue = this.props.control.maxValue || 10;
const step = this.props.control.increment || 1;

return (
<div className={classNames("properties-slider ", { "hide": this.props.state === STATES.HIDDEN })}
data-id={ControlUtils.getDataId(this.props.propertyId)}
>
<div className={classNames("properties-slider ", { "hide": this.props.state === STATES.HIDDEN })}>
<Slider
id={this.id}
value={this.state.value}
min={this.state.min}
max={this.state.max}
step={this.state.step}
value={this.props.value}
min={minValue}
max={maxValue}
step={step}
labelText={this.props.controlItem}
onChange={this.handleChange}
disabled={this.props.state === STATES.DISABLED}
formatLabel={
(val, label) => {
if (val === this.state.min && minLabel) {
(val) => {
if (val === minValue && minLabel) {
return minLabel;
} else if (val === this.state.min && !minLabel) {
return this.state.min;
} else if (val === minValue && !minLabel) {
return minValue;
}
if (val === this.state.max && maxLabel) {
if (val === maxValue && maxLabel) {
return maxLabel;
} else if (val === this.state.max && !maxLabel) {
return this.state.max;
} else if (val === maxValue && !maxLabel) {
return maxValue;
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export class Control {
if (settings.increment) {
this.increment = settings.increment;
}
if (settings.min_value) {
this.min_value = settings.min_value;
if (settings.minValue) {
this.minValue = settings.minValue;
}
if (settings.max_value) {
this.max_value = settings.max_value;
if (settings.maxValue) {
this.maxValue = settings.maxValue;
}
if (settings.generatedValues) {
this.generatedValues = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ function _makeControl(parameterMetadata, paramName, group, structureDefinition,
settings.enableMaximize = parameter.enableMaximize;
settings.summary = parameter.summary;
settings.increment = parameter.increment;
settings.min_value = parameter.min_value;
settings.max_value = parameter.max_value;
settings.minValue = parameter.minValue;
settings.maxValue = parameter.maxValue;
settings.rowSelection = rowSelection;
settings.generatedValues = parameter.generatedValues;
settings.addRemoveRows = addRemoveRows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export class ParameterDef {
if (settings.charLimit) {
this.charLimit = settings.charLimit;
}
if (settings.min_value) {
this.min_value = settings.min_value;
if (settings.minValue) {
this.minValue = settings.minValue;
}
if (settings.max_value) {
this.max_value = settings.max_value;
if (settings.maxValue) {
this.maxValue = settings.maxValue;
}
if (settings.placeHolderText) {
this.placeHolderText = ResourceDef.make(settings.placeHolderText);
Expand Down Expand Up @@ -336,8 +336,8 @@ export class ParameterDef {
"orientation": propertyOf(uihint)("orientation"),
"width": propertyOf(uihint)("width"),
"charLimit": propertyOf(uihint)("char_limit"),
"min_value": propertyOf(uihint)("min_value"),
"max_value": propertyOf(uihint)("max_value"),
"minValue": propertyOf(uihint)("min_value"),
"maxValue": propertyOf(uihint)("max_value"),
"placeHolderText": propertyOf(uihint)("place_holder_text"),
"separator": propertyOf(uihint)("separator"),
"resource_key": propertyOf(uihint)("resource_key"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
},
"current_parameters": {
"slider": 50,
"slider_double": 0.5,
"slider_error": 50,
"hide": true,
"slider-disable": false
Expand All @@ -12,24 +13,26 @@
{
"id": "slider-disable",
"type": "boolean"
},
},
{
"id": "slider",
"type": "integer"
},
{
"id": "slider_double",
"type": "double"
},
{
"id": "slider_error",
"type": "object",
"type": "integer",
"required": true,
"default": 20
}
],
"complex_types": [
{
"id": "sliders",
"parameters": [

]
"parameters": []
}
],
"uihints": {
Expand All @@ -39,43 +42,57 @@
"default": "Slider Values"
},
"parameter_info": [
{
"parameter_ref": "slider-disable",
"label": {
"default": "Disable 'Slider'"
}
{
"parameter_ref": "slider-disable",
"label": {
"default": "Disable 'Slider'"
}
},
{
"parameter_ref": "slider",
"label": {
"default": "Slider Testing"
},
{
"parameter_ref": "slider",
"label": {
"default": "Slider Testing"
},
"description": {
"default": "Slider Testing"
},
"control": "slider",
"min_value": 10,
"max_value": 100,
"increment": 10,
"test": "test",
"class_name": "slider-control-class"
"description": {
"default": "Slider Testing"
},
{
"parameter_ref": "slider_error",
"label": {
"default": "Error"
},
"control": "slider",
"min_value": 10,
"max_value": 100,
"increment": 10,
"description": {
"default": "Slider error with range more than Max'"
}
"control": "slider",
"min_value": 10,
"max_value": 100,
"increment": 10,
"test": "test",
"class_name": "slider-control-class"
},
{
"parameter_ref": "slider_double",
"label": {
"default": "Slider Double Testing"
},
"description": {
"default": "Slider Double Testing"
},
"control": "slider",
"min_value": 0.1,
"max_value": 1,
"increment": 0.1,
"test": "test",
"class_name": "slider-control-class"
},
{
"parameter_ref": "slider_error",
"label": {
"default": "Error"
},
"control": "slider",
"min_value": 10,
"max_value": 100,
"increment": 10,
"description": {
"default": "Slider error with range more than Max'"
}
}
],
"complex_type_info": [
],
"complex_type_info": [],
"group_info": [
{
"id": "slider-values",
Expand All @@ -84,7 +101,8 @@
},
"type": "controls",
"parameter_refs": [
"slider"
"slider",
"slider_double"
]
},
{
Expand Down Expand Up @@ -163,7 +181,7 @@
}
],
"resources": {
"slider.min.label": "Min",
"slider.max.label": "Max"
}
}
"slider.min.label": "Min",
"slider.max.label": "Max"
}
}

0 comments on commit fe9a27e

Please sign in to comment.