Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 33x | import { ModuleMark } from "@/ahuora-design-system/componentIcons/ModuleMark";
import { SelectableItem } from "@/ahuora-design-system/ui/selectable-item";
import {
useGroupGraphicsObjects,
useSelectedObjectGroup,
useSimulationObjectGroup
} from "@/hooks/flowsheetObjects";
import { useSearchParam } from "@/hooks/searchParams";
import { setClick } from "@/store/ClickSlice";
import { useAppDispatch } from "@/store/hooks";
import { useRunCommand } from "just-search-it";
import { SwitchGroup } from "../../../../commands/SwitchCurrentGroup";
import { isStream } from "../../../../lib/isStream";
import { PropertiesStatus } from "./PropertyPanel/PropertiesStatus";
export const DisplayObjects = ({ type }: { type: "all" | "units" | "streams" }) => {
const [objectID, setObjectID] = useSearchParam("object");
const switchGroup = useRunCommand(SwitchGroup);
const simulationObjectGroup = useSimulationObjectGroup();
const dispatch = useAppDispatch();
const grouping = useSelectedObjectGroup();
const groupId = grouping?.id;
const groupObjects = useGroupGraphicsObjects(groupId)?.map(
(obj) => obj.simulationObject,
);
Iif (groupObjects == undefined) return "loading";
let displayObjects = groupObjects.map((obj) => ({
key: obj,
nested: [],
}));
if (type === "units") {
displayObjects = displayObjects.filter(
(obj) => !isStream(obj.key) && obj.key.objectType !== "group",
);
I} else if (type === "streams") {
displayObjects = displayObjects.filter((obj) => isStream(obj.key));
}
return (
<>
<div className="flex flex-col">
{displayObjects.length > 0 ? (
displayObjects.map((obj) => {
const item = obj.key;
const isSelected = item.id?.toString() === objectID;
const isModule = item.objectType === "group";
const onClick = () => {
setObjectID(item.id?.toString());
dispatch(
setClick({
type: item.objectType!,
id: item.id!,
}),
);
};
const onDoubleClick = () => {
setObjectID(item.id?.toString());
switchGroup(item.id);
dispatch(
setClick({
type: item.objectType!,
id: item.id!,
}),
);
};
return (
<SelectableItem
key={item.id}
name={item?.componentName}
onClick={onClick}
onDoubleClick={onDoubleClick}
isSelected={isSelected}
className=" py-1 cursor-pointer hover:bg-zinc-700"
startIcon={
<div className="flex items-center mr-2">
<PropertiesStatus
propertySet={item.unspecifiedProperties}
/>
</div>
}
endIcon={
isModule ? (
<div className="flex items-center justify-center w-4 h-4 text-emerald-600">
<ModuleMark />
</div>
) : null
}
/>
);
})
) : (
<p className="italic text-zinc-500 ml-4">No objects found</p>
)}
</div>
</>
);
}; |