Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: add search to bom explorer

Brad Barbin56cf1af8155d
diff --git a/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx b/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx
index 10867c6f53..82985f7f0f 100644
--- a/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx
@@ -25,8 +25,8 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { Form, Link, useMatches } from "@remix-run/react";
import { BsFillHexagonFill } from "react-icons/bs";
+import { IoMdAdd } from "react-icons/io";
import { LuChevronsUpDown } from "react-icons/lu";
-import { MdAdd } from "react-icons/md";
import { z } from "zod";
import {
BreadcrumbItem,
@@ -158,7 +158,7 @@ function CompanyBreadcrumb() {
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem onClick={companyForm.onOpen}>
- <DropdownMenuIcon icon={<MdAdd />} />
+ <DropdownMenuIcon icon={<IoMdAdd />} />
Add Company
</DropdownMenuItem>
</DropdownMenuGroup>
diff --git a/apps/carbon/app/routes/x+/item+/index.tsx b/apps/carbon/app/routes/x+/item+/index.tsx
index 4ce7599dd7..388de147bc 100644
--- a/apps/carbon/app/routes/x+/item+/index.tsx
+++ b/apps/carbon/app/routes/x+/item+/index.tsx
@@ -4,9 +4,14 @@ import {
Enumerable,
HStack,
Heading,
+ IconButton,
+ Input,
+ InputGroup,
+ InputLeftElement,
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
+ VStack,
cn,
} from "@carbon/react";
import { Link, type LinkProps } from "@remix-run/react";
@@ -21,6 +26,8 @@ import {
LuChevronDown,
LuChevronUp,
LuHammer,
+ LuPlus,
+ LuSearch,
LuShoppingCart,
} from "react-icons/lu";
import { typedjson, useTypedLoaderData } from "remix-typedjson";
@@ -77,6 +84,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
isRoot: false,
},
},
+
{
id: "4",
parentId: "2",
@@ -93,6 +101,22 @@ export async function loader({ request }: LoaderFunctionArgs) {
isRoot: false,
},
},
+ {
+ id: "3",
+ parentId: "1",
+ hasChildren: false,
+ children: [],
+ level: 1,
+ data: {
+ itemId: "3",
+ readableId: "91772A061",
+ description: '5/16" Threaded Machine Screw',
+ quantity: 4,
+ fulfillmentMethod: "Buy",
+ isInherited: false,
+ isRoot: false,
+ },
+ },
] satisfies Method[],
});
}
@@ -117,7 +141,7 @@ export default function Item() {
<TabTrigger to="details">Details</TabTrigger>
<TabTrigger to="purchasing">Purchasing</TabTrigger>
<TabTrigger to="sales">Sales</TabTrigger>
- <TabTrigger isActive to="production">
+ <TabTrigger isActive to="purchasing">
Production
</TabTrigger>
<TabTrigger to="inventory">Inventory</TabTrigger>
@@ -149,7 +173,7 @@ export default function Item() {
<ResizablePanel order={2} minSize={40} defaultSize={60}>
{/* Details */}
</ResizablePanel>
- <ResizableHandle withHandle />
+ {/* <ResizableHandle withHandle />
<ResizablePanel
order={3}
minSize={20}
@@ -157,7 +181,7 @@ export default function Item() {
className="bg-card"
>
<div className="grid h-full overflow-hidden p-2"></div>
- </ResizablePanel>
+ </ResizablePanel> */}
</ResizablePanelGroup>
)}
</ClientOnly>
@@ -203,103 +227,122 @@ function BoMExplorer({
value: { text: filterText },
fn: (value, node) => {
if (value.text === "") return true;
- // if (
- // node.data.partId.toLowerCase().includes(value.text.toLowerCase())
- // ) {
- // return true;
- // }
+ if (
+ node.data.readableId.toLowerCase().includes(value.text.toLowerCase())
+ ) {
+ return true;
+ }
return false;
},
},
});
return (
- <TreeView
- parentRef={parentRef}
- virtualizer={virtualizer}
- autoFocus
- tree={methods}
- nodes={nodes}
- getNodeProps={getNodeProps}
- getTreeProps={getTreeProps}
- renderNode={({ node, state }) => (
- <>
- <div
- className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
- state.selected
- ? "bg-muted hover:bg-muted/90"
- : "bg-transparent hover:bg-muted/90"
- )}
- onClick={() => {
- selectNode(node.id);
- }}
- >
- <div className="flex h-8 items-center">
- {Array.from({ length: node.level }).map((_, index) => (
- <TaskLine key={index} isSelected={state.selected} />
- ))}
- <div
- className={cn(
- "flex h-8 w-4 items-center",
- node.hasChildren && "hover:bg-accent"
- )}
- onClick={(e) => {
- e.stopPropagation();
- if (e.altKey) {
- if (state.expanded) {
- collapseAllBelowDepth(node.level);
+ <VStack>
+ <HStack className="w-full">
+ <InputGroup size="sm" className="flex flex-grow">
+ <InputLeftElement>
+ <LuSearch className="h-4 w-4" />
+ </InputLeftElement>
+ <Input
+ placeholder="Search..."
+ value={filterText}
+ onChange={(e) => setFilterText(e.target.value)}
+ />
+ </InputGroup>
+ <IconButton
+ aria-label="Add"
+ variant="secondary"
+ icon={<LuPlus className="h-4 w-4" />}
+ />
+ </HStack>
+ <TreeView
+ parentRef={parentRef}
+ virtualizer={virtualizer}
+ autoFocus
+ tree={methods}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ renderNode={({ node, state }) => (
+ <>
+ <div
+ className={cn(
+ "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
+ state.selected
+ ? "bg-muted hover:bg-muted/90"
+ : "bg-transparent hover:bg-muted/90"
+ )}
+ onClick={() => {
+ selectNode(node.id);
+ }}
+ >
+ <div className="flex h-8 items-center">
+ {Array.from({ length: node.level }).map((_, index) => (
+ <TaskLine key={index} isSelected={state.selected} />
+ ))}
+ <div
+ className={cn(
+ "flex h-8 w-4 items-center",
+ node.hasChildren && "hover:bg-accent"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (e.altKey) {
+ if (state.expanded) {
+ collapseAllBelowDepth(node.level);
+ } else {
+ expandAllBelowDepth(node.level);
+ }
} else {
- expandAllBelowDepth(node.level);
+ toggleExpandNode(node.id);
}
- } else {
- toggleExpandNode(node.id);
- }
- scrollToNode(node.id);
- }}
- >
- {node.hasChildren ? (
- state.expanded ? (
- <LuChevronDown className="h-4 w-4 text-gray-400" />
+ scrollToNode(node.id);
+ }}
+ >
+ {node.hasChildren ? (
+ state.expanded ? (
+ <LuChevronDown className="h-4 w-4 text-gray-400" />
+ ) : (
+ <LuChevronUp className="h-4 w-4 text-gray-400" />
+ )
) : (
- <LuChevronUp className="h-4 w-4 text-gray-400" />
- )
- ) : (
- <div className="h-8 w-4" />
- )}
+ <div className="h-8 w-4" />
+ )}
+ </div>
</div>
- </div>
- <div className="flex w-full items-center justify-between gap-2">
- <div
- className={cn(
- "flex items-center gap-2 overflow-x-hidden",
- node.data.isInherited && "opacity-50"
- )}
- >
- <MethodIcon
- type={
- // node.data.isRoot ? "Method" :
- node.data.fulfillmentMethod
- }
- className="h-4 min-h-4 w-4 min-w-4"
- />
- <NodeText node={node} />
- </div>
- <div className="flex items-center gap-1">
- {node.data.isRoot ? (
- <Badge variant="outline" className="text-xs">
- Method
- </Badge>
- ) : (
- <NodeQuantity node={node} />
- )}
+ <div className="flex w-full items-center justify-between gap-2">
+ <div
+ className={cn(
+ "flex items-center gap-2 overflow-x-hidden",
+ node.data.isInherited && "opacity-50"
+ )}
+ >
+ <MethodIcon
+ type={
+ // node.data.isRoot ? "Method" :
+ node.data.fulfillmentMethod
+ }
+ className="h-4 min-h-4 w-4 min-w-4"
+ />
+ <NodeText node={node} />
+ </div>
+ <div className="flex items-center gap-1">
+ {node.data.isRoot ? (
+ <Badge variant="outline" className="text-xs">
+ Method
+ </Badge>
+ ) : (
+ <NodeQuantity node={node} />
+ )}
+ </div>
</div>
</div>
- </div>
- </>
- )}
- />
+ </>
+ )}
+ />
+ </VStack>
);
}
@@ -364,7 +407,7 @@ function TabTrigger({
<Link
{...props}
className={cn(
- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
isActive && "bg-background text-foreground shadow"
)}
>