feat: Update ElementEditor and DashboardEditor to enhance data handling and UI responsiveness

This commit is contained in:
2025-12-17 17:39:50 +05:30
parent d014b3f87e
commit debabea79b
3 changed files with 136 additions and 85 deletions

View File

@@ -301,7 +301,7 @@ export const createSimulationDashboardStore = () => {
...baseGraphProps,
dataType: "multiple-machine" as const,
title: "Multi Machine Chart",
dataSource: ["", "", ""],
dataSource: [],
commonValue: "",
};
} else {
@@ -310,7 +310,7 @@ export const createSimulationDashboardStore = () => {
dataType: "single-machine" as const,
title: "Single Machine Chart",
dataSource: "",
dataValue: ["", "", ""],
dataValue: [],
};
}
break;
@@ -668,7 +668,7 @@ export const createSimulationDashboardStore = () => {
...baseGraphProps,
dataType: "multiple-machine" as const,
title: "Multi Machine Chart",
dataSource: ["", "", ""],
dataSource: [],
commonValue: "",
};
} else {
@@ -677,7 +677,7 @@ export const createSimulationDashboardStore = () => {
dataType: "single-machine" as const,
title: "Single Machine Chart",
dataSource: "",
dataValue: ["", "", ""],
dataValue: [],
};
}
break;
@@ -853,13 +853,39 @@ export const createSimulationDashboardStore = () => {
peekUpdateDataType: (blockId, elementId, dataType) => {
const blocks = cloneBlocks(get().blocks);
const block = blocks.find((b) => b.blockUuid === blockId);
if (block) {
const element = block.elements.find((el) => el.elementUuid === elementId);
if (element && element.type === "graph") {
element.dataType = dataType;
}
if (!block) return blocks;
const index = block.elements.findIndex((el) => el.elementUuid === elementId);
if (index === -1) return blocks;
const element = block.elements[index];
if (element.type !== "graph" || element.dataType === dataType) return blocks;
let newElement: UIElement;
if (dataType === "single-machine") {
const { commonValue, ...rest } = element as Extract<UIElement, { type: "graph"; dataType: "multiple-machine" }>;
newElement = {
...rest,
dataType: "single-machine",
dataSource: "",
dataValue: [],
};
} else {
const { dataValue, ...rest } = element as Extract<UIElement, { type: "graph"; dataType: "single-machine" }>;
newElement = {
...rest,
dataType: "multiple-machine",
dataSource: [],
commonValue: "",
};
}
block.elements[index] = newElement;
return blocks;
},