feat: Update ElementEditor to handle data value changes and refactor data source initialization in simulation store
This commit is contained in:
@@ -566,7 +566,9 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
||||
placeholder="Select Value"
|
||||
sections={getLableValueDropdownItems(element.dataSource as string | undefined)}
|
||||
value={element.dataValue ? { id: element.dataValue, label: element.dataValue, icon: <ParametersIcon /> } : null}
|
||||
onChange={() => {}}
|
||||
onChange={(value) => {
|
||||
updateDataValue(selectedBlock, selectedElement, value.id);
|
||||
}}
|
||||
dropDownHeader={"RT-Data-Value"}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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() {
|
||||
<AssetsGroup plane={plane} />
|
||||
|
||||
<mesh name="Walls-And-WallAssets-Group">
|
||||
<Geometry ref={csgRef} useGroups>
|
||||
<Geometry ref={csgRef} useGroups computeVertexNormals>
|
||||
<WallGroup />
|
||||
|
||||
<WallAssetGroup />
|
||||
|
||||
@@ -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<Block>) => 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user