mirror of
https://github.com/xodio/xod.git
synced 2026-03-20 23:56:54 +01:00
fix(xod-client, xod-core): fix errors caused by pulse type
This commit is contained in:
@@ -7,7 +7,7 @@ function BoolWidget(props) {
|
||||
'is-disabled': props.disabled,
|
||||
});
|
||||
const onChange = (event) => {
|
||||
props.onChange(event.target.value);
|
||||
props.onChange(event.target.checked);
|
||||
};
|
||||
return (
|
||||
<div className={cls}>
|
||||
@@ -16,10 +16,7 @@ function BoolWidget(props) {
|
||||
type="checkbox"
|
||||
value="1"
|
||||
checked={props.value}
|
||||
autoFocus={props.focused}
|
||||
disabled={props.disabled}
|
||||
onFocus={props.onFocus}
|
||||
onBlur={props.onBlur}
|
||||
onChange={onChange}
|
||||
/>
|
||||
<label
|
||||
|
||||
@@ -25,6 +25,7 @@ export default function composeWidget(Component, widgetProps) {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.type = widgetProps.type;
|
||||
this.commitOnChange = widgetProps.commitOnChange;
|
||||
|
||||
const val = this.parseValue(props.value);
|
||||
this.state = {
|
||||
@@ -87,13 +88,15 @@ export default function composeWidget(Component, widgetProps) {
|
||||
|
||||
updateValue(value) {
|
||||
const newValue = this.parseValue(value);
|
||||
const commitCallback = (this.commitOnChange) ? this.commit.bind(this) : noop;
|
||||
|
||||
this.setState({
|
||||
value: newValue,
|
||||
});
|
||||
}, commitCallback);
|
||||
}
|
||||
|
||||
commit() {
|
||||
if (this.state.value !== this.props.value && this.props.injected) {
|
||||
if (this.parseValue(this.state.value) !== this.parseValue(this.props.value)) {
|
||||
this.props.onPropUpdate(
|
||||
this.props.entityId,
|
||||
this.props.kind,
|
||||
|
||||
@@ -56,10 +56,10 @@ export const WIDGET_MAPPING = {
|
||||
props: { type: 'string' },
|
||||
},
|
||||
[WIDGET_TYPE.PULSE]: {
|
||||
component: PulseWidget,
|
||||
component: BoolWidget,
|
||||
props: {
|
||||
type: 'pulse',
|
||||
keyDownHandlers: widgetNumberKeysDownHandlers,
|
||||
type: 'bool',
|
||||
commitOnChange: true,
|
||||
},
|
||||
},
|
||||
[WIDGET_TYPE.IO_LABEL]: {
|
||||
|
||||
@@ -49,7 +49,7 @@ export const PROPERTY_DEFAULT_VALUE = {
|
||||
BOOL: false,
|
||||
NUMBER: 0,
|
||||
STRING: '',
|
||||
PULSE: 'once',
|
||||
PULSE: false,
|
||||
};
|
||||
|
||||
export const PROPERTY_TYPE_PARSE = {
|
||||
@@ -60,7 +60,7 @@ export const PROPERTY_TYPE_PARSE = {
|
||||
return isNaN(newValue) ? '' : newValue;
|
||||
},
|
||||
[PROPERTY_TYPE.STRING]: v => String(v),
|
||||
[PROPERTY_TYPE.PULSE]: v => (v !== null ? String(v) : PROPERTY_DEFAULT_VALUE.PULSE),
|
||||
[PROPERTY_TYPE.PULSE]: v => !!v,
|
||||
};
|
||||
|
||||
export const SIZE = {
|
||||
|
||||
Reference in New Issue
Block a user