diff --git a/src/__tests__/components/dialog/edit-widget-control-creator.js b/src/__tests__/components/dialog/edit-widget-control-creator.js index 1f4815c..4298ef1 100644 --- a/src/__tests__/components/dialog/edit-widget-control-creator.js +++ b/src/__tests__/components/dialog/edit-widget-control-creator.js @@ -37,7 +37,7 @@ describe('edit widget control creator', () => { { args: { widgetType: 'Box' }, result: { controlNumber: 1, controlTypes: [EditWidgetColorControl] } }, { args: { widgetType: 'Label' }, result: { controlNumber: 3, controlTypes: [EditWidgetTextControl, EditWidgetTextSizeControl, EditWidgetColorControl] } }, { args: { widgetType: 'HTML' }, result: { controlNumber: 1, controlTypes: [EditWidgetHTMLContent] } }, - { args: { widgetType: 'NumberInput'}, result: { controlNumber: 3, controlTypes: [EditWidgetTextControl, EditWidgetSimulatorControl, EditWidgetSignalControl] } } + { args: { widgetType: 'Input'}, result: { controlNumber: 3, controlTypes: [EditWidgetTextControl, EditWidgetSimulatorControl, EditWidgetSignalControl] } } ]; runs.forEach( (run) => { diff --git a/src/components/dialog/edit-widget-control-creator.js b/src/components/dialog/edit-widget-control-creator.js index 9f593ec..f73c86c 100644 --- a/src/components/dialog/edit-widget-control-creator.js +++ b/src/components/dialog/edit-widget-control-creator.js @@ -162,7 +162,7 @@ export default function createControls(widgetType = null, widget = null, session ); break; - case 'NumberInput': + case 'Input': dialogControls.push( validateForm(id)} handleChange={e => handleChange(e)} />, validateForm(id)} simulationModels={simulationModels} handleChange={(e) => valueBoundOnChange(e)} />, diff --git a/src/components/widget-factory.js b/src/components/widget-factory.js index b59c6fa..496a3be 100644 --- a/src/components/widget-factory.js +++ b/src/components/widget-factory.js @@ -108,7 +108,7 @@ class WidgetFactory { widget.simulationModel = defaultSimulationModel; widget.signal = 0; break; - case 'NumberInput': + case 'Input': widget.minWidth = 200; widget.minHeight = 50; widget.width = 200; diff --git a/src/components/widget-number-input.js b/src/components/widget-input.js similarity index 82% rename from src/components/widget-number-input.js rename to src/components/widget-input.js index 13061bb..47c21d0 100644 --- a/src/components/widget-number-input.js +++ b/src/components/widget-input.js @@ -10,8 +10,8 @@ import React, { Component } from 'react'; import { Form, FormGroup, Col, ControlLabel, FormControl } from 'react-bootstrap'; -class WidgetNumberInput extends Component { - +class WidgetInput extends Component { + static whichValidationStateIs( condition ) { switch(condition) { case 'ok': return null; @@ -25,23 +25,23 @@ class WidgetNumberInput extends Component { this.state = { value: '', - validationState: WidgetNumberInput.whichValidationStateIs('ok') + validationState: WidgetInput.whichValidationStateIs('ok') }; } validateInput(e) { if (e.target.value === '' || e.target.value.endsWith('.')) { this.setState({ - validationState: WidgetNumberInput.whichValidationStateIs('ok'), + validationState: WidgetInput.whichValidationStateIs('ok'), value: e.target.value }); } else { var num = Number(e.target.value); if (Number.isNaN(num)) { - this.setState({ validationState: WidgetNumberInput.whichValidationStateIs('error'), + this.setState({ validationState: WidgetInput.whichValidationStateIs('error'), value: e.target.value }); } else { this.setState({ - validationState: WidgetNumberInput.whichValidationStateIs('ok'), + validationState: WidgetInput.whichValidationStateIs('ok'), value: num }); } } @@ -66,4 +66,4 @@ class WidgetNumberInput extends Component { } } -export default WidgetNumberInput; \ No newline at end of file +export default WidgetInput; diff --git a/src/containers/widget.js b/src/containers/widget.js index 2879498..37c7b8e 100644 --- a/src/containers/widget.js +++ b/src/containers/widget.js @@ -39,7 +39,7 @@ import WidgetLabel from '../components/widget-label'; import WidgetPlotTable from '../components/widget-plot-table'; import WidgetImage from '../components/widget-image'; import WidgetButton from '../components/widget-button'; -import WidgetNumberInput from '../components/widget-number-input'; +import WidgetInput from '../components/widget-input'; import WidgetSlider from '../components/widget-slider'; import WidgetGauge from '../components/widget-gauge'; import WidgetBox from '../components/widget-box'; @@ -218,8 +218,8 @@ class Widget extends React.Component { element = } else if (widget.type === 'Button') { element = - } else if (widget.type === 'NumberInput') { - element = + } else if (widget.type === 'Input') { + element = } else if (widget.type === 'Slider') { element = this.props.onWidgetStatusChange(w, this.props.index) } onInputChanged={(value) => this.inputDataChanged(widget, value)} /> } else if (widget.type === 'Gauge') {