added multiple actions for storage unit , and simulation bug fix
This commit is contained in:
@@ -125,26 +125,6 @@ function ConveyorMechanics() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleRenameAction = (newName: string) => {
|
||||
if (!selectedPointData) return;
|
||||
|
||||
setActionName(newName);
|
||||
const event = updateAction(
|
||||
selectedProduct.productUuid,
|
||||
selectedPointData.action.actionUuid,
|
||||
{ actionName: newName }
|
||||
);
|
||||
|
||||
if (event) {
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSpawnCountChange = (value: string) => {
|
||||
if (!selectedPointData) return;
|
||||
|
||||
|
||||
@@ -62,36 +62,6 @@ function CraneMechanics() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleRenameAction = (newName: string) => {
|
||||
if (!selectedAction.actionId || !selectedPointData) return;
|
||||
|
||||
const event = updateAction(
|
||||
selectedProduct.productUuid,
|
||||
selectedAction.actionId,
|
||||
{ actionName: newName }
|
||||
);
|
||||
|
||||
const updatedActions = selectedPointData.actions.map(action =>
|
||||
action.actionUuid === selectedAction.actionId
|
||||
? { ...action, actionName: newName }
|
||||
: action
|
||||
);
|
||||
|
||||
setSelectedPointData({
|
||||
...selectedPointData,
|
||||
actions: updatedActions,
|
||||
});
|
||||
|
||||
if (event) {
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddAction = () => {
|
||||
if (!selectedEventData || !selectedPointData) return;
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ function HumanMechanics() {
|
||||
if (isNaN(numericValue)) return;
|
||||
|
||||
const updatedEvent = {
|
||||
...selectedEventData.data,
|
||||
speed: numericValue
|
||||
} as HumanEventSchema;
|
||||
|
||||
|
||||
@@ -71,36 +71,6 @@ function RoboticArmMechanics() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleRenameAction = (newName: string) => {
|
||||
if (!selectedAction.actionId || !selectedPointData) return;
|
||||
|
||||
const event = updateAction(
|
||||
selectedProduct.productUuid,
|
||||
selectedAction.actionId,
|
||||
{ actionName: newName }
|
||||
);
|
||||
|
||||
const updatedActions = selectedPointData.actions.map(action =>
|
||||
action.actionUuid === selectedAction.actionId
|
||||
? { ...action, actionName: newName }
|
||||
: action
|
||||
);
|
||||
|
||||
setSelectedPointData({
|
||||
...selectedPointData,
|
||||
actions: updatedActions,
|
||||
});
|
||||
|
||||
if (event) {
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSpeedChange = (value: string) => {
|
||||
if (!selectedEventData) return;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ function StorageMechanics() {
|
||||
const [spawnedCount, setSpawnedCount] = useState("0");
|
||||
const [spawnedMaterial, setSpawnedMaterial] = useState("Default material");
|
||||
const [selectedPointData, setSelectedPointData] = useState<StoragePointSchema | undefined>();
|
||||
const [currentAction, setCurrentAction] = useState<StorageAction | undefined>();
|
||||
const { selectedEventData } = useSelectedEventData();
|
||||
const { productStore } = useSceneContext();
|
||||
const { getPointByUuid, updateAction, updateEvent, getEventByModelUuid, getActionByUuid, addAction, removeAction } = productStore();
|
||||
@@ -40,7 +39,6 @@ function StorageMechanics() {
|
||||
if (point?.actions?.length) {
|
||||
setSelectedPointData(point);
|
||||
const firstAction = point.actions[0];
|
||||
setCurrentAction(firstAction);
|
||||
|
||||
const eventData = getEventByModelUuid(
|
||||
selectedProduct.productUuid,
|
||||
@@ -62,7 +60,6 @@ function StorageMechanics() {
|
||||
}
|
||||
} else {
|
||||
clearSelectedAction();
|
||||
setCurrentAction(undefined);
|
||||
}
|
||||
}, [selectedEventData, selectedProduct]);
|
||||
|
||||
@@ -74,18 +71,18 @@ function StorageMechanics() {
|
||||
selectedEventData.selectedPoint
|
||||
) as StoragePointSchema | undefined;
|
||||
|
||||
const newCurrentAction = getActionByUuid(selectedProduct.productUuid, selectedAction.actionId);
|
||||
const actionUuid = selectedAction.actionId || point?.actions[0].actionUuid || '';
|
||||
|
||||
const newCurrentAction = getActionByUuid(selectedProduct.productUuid, actionUuid);
|
||||
|
||||
if (newCurrentAction && (newCurrentAction.actionType === 'store' || newCurrentAction.actionType === 'retrieve')) {
|
||||
if (!selectedAction.actionId) {
|
||||
setSelectedAction(newCurrentAction.actionUuid, newCurrentAction.actionName);
|
||||
}
|
||||
setCurrentAction(newCurrentAction);
|
||||
const uiOption = newCurrentAction.actionType === "retrieve" ? "spawn" : "store";
|
||||
setActiveOption(uiOption);
|
||||
} else {
|
||||
clearSelectedAction();
|
||||
setCurrentAction(undefined);
|
||||
}
|
||||
}
|
||||
}, [selectedAction, selectedProduct, selectedEventData]);
|
||||
@@ -106,17 +103,19 @@ function StorageMechanics() {
|
||||
}
|
||||
|
||||
const handleActionTypeChange = (option: string) => {
|
||||
if (!selectedAction.actionId || !currentAction || !selectedPointData) return;
|
||||
if (!selectedAction.actionId || !selectedPointData) return;
|
||||
|
||||
const internalOption = option === "spawn" ? "retrieve" : "store";
|
||||
|
||||
const updatedAction = {
|
||||
...currentAction,
|
||||
actionType: internalOption as "store" | "retrieve"
|
||||
};
|
||||
|
||||
const updatedActions = selectedPointData.actions.map(action =>
|
||||
action.actionUuid === updatedAction.actionUuid ? updatedAction : action
|
||||
action.actionUuid === selectedAction.actionId ? {
|
||||
...action,
|
||||
actionType: updatedAction.actionType
|
||||
} : action
|
||||
);
|
||||
|
||||
const updatedPoint = { ...selectedPointData, actions: updatedActions };
|
||||
@@ -136,7 +135,6 @@ function StorageMechanics() {
|
||||
);
|
||||
}
|
||||
|
||||
setCurrentAction(updatedAction);
|
||||
setSelectedPointData(updatedPoint);
|
||||
setActiveOption(option as "store" | "spawn");
|
||||
};
|
||||
@@ -148,7 +146,6 @@ function StorageMechanics() {
|
||||
if (isNaN(numericValue)) return;
|
||||
|
||||
const updatedEvent = {
|
||||
...selectedEventData.data,
|
||||
storageCapacity: numericValue
|
||||
} as StorageEventSchema;
|
||||
|
||||
@@ -186,7 +183,6 @@ function StorageMechanics() {
|
||||
if (numericValue > maxCapacity) return;
|
||||
|
||||
const updatedEvent = {
|
||||
...selectedEventData.data,
|
||||
storageCount: numericValue
|
||||
} as StorageEventSchema;
|
||||
|
||||
@@ -212,7 +208,6 @@ function StorageMechanics() {
|
||||
if (!selectedEventData) return;
|
||||
|
||||
const updatedEvent = {
|
||||
...selectedEventData.data,
|
||||
materialType: value
|
||||
} as StorageEventSchema;
|
||||
|
||||
@@ -283,13 +278,8 @@ function StorageMechanics() {
|
||||
const nextAction = updatedPoint.actions[index] || updatedPoint.actions[index - 1];
|
||||
if (nextAction) {
|
||||
setSelectedAction(nextAction.actionUuid, nextAction.actionName);
|
||||
const action = getActionByUuid(selectedProduct.productUuid, nextAction.actionUuid);
|
||||
if (action) {
|
||||
setCurrentAction(action as StorageAction);
|
||||
}
|
||||
} else {
|
||||
clearSelectedAction();
|
||||
setCurrentAction(undefined);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -318,7 +308,7 @@ function StorageMechanics() {
|
||||
handleDeleteAction={handleDeleteAction}
|
||||
/>
|
||||
|
||||
{selectedAction.actionId && currentAction && (
|
||||
{selectedAction.actionId && (
|
||||
<div className="selected-actions-details">
|
||||
<div className="selected-actions-header">
|
||||
<RenameInput
|
||||
|
||||
@@ -119,26 +119,6 @@ function VehicleMechanics() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleRenameAction = (newName: string) => {
|
||||
if (!selectedPointData) return;
|
||||
|
||||
setActionName(newName);
|
||||
const event = updateAction(
|
||||
selectedProduct.productUuid,
|
||||
selectedPointData.action.actionUuid,
|
||||
{ actionName: newName }
|
||||
);
|
||||
|
||||
if (event) {
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productUuid,
|
||||
projectId || '',
|
||||
event
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLoadCapacityChange = (value: string) => {
|
||||
if (!selectedPointData) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user