Fix wired check boxes

This commit is contained in:
Bill 2022-03-24 13:15:21 -04:00
parent 93a63e05ed
commit 0b8746fe9f
2 changed files with 14 additions and 12 deletions

View File

@ -7,9 +7,9 @@ import { WiredActionBaseView } from './WiredActionBaseView';
export const WiredActionSetFurniStateToView: FC<{}> = props => export const WiredActionSetFurniStateToView: FC<{}> = props =>
{ {
const [ stateFlag, setStateFlag ] = useState(-1); const [ stateFlag, setStateFlag ] = useState(0);
const [ directionFlag, setDirectionFlag ] = useState(-1); const [ directionFlag, setDirectionFlag ] = useState(0);
const [ positionFlag, setPositionFlag ] = useState(-1); const [ positionFlag, setPositionFlag ] = useState(0);
const { trigger = null, setIntParams = null } = useWiredContext(); const { trigger = null, setIntParams = null } = useWiredContext();
const save = () => setIntParams([ stateFlag, directionFlag, positionFlag ]); const save = () => setIntParams([ stateFlag, directionFlag, positionFlag ]);
@ -29,15 +29,15 @@ export const WiredActionSetFurniStateToView: FC<{}> = props =>
<Column gap={ 1 }> <Column gap={ 1 }>
<Text bold>{ LocalizeText('wiredfurni.params.conditions') }</Text> <Text bold>{ LocalizeText('wiredfurni.params.conditions') }</Text>
<Flex alignItems="center" gap={ 1 }> <Flex alignItems="center" gap={ 1 }>
<input className="form-check-input" type="checkbox" id="stateFlag" onChange={ event => setStateFlag(event.target.checked ? 1 : 0) } /> <input className="form-check-input" type="checkbox" id="stateFlag" checked={ !!stateFlag } onChange={ event => setStateFlag(event.target.checked ? 1 : 0) } />
<Text>{ LocalizeText('wiredfurni.params.condition.state') }</Text> <Text>{ LocalizeText('wiredfurni.params.condition.state') }</Text>
</Flex> </Flex>
<Flex alignItems="center" gap={ 1 }> <Flex alignItems="center" gap={ 1 }>
<input className="form-check-input" type="checkbox" id="directionFlag" onChange={ event => setDirectionFlag(event.target.checked ? 1 : 0) } /> <input className="form-check-input" type="checkbox" id="directionFlag" checked={ !!directionFlag } onChange={ event => setDirectionFlag(event.target.checked ? 1 : 0) } />
<Text>{ LocalizeText('wiredfurni.params.condition.direction') }</Text> <Text>{ LocalizeText('wiredfurni.params.condition.direction') }</Text>
</Flex> </Flex>
<Flex alignItems="center" gap={ 1 }> <Flex alignItems="center" gap={ 1 }>
<input className="form-check-input" type="checkbox" id="positionFlag" onChange={ event => setPositionFlag(event.target.checked ? 1 : 0) } /> <input className="form-check-input" type="checkbox" id="positionFlag" checked={ !!positionFlag } onChange={ event => setPositionFlag(event.target.checked ? 1 : 0) } />
<Text>{ LocalizeText('wiredfurni.params.condition.position') }</Text> <Text>{ LocalizeText('wiredfurni.params.condition.position') }</Text>
</Flex> </Flex>
</Column> </Column>

View File

@ -7,9 +7,9 @@ import { WiredConditionBaseView } from './WiredConditionBaseView';
export const WiredConditionFurniMatchesSnapshotView: FC<{}> = props => export const WiredConditionFurniMatchesSnapshotView: FC<{}> = props =>
{ {
const [ stateFlag, setStateFlag ] = useState(-1); const [ stateFlag, setStateFlag ] = useState(0);
const [ directionFlag, setDirectionFlag ] = useState(-1); const [ directionFlag, setDirectionFlag ] = useState(0);
const [ positionFlag, setPositionFlag ] = useState(-1); const [ positionFlag, setPositionFlag ] = useState(0);
const { trigger = null, setIntParams = null } = useWiredContext(); const { trigger = null, setIntParams = null } = useWiredContext();
const save = () => setIntParams([ stateFlag, directionFlag, positionFlag ]); const save = () => setIntParams([ stateFlag, directionFlag, positionFlag ]);
@ -24,20 +24,22 @@ export const WiredConditionFurniMatchesSnapshotView: FC<{}> = props =>
}); });
}, [ trigger ]); }, [ trigger ]);
console.log(stateFlag, directionFlag, positionFlag);
return ( return (
<WiredConditionBaseView requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } hasSpecialInput={ true } save={ save }> <WiredConditionBaseView requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } hasSpecialInput={ true } save={ save }>
<Column gap={ 1 }> <Column gap={ 1 }>
<Text bold>{ LocalizeText('wiredfurni.params.conditions') }</Text> <Text bold>{ LocalizeText('wiredfurni.params.conditions') }</Text>
<Flex alignItems="center" gap={ 1 }> <Flex alignItems="center" gap={ 1 }>
<input className="form-check-input" type="checkbox" id="stateFlag" onChange={ event => setStateFlag(event.target.checked ? 1 : 0) } /> <input className="form-check-input" type="checkbox" id="stateFlag" checked={ !!stateFlag } onChange={ event => setStateFlag(event.target.checked ? 1 : 0) } />
<Text>{ LocalizeText('wiredfurni.params.condition.state') }</Text> <Text>{ LocalizeText('wiredfurni.params.condition.state') }</Text>
</Flex> </Flex>
<Flex alignItems="center" gap={ 1 }> <Flex alignItems="center" gap={ 1 }>
<input className="form-check-input" type="checkbox" id="directionFlag" onChange={ event => setDirectionFlag(event.target.checked ? 1 : 0) } /> <input className="form-check-input" type="checkbox" id="directionFlag" checked={ !!directionFlag } onChange={ event => setDirectionFlag(event.target.checked ? 1 : 0) } />
<Text>{ LocalizeText('wiredfurni.params.condition.direction') }</Text> <Text>{ LocalizeText('wiredfurni.params.condition.direction') }</Text>
</Flex> </Flex>
<Flex alignItems="center" gap={ 1 }> <Flex alignItems="center" gap={ 1 }>
<input className="form-check-input" type="checkbox" id="positionFlag" onChange={ event => setPositionFlag(event.target.checked ? 1 : 0) } /> <input className="form-check-input" type="checkbox" id="positionFlag" checked={ !!positionFlag } onChange={ event => setPositionFlag(event.target.checked ? 1 : 0) } />
<Text>{ LocalizeText('wiredfurni.params.condition.position') }</Text> <Text>{ LocalizeText('wiredfurni.params.condition.position') }</Text>
</Flex> </Flex>
</Column> </Column>