summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2025-04-29 11:41:07 +0530
committerSunil Shetye2025-04-29 11:41:07 +0530
commitef2191bd4b8b5806e20a39203849b1a7397c4dc2 (patch)
treec6c4c1b5236e051d7b90d3c40015f3d58c87998f
parent6951d1896a995189b3f477768920e011fee9403c (diff)
downloadCommon-Interface-Project-ef2191bd4b8b5806e20a39203849b1a7397c4dc2.tar.gz
Common-Interface-Project-ef2191bd4b8b5806e20a39203849b1a7397c4dc2.tar.bz2
Common-Interface-Project-ef2191bd4b8b5806e20a39203849b1a7397c4dc2.zip
getCompProperties.fulfilled should set only state.compProperties
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js150
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js1
-rw-r--r--blocks/eda-frontend/src/redux/componentPropertiesSlice.js13
3 files changed, 84 insertions, 80 deletions
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js b/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js
index d598f51f..5c3c4839 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js
@@ -21,62 +21,62 @@ function getXY (portOrientation, offsetPorts, newTotalPorts, i, block) {
let ports
let pins
switch (portOrientation) {
- case 'ExplicitInputPort':
- xPos = 0
- yPos = 1 - (2 * i + 1) / (2 * newTotalPorts)
- pointX = -portSize
- pointY = -portSize / 2
- ports = 'explicitInputPorts'
- pins = block.pins.explicitInputPorts
- break
- case 'ImplicitInputPort':
- xPos = 0
- yPos = 1 - (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts)
- pointX = -portSize
- pointY = -portSize / 2
- ports = 'implicitInputPorts'
- pins = block.pins.implicitInputPorts
- break
- case 'ControlPort':
- xPos = (2 * i + 1) / (2 * newTotalPorts)
- yPos = 0
- pointX = -portSize / 2
- pointY = -portSize
- ports = 'controlPorts'
- pins = block.pins.controlPorts
- break
- case 'ExplicitOutputPort':
- xPos = 1
- yPos = 1 - (2 * i + 1) / (2 * newTotalPorts)
- pointX = 0
- pointY = -portSize / 2
- ports = 'explicitOutputPorts'
- pins = block.pins.explicitOutputPorts
- break
- case 'ImplicitOutputPort':
- xPos = 1
- yPos = 1 - (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts)
- pointX = 0
- pointY = -portSize / 2
- ports = 'implicitOutputPorts'
- pins = block.pins.implicitOutputPorts
- break
- case 'CommandPort':
- xPos = (2 * i + 1) / (2 * newTotalPorts)
- yPos = 1
- pointX = -portSize / 2
- pointY = 0
- ports = 'commandPorts'
- pins = block.pins.commandPorts
- break
- default:
- xPos = 0
- yPos = 0
- pointX = -portSize / 2
- pointY = -portSize / 2
- ports = null
- pins = null
- break
+ case 'ExplicitInputPort':
+ xPos = 0
+ yPos = 1 - (2 * i + 1) / (2 * newTotalPorts)
+ pointX = -portSize
+ pointY = -portSize / 2
+ ports = 'explicitInputPorts'
+ pins = block.pins.explicitInputPorts
+ break
+ case 'ImplicitInputPort':
+ xPos = 0
+ yPos = 1 - (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts)
+ pointX = -portSize
+ pointY = -portSize / 2
+ ports = 'implicitInputPorts'
+ pins = block.pins.implicitInputPorts
+ break
+ case 'ControlPort':
+ xPos = (2 * i + 1) / (2 * newTotalPorts)
+ yPos = 0
+ pointX = -portSize / 2
+ pointY = -portSize
+ ports = 'controlPorts'
+ pins = block.pins.controlPorts
+ break
+ case 'ExplicitOutputPort':
+ xPos = 1
+ yPos = 1 - (2 * i + 1) / (2 * newTotalPorts)
+ pointX = 0
+ pointY = -portSize / 2
+ ports = 'explicitOutputPorts'
+ pins = block.pins.explicitOutputPorts
+ break
+ case 'ImplicitOutputPort':
+ xPos = 1
+ yPos = 1 - (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts)
+ pointX = 0
+ pointY = -portSize / 2
+ ports = 'implicitOutputPorts'
+ pins = block.pins.implicitOutputPorts
+ break
+ case 'CommandPort':
+ xPos = (2 * i + 1) / (2 * newTotalPorts)
+ yPos = 1
+ pointX = -portSize / 2
+ pointY = 0
+ ports = 'commandPorts'
+ pins = block.pins.commandPorts
+ break
+ default:
+ xPos = 0
+ yPos = 0
+ pointX = -portSize / 2
+ pointY = -portSize / 2
+ ports = null
+ pins = null
+ break
}
return { xPos, yPos, pointX, pointY, ports, pins }
}
@@ -230,22 +230,22 @@ export default function ComponentProperties () {
const fieldType = compProperties && compProperties[typeId]
let isValid = true
switch (fieldType) {
- case 1: // boolean
- // For boolean type, consider 0 as false and 1 as true
- isValid = value === '0' || value === '1'
- break
- case 2: // integer
- // For integer type, check if the input is a valid number
- isValid = !isNaN(value) && Number.isInteger(Number(value))
- break
- case 3: // double
- // For double type, check if the input is a valid number
- isValid = !isNaN(value) && !Number.isNaN(parseFloat(value))
- break
+ case 1: // boolean
+ // For boolean type, consider 0 as false and 1 as true
+ isValid = value === '0' || value === '1'
+ break
+ case 2: // integer
+ // For integer type, check if the input is a valid number
+ isValid = !isNaN(value) && Number.isInteger(Number(value))
+ break
+ case 3: // double
+ // For double type, check if the input is a valid number
+ isValid = !isNaN(value) && !Number.isNaN(parseFloat(value))
+ break
// Add more cases for other types as needed
- default:
- // For other types, no specific validation
- isValid = true
+ default:
+ // For other types, no specific validation
+ isValid = true
}
// Update error state for the field
setErrorFields({
@@ -278,7 +278,13 @@ export default function ComponentProperties () {
/>
<ListItem>
- {compProperties && compProperties.length > 0 ? <ListItemText primary={link1} /> : isLoading ? <ListItemText primary={link4} /> : <ListItemText primary={link3} />}
+ {
+ compProperties && compProperties.length > 0
+ ? <ListItemText primary={link1} />
+ : isLoading
+ ? <ListItemText primary={link4} />
+ : <ListItemText primary={link3} />
+ }
</ListItem>
{
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js b/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
index 57933eef..31222b10 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
@@ -484,7 +484,6 @@ export function ScriptScreen ({ isOpen, onClose }) {
variant='outlined'
fullWidth
InputProps={{
- disableUnderline: true,
style: {
fontFamily: '"Roboto Mono", monospace',
fontSize: '14px'
diff --git a/blocks/eda-frontend/src/redux/componentPropertiesSlice.js b/blocks/eda-frontend/src/redux/componentPropertiesSlice.js
index 3f74674f..4c0781d7 100644
--- a/blocks/eda-frontend/src/redux/componentPropertiesSlice.js
+++ b/blocks/eda-frontend/src/redux/componentPropertiesSlice.js
@@ -74,19 +74,18 @@ const componentPropertiesSlice = createSlice({
.addCase(getCompProperties.pending, (state, action) => {
state.isLoading = true
state.isPropertiesWindowOpen = true
- state.compProperties = undefined
+ state.compProperties = []
const block = action.meta.arg
+ state.block = block
state.name = styleToObject(block.style).default
+ state.parameter_values = block.parameter_values
+ state.errorFields = block.errorFields
+ state.displayProperties = block.displayProperties
})
.addCase(getCompProperties.fulfilled, (state, action) => {
state.isLoading = false
state.isPropertiesWindowOpen = true
- state.name = action.payload.name
- state.block = action.payload.block
- state.parameter_values = action.payload.parameter_values
- state.errorFields = action.payload.errorFields
- state.displayProperties = action.payload.displayProperties
- state.compProperties = action.payload.compProperties
+ state.compProperties = action.payload
})
.addCase(getCompProperties.rejected, (state) => {
state.isLoading = false