From d64ff881dea872e46f7fa7f2616c801524adad2f Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Wed, 17 Dec 2025 13:40:11 +0530 Subject: [PATCH] feat: Update ElementEditor to handle data value changes and refactor data source initialization in simulation store --- .../components/element/ElementEditor.tsx | 4 ++- app/src/modules/builder/builder.tsx | 12 ++------ .../simulation/useSimulationDashBoardStore.ts | 29 +++++++++++-------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx index 517b614..edac1c1 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx @@ -566,7 +566,9 @@ const ElementEditor: React.FC = ({ placeholder="Select Value" sections={getLableValueDropdownItems(element.dataSource as string | undefined)} value={element.dataValue ? { id: element.dataValue, label: element.dataValue, icon: } : null} - onChange={() => {}} + onChange={(value) => { + updateDataValue(selectedBlock, selectedElement, value.id); + }} dropDownHeader={"RT-Data-Value"} /> diff --git a/app/src/modules/builder/builder.tsx b/app/src/modules/builder/builder.tsx index bee7269..29634f0 100644 --- a/app/src/modules/builder/builder.tsx +++ b/app/src/modules/builder/builder.tsx @@ -11,15 +11,7 @@ import { useFrame, useThree } from "@react-three/fiber"; import { useSceneContext } from "../scene/sceneContext"; import { useBuilderStore } from "../../store/builder/useBuilderStore"; -import { - useToggleView, - useWallVisibility, - useRoofVisibility, - useShadows, - useToolMode, - useRenderDistance, - useLimitDistance, -} from "../../store/builder/store"; +import { useToggleView, useWallVisibility, useRoofVisibility, useShadows, useToolMode, useRenderDistance, useLimitDistance } from "../../store/builder/store"; ////////// 3D Function Imports ////////// @@ -98,7 +90,7 @@ export default function Builder() { - + diff --git a/app/src/store/simulation/useSimulationDashBoardStore.ts b/app/src/store/simulation/useSimulationDashBoardStore.ts index f3e5d96..3aabba8 100644 --- a/app/src/store/simulation/useSimulationDashBoardStore.ts +++ b/app/src/store/simulation/useSimulationDashBoardStore.ts @@ -19,7 +19,7 @@ interface SimulationDashboardStore { setSelectedElement: (elementId: string | null) => void; // Block operations - addBlock: (newBlock : Block) => void; + addBlock: (newBlock: Block) => void; removeBlock: (blockId: string) => void; updateBlock: (blockId: string, updates: Partial) => void; clearBlocks: () => void; @@ -252,8 +252,8 @@ export const createSimulationDashboardStore = () => { ...commonProps, type: "label-value", title: "Label Value", - dataSource: "machine-1", - dataValue: "metric-1", + dataSource: "", + dataValue: "", style: { color: "#ffffff", fontSize: 14, @@ -301,16 +301,16 @@ export const createSimulationDashboardStore = () => { ...baseGraphProps, dataType: "multiple-machine" as const, title: "Multi Machine Chart", - dataSource: ["machine-1", "machine-2", "machine-3"], - commonValue: "metric-1", + dataSource: ["", "", ""], + commonValue: "", }; } else { newElement = { ...baseGraphProps, dataType: "single-machine" as const, title: "Single Machine Chart", - dataSource: "machine-1", - dataValue: ["metric-1", "metric-2", "metric-3"], + dataSource: "", + dataValue: ["", "", ""], }; } break; @@ -619,7 +619,7 @@ export const createSimulationDashboardStore = () => { ...commonProps, type: "label-value", title: "Label Value", - dataSource: "machine-1", + dataSource: "", dataValue: "metric-1", style: { color: "#ffffff", @@ -668,16 +668,16 @@ export const createSimulationDashboardStore = () => { ...baseGraphProps, dataType: "multiple-machine" as const, title: "Multi Machine Chart", - dataSource: ["machine-1", "machine-2", "machine-3"], - commonValue: "metric-1", + dataSource: ["", "", ""], + commonValue: "", }; } else { newElement = { ...baseGraphProps, dataType: "single-machine" as const, title: "Single Machine Chart", - dataSource: "machine-1", - dataValue: ["metric-1", "metric-2", "metric-3"], + dataSource: "", + dataValue: ["", "", ""], }; } break; @@ -882,6 +882,8 @@ export const createSimulationDashboardStore = () => { const element = block.elements.find((el) => el.elementUuid === elementId); if (element && element.type === "graph" && element.dataType === "single-machine") { element.dataValue = dataValue as string[]; + } else if (element && element.type === "label-value") { + element.dataValue = dataValue as string; } } return blocks; @@ -892,6 +894,9 @@ export const createSimulationDashboardStore = () => { const block = blocks.find((b) => b.blockUuid === blockId); if (block) { const element = block.elements.find((el) => el.elementUuid === elementId); + if (element?.type === "label-value") { + element.dataValue = ""; + } if (element) { element.dataSource = dataSource; }