Skip to content

Commit

Permalink
Fixed FE-2739
Browse files Browse the repository at this point in the history
  • Loading branch information
VicenteQueiroz authored and Paulo Andre Azevedo Quirino committed Aug 20, 2024
1 parent 66dd32d commit 0fbc9d2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v1.2.5

- [FP-2879](https://movai.atlassian.net/browse/FP-2879): Closing last tab keeps bookmarks
- [FP-2739](https://movai.atlassian.net/browse/FP-2739): Port properties of the node templates are turning to strings after editing them
- [FP-2882](https://movai.atlassian.net/browse/FP-2882): Clicking in the bar under the documents loses context, not easy to get back

# v1.2.4
Expand Down
11 changes: 10 additions & 1 deletion src/editors/Node/view/Node.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,16 @@ export const Node = (props, ref) => {
);

const updateIOPortInputs = useCallback(
(value, ioConfigName, direction, ioPortKey, paramName) => {
(target, ioConfigName, direction, ioPortKey, paramName) => {
// Can be either a checkbox event or a text/number change event
let value = target.type === "checkbox" ? target.checked : target.value;

// Make sure if the input is a number, we save a number to Redis
// TO improve: backend can do this type validation
if (target.type === "number") {
value = parseFloat(value);
}

instance.current.setPortParameter(
ioConfigName,
direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback } from "react";
import Grid from "@material-ui/core/Grid";
import Circle from "@material-ui/icons/FiberManualRecord";
import TextField from "@material-ui/core/TextField";
import Checkbox from "@material-ui/core/Checkbox";

import { parametersStyles } from "./styles";

Expand All @@ -22,7 +23,7 @@ const Parameters = props => {
const handleOnChange = useCallback(
evt => {
handleIOPortsInputs(
evt.target.value,
evt.target,
rowDataName,
direction,
ioPort,
Expand All @@ -32,20 +33,39 @@ const Parameters = props => {
[rowDataName, direction, ioPort, param, handleIOPortsInputs]
);

// This is a temporary patch, actually Ports data should provide which type the frontend should render
// and not this harcoded string. And the backend should have a type validation as well
const inputType = () => {
if (["latch", "Oneshot"].includes(param)) {
return <Checkbox
type={"checkbox"}
defaultChecked={paramValue}
// className={classes.input}
onChange={handleOnChange}
/>;
}
else {
// To improve: MUI has an experimental <NumberInput>
return <TextField
type={["Frequency", "queue_size"].includes(param) ? "number" : "text"}
inputProps={{ "data-testid": "input_parameter" }}
disabled={!editable}
defaultValue={paramValue}
className={classes.input}
onChange={handleOnChange}
/>;
}

}

return (
<Grid className={classes.gridContainer}>
<Grid item xs={3} className={classes.titleColumn}>
<Circle className={classes.circle} />
{`${param}:`}
</Grid>
<Grid item xs={9}>
<TextField
inputProps={{ "data-testid": "input_parameter" }}
disabled={!editable}
defaultValue={paramValue}
className={classes.input}
onChange={handleOnChange}
/>
{inputType()}
</Grid>
</Grid>
);
Expand Down

0 comments on commit 0fbc9d2

Please sign in to comment.