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(erp): one shared BOM/BOP row for item, quote and job methods; phones edit lines in a sheet, reorder by handle and hold for a menu

aashuc5f7e395c906
diff --git a/apps/erp/app/components/BoMExplorer/BoMExplorer.tsx b/apps/erp/app/components/BoMExplorer/BoMExplorer.tsx
index bd795a35c7..ee930f0e45 100644
--- a/apps/erp/app/components/BoMExplorer/BoMExplorer.tsx
+++ b/apps/erp/app/components/BoMExplorer/BoMExplorer.tsx
@@ -6,6 +6,9 @@ import { PreviewCard } from "@base-ui-components/react/preview-card";
import { hasOnshapeIntegration } from "@carbon/ee";
import {
Badge,
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuTrigger,
Copy,
cn,
DropdownMenu,
@@ -19,6 +22,7 @@ import {
Input,
InputGroup,
InputLeftElement,
+ useViewport,
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -141,6 +145,8 @@ export function BoMExplorerProvider<T extends BoMExplorerNodeData>({
const [filterTextInternal, setFilterTextInternal] = useState("");
const filterText = filterTextProp ?? filterTextInternal;
+ // Phones: touch-sized rows (BoMExplorerRow draws them at this height).
+ const { isPhone } = useViewport();
const {
nodes,
@@ -156,7 +162,7 @@ export function BoMExplorerProvider<T extends BoMExplorerNodeData>({
tree,
// biome-ignore lint/suspicious/noEmptyBlockStatements: selection is URL-driven
onSelectedIdChanged: () => {},
- estimatedRowHeight: () => 32,
+ estimatedRowHeight: () => (isPhone ? 48 : 32),
parentRef,
filter: {
value: { text: filterText },
@@ -426,6 +432,119 @@ export function BoMExplorerRow({ node, state, children }: BoMExplorerRowProps) {
const [isBadgeHovered, setIsBadgeHovered] = useState(false);
const bomId = bomIdMap.get(node.id);
+ const { isPhone } = useViewport();
+ const rowHeight = isPhone ? "h-12" : "h-8";
+
+ const content = (
+ <>
+ <div className={cn("flex items-center", rowHeight)}>
+ {Array.from({ length: node.level }).map((_, index) => (
+ <LevelLine
+ key={index}
+ isSelected={state.selected}
+ className={rowHeight}
+ />
+ ))}
+ <div
+ className={cn(
+ "flex items-center",
+ rowHeight,
+ isPhone ? "w-8 justify-center" : "w-4",
+ node.hasChildren && "hover:bg-accent"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (e.altKey) {
+ if (state.expanded) {
+ collapseAllBelowDepth(node.level);
+ } else {
+ expandAllBelowDepth(node.level);
+ }
+ } else {
+ toggleExpandNode(node.id);
+ }
+ }}
+ >
+ {node.hasChildren ? (
+ state.expanded ? (
+ <LuChevronDown
+ className={cn(
+ "h-4 w-4 text-gray-400 flex-shrink-0",
+ !isPhone && "ml-1"
+ )}
+ />
+ ) : (
+ <LuChevronRight
+ className={cn(
+ "h-4 w-4 text-gray-400 flex-shrink-0",
+ !isPhone && "ml-1"
+ )}
+ />
+ )
+ ) : (
+ <div className={cn(rowHeight, "w-4")} />
+ )}
+ </div>
+ </div>
+
+ <div className="flex w-full min-w-0 items-center justify-between gap-2">
+ <div className="flex flex-1 min-w-0 items-center gap-2 overflow-hidden">
+ {bomId && (
+ <Badge variant="outline" className="flex-shrink-0">
+ {bomId}
+ </Badge>
+ )}
+ <BoMNodeText node={node} />
+ </div>
+ <div className="flex flex-shrink-0 items-center gap-1">
+ {node.data.isRoot ? (
+ <Badge variant="outline" className="whitespace-nowrap">
+ V{getRootVersion(node)}
+ </Badge>
+ ) : (
+ <BoMNodeData node={node} />
+ )}
+ {children && (
+ <div
+ className="flex items-center gap-1"
+ onPointerEnter={() => setIsBadgeHovered(true)}
+ onPointerLeave={() => setIsBadgeHovered(false)}
+ >
+ {children}
+ </div>
+ )}
+ </div>
+ </div>
+ </>
+ );
+
+ const rowClassName = cn(
+ "flex cursor-pointer items-center overflow-hidden rounded-sm pr-2 gap-1 group/node",
+ rowHeight,
+ state.selected
+ ? "bg-muted hover:bg-accent"
+ : "bg-transparent hover:bg-accent",
+ node.data.isPickDescendant && "opacity-60"
+ );
+
+ if (isPhone) {
+ // Phones have no hover: holding a row shows the preview desktop shows
+ // on hover.
+ return (
+ <ContextMenu>
+ <ContextMenuTrigger asChild>
+ <div className={rowClassName} onClick={() => onNodeClick(node)}>
+ {content}
+ </div>
+ </ContextMenuTrigger>
+ <ContextMenuContent>
+ <div className="px-3 pb-2">
+ <BoMNodePreview node={node} />
+ </div>
+ </ContextMenuContent>
+ </ContextMenu>
+ );
+ }
return (
// Uncontrolled: Base UI owns hover open/close per row.
@@ -436,79 +555,12 @@ export function BoMExplorerRow({ node, state, children }: BoMExplorerRowProps) {
render={
<div
key={node.id}
- className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2 gap-1 group/node",
- state.selected
- ? "bg-muted hover:bg-accent"
- : "bg-transparent hover:bg-accent",
- node.data.isPickDescendant && "opacity-60"
- )}
+ className={rowClassName}
onClick={() => onNodeClick(node)}
/>
}
>
- <div className="flex h-8 items-center">
- {Array.from({ length: node.level }).map((_, index) => (
- <LevelLine 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 {
- toggleExpandNode(node.id);
- }
- }}
- >
- {node.hasChildren ? (
- state.expanded ? (
- <LuChevronDown className="h-4 w-4 text-gray-400 flex-shrink-0 ml-1" />
- ) : (
- <LuChevronRight className="h-4 w-4 text-gray-400 flex-shrink-0 ml-1" />
- )
- ) : (
- <div className="h-8 w-4" />
- )}
- </div>
- </div>
-
- <div className="flex w-full min-w-0 items-center justify-between gap-2">
- <div className="flex flex-1 min-w-0 items-center gap-2 overflow-hidden">
- {bomId && (
- <Badge variant="outline" className="flex-shrink-0">
- {bomId}
- </Badge>
- )}
- <BoMNodeText node={node} />
- </div>
- <div className="flex flex-shrink-0 items-center gap-1">
- {node.data.isRoot ? (
- <Badge variant="outline" className="whitespace-nowrap">
- V{getRootVersion(node)}
- </Badge>
- ) : (
- <BoMNodeData node={node} />
- )}
- {children && (
- <div
- className="flex items-center gap-1"
- onPointerEnter={() => setIsBadgeHovered(true)}
- onPointerLeave={() => setIsBadgeHovered(false)}
- >
- {children}
- </div>
- )}
- </div>
- </div>
+ {content}
</PreviewCard.Trigger>
<PreviewCard.Portal>
<PreviewCard.Positioner side="right" sideOffset={4} className="z-[100]">
diff --git a/apps/erp/app/components/DirectionAwareTabs.tsx b/apps/erp/app/components/DirectionAwareTabs.tsx
index 2c423552bc..3f97453b90 100644
--- a/apps/erp/app/components/DirectionAwareTabs.tsx
+++ b/apps/erp/app/components/DirectionAwareTabs.tsx
@@ -4,11 +4,12 @@
"use client";
-import { cn } from "@carbon/react";
+import { cn, useViewport } from "@carbon/react";
import { AnimatePresence, MotionConfig, motion } from "motion/react";
import type { ReactNode } from "react";
import { useMemo, useState } from "react";
import useMeasure from "react-use-measure";
+import { CompactTabRow } from "./Layout/CompactTabRow";
type Tab = {
id: number;
@@ -34,6 +35,7 @@ function DirectionAwareTabs({
const [direction, setDirection] = useState(0);
const [isAnimating, setIsAnimating] = useState(false);
const [ref, bounds] = useMeasure();
+ const { isPhone } = useViewport();
const content = useMemo(() => {
const activeTabContent = tabs.find((tab) => tab.id === activeTab)?.content;
@@ -80,39 +82,53 @@ function DirectionAwareTabs({
transition={{ duration: 0.2 }}
className="flex flex-col items-center w-full"
>
- <div
- className={cn(
- "flex flex-wrap gap-1 rounded-lg cursor-pointer bg-muted p-1 shadow-inner w-auto",
- className,
- rounded
- )}
- >
- {tabs.map((tab) => (
- <button
- key={tab.id}
- disabled={tab.disabled}
- onClick={() => handleTabClick(tab.id)}
- className={cn(
- "relative rounded-md px-3.5 py-1.5 text-sm font-medium text-foreground/80 transition focus-visible:outline-1 focus-visible:ring-2 ring-ring ring-offset-ring focus-visible:outline-none flex gap-2 items-center justify-center flex-initial",
- activeTab === tab.id
- ? "text-foreground"
- : "hover:text-foreground/60 text-foreground/80",
- rounded,
- tab.disabled && "cursor-not-allowed opacity-50"
- )}
- style={{ WebkitTapHighlightColor: "transparent" }}
- >
- {activeTab === tab.id && (
- <motion.span
- layoutId="bubble"
- className="absolute inset-0 z-10 bg-background text-foreground rounded-md border"
- transition={{ type: "spring", bounce: 0, duration: 0.4 }}
- />
- )}
- <span className="z-20 text-center">{tab.label}</span>
- </button>
- ))}
- </div>
+ {isPhone ? (
+ // Phones: the record pages' scrolling tab row, pinned over the content.
+ <CompactTabRow
+ className="sticky top-0 z-10 -mx-4 w-[calc(100%+2rem)] bg-popover"
+ items={tabs.map((tab) => ({
+ id: String(tab.id),
+ label: tab.label,
+ active: activeTab === tab.id,
+ disabled: tab.disabled,
+ onClick: () => handleTabClick(tab.id)
+ }))}
+ />
+ ) : (
+ <div
+ className={cn(
+ "flex flex-wrap gap-1 rounded-lg cursor-pointer bg-muted p-1 shadow-inner w-auto",
+ className,
+ rounded
+ )}
+ >
+ {tabs.map((tab) => (
+ <button
+ key={tab.id}
+ disabled={tab.disabled}
+ onClick={() => handleTabClick(tab.id)}
+ className={cn(
+ "relative rounded-md px-3.5 py-1.5 text-sm font-medium text-foreground/80 transition focus-visible:outline-1 focus-visible:ring-2 ring-ring ring-offset-ring focus-visible:outline-none flex gap-2 items-center justify-center flex-initial",
+ activeTab === tab.id
+ ? "text-foreground"
+ : "hover:text-foreground/60 text-foreground/80",
+ rounded,
+ tab.disabled && "cursor-not-allowed opacity-50"
+ )}
+ style={{ WebkitTapHighlightColor: "transparent" }}
+ >
+ {activeTab === tab.id && (
+ <motion.span
+ layoutId="bubble"
+ className="absolute inset-0 z-10 bg-background text-foreground rounded-md border"
+ transition={{ type: "spring", bounce: 0, duration: 0.4 }}
+ />
+ )}
+ <span className="z-20 text-center">{tab.label}</span>
+ </button>
+ ))}
+ </div>
+ )}
<MotionConfig transition={{ duration: 0.4, type: "spring", bounce: 0 }}>
<motion.div
className="relative mx-auto w-full h-full overflow-hidden"
diff --git a/apps/erp/app/components/Layout/CompactTabRow.tsx b/apps/erp/app/components/Layout/CompactTabRow.tsx
index 21132125fc..bebaa103a9 100644
--- a/apps/erp/app/components/Layout/CompactTabRow.tsx
+++ b/apps/erp/app/components/Layout/CompactTabRow.tsx
@@ -14,10 +14,11 @@ export type CompactTabItem = {
to?: string;
onClick?: () => void;
count?: number;
+ disabled?: boolean;
};
const tabClassName =
- "relative flex min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap text-[15px] font-medium text-muted-foreground outline-none after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:rounded-full data-[active=true]:text-foreground data-[active=true]:after:bg-foreground";
+ "relative flex disabled:opacity-50 min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap text-[15px] font-medium text-muted-foreground outline-none after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:rounded-full data-[active=true]:text-foreground data-[active=true]:after:bg-foreground";
/** Phones: a horizontally scrolling underline tab row. */
export function CompactTabRow({
@@ -74,6 +75,7 @@ export function CompactTabRow({
role="tab"
data-active={item.active}
aria-selected={item.active}
+ disabled={item.disabled}
className={tabClassName}
onClick={item.onClick}
>
diff --git a/apps/erp/app/components/SortableList.tsx b/apps/erp/app/components/SortableList.tsx
index d90db9a70e..e3d530999f 100644
--- a/apps/erp/app/components/SortableList.tsx
+++ b/apps/erp/app/components/SortableList.tsx
@@ -4,8 +4,31 @@
"use client";
-import { Checkbox, cn, HStack } from "@carbon/react";
-import { useLingui } from "@lingui/react/macro";
+import {
+ BottomSheet,
+ BottomSheetBody,
+ BottomSheetContent,
+ BottomSheetHeader,
+ BottomSheetTitle,
+ Button,
+ Checkbox,
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuTrigger,
+ cn,
+ HStack,
+ IconButton,
+ Modal,
+ ModalBody,
+ ModalContent,
+ ModalFooter,
+ ModalHeader,
+ ModalOverlay,
+ ModalTitle,
+ useViewport
+} from "@carbon/react";
+import { Trans, useLingui } from "@lingui/react/macro";
import {
AnimatePresence,
LayoutGroup,
@@ -14,9 +37,15 @@ import {
useDragControls
} from "motion/react";
import type { ReactNode } from "react";
-import { useEffect, useRef, useState } from "react";
+import { createContext, useContext, useEffect, useRef, useState } from "react";
import { flushSync } from "react-dom";
-import { LuSettings2, LuTrash, LuX } from "react-icons/lu";
+import {
+ LuGripVertical,
+ LuPencil,
+ LuSettings2,
+ LuTrash,
+ LuX
+} from "react-icons/lu";
import Empty from "./Empty";
export interface Item {
@@ -33,11 +62,21 @@ interface SortableItem<T> extends Item {
data: T;
}
+/**
+ * Phones: what a row's edit sheet needs from its row — the sheet is rendered
+ * by the editor (`SortableListItemPanel`), the row owns its title and delete.
+ */
+const PhoneRowContext = createContext<{
+ title: ReactNode;
+ onClose: () => void;
+ onDelete?: () => void;
+} | null>(null);
+
interface SortableListItemProps<T> {
item: SortableItem<T>;
items: SortableItem<T>[];
order: number;
- onSelectItem: (id: string) => void;
+ onSelectItem: (id: string | null) => void;
onToggleItem: (id: string) => void;
onRemoveItem: (id: string) => void;
renderExtra?: (item: SortableItem<T>) => React.ReactNode;
@@ -46,6 +85,8 @@ interface SortableListItemProps<T> {
className?: string;
handleDrag: () => void;
isReadOnly?: boolean;
+ /** Phones: extra items for the row's press-and-hold menu. */
+ menuItems?: ReactNode;
}
function SortableListItem<T>({
@@ -60,10 +101,13 @@ function SortableListItem<T>({
isExpanded,
isHighlighted,
className,
- isReadOnly = false
+ isReadOnly = false,
+ menuItems
}: SortableListItemProps<T>) {
const { t } = useLingui();
+ const { isPhone } = useViewport();
const [isDragging, setIsDragging] = useState(false);
+ const [isConfirmingDelete, setIsConfirmingDelete] = useState(false);
const isDraggable = !isExpanded && !isReadOnly;
const dragControls = useDragControls();
const itemRef = useRef<HTMLDivElement>(null);
@@ -89,6 +133,142 @@ function SortableListItem<T>({
}
}, [isHighlighted]);
+ if (isPhone) {
+ // Phones: a flat row. Tapping it opens the editor in a sheet, holding it
+ // opens its menu, and only the grip reorders — a drag anywhere on the
+ // card would fight the page's scroll.
+ const onDelete = isReadOnly ? undefined : () => setIsConfirmingDelete(true);
+ return (
+ <Reorder.Item
+ as="div"
+ value={item}
+ ref={itemRef}
+ dragListener={false}
+ dragControls={dragControls}
+ onDragEnd={handleDragEnd}
+ className={cn(
+ "relative flex items-start gap-3 py-3 pr-1 pl-4",
+ isDragging && "z-10 rounded-lg bg-card shadow-lg",
+ isHighlighted &&
+ "bg-primary/5 shadow-[inset_3px_0_0_hsl(var(--primary))]",
+ className
+ )}
+ >
+ <ContextMenu>
+ <ContextMenuTrigger asChild>
+ <div
+ role="button"
+ tabIndex={0}
+ className="flex min-w-0 flex-1 items-start gap-3 text-left"
+ onClick={() => onSelectItem(item.id)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") onSelectItem(item.id);
+ }}
+ >
+ <span
+ className={cn(
+ "mt-px flex size-6 shrink-0 items-center justify-center rounded-full border border-border bg-muted/50 text-xs font-medium tabular-nums text-muted-foreground",
+ item.order === "With Previous" &&
+ "border-dashed bg-transparent"
+ )}
+ >
+ {getParallelizedOrder(order, item, items)}
+ </span>
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
+ {item.title}
+ {item.details}
+ {item.footer && (
+ // The footer's own controls act in place.
+ <div
+ className="-ml-1 flex flex-wrap items-center gap-1"
+ onClick={(event) => event.stopPropagation()}
+ >
+ {item.footer}
+ </div>
+ )}
+ </div>
+ </div>
+ </ContextMenuTrigger>
+ <ContextMenuContent>
+ <ContextMenuItem onClick={() => onSelectItem(item.id)}>
+ <LuPencil className="mr-2 h-4 w-4" />
+ {isReadOnly ? <Trans>View</Trans> : <Trans>Edit</Trans>}
+ </ContextMenuItem>
+ {menuItems}
+ {onDelete && (
+ <ContextMenuItem destructive onClick={onDelete}>
+ <LuTrash className="mr-2 h-4 w-4" />
+ <Trans>Delete</Trans>
+ </ContextMenuItem>
+ )}
+ </ContextMenuContent>
+ </ContextMenu>
+ {!isReadOnly && (
+ <button
+ type="button"
+ aria-label={t`Reorder`}
+ className="-mt-2.5 flex h-11 w-10 shrink-0 cursor-grab touch-none items-center justify-center text-muted-foreground active:cursor-grabbing"
+ onPointerDown={(event) => {
+ flushSync(() => setIsDragging(true));
+ handleDrag();
+ dragControls.start(event);
+ }}
+ >
+ <LuGripVertical className="size-5" />
+ </button>
+ )}
+ <PhoneRowContext.Provider
+ value={{
+ title: item.title,
+ onClose: () => onSelectItem(null),
+ onDelete
+ }}
+ >
+ {renderExtra?.(item)}
+ </PhoneRowContext.Provider>
+ {isConfirmingDelete && (
+ <Modal
+ open
+ onOpenChange={(open) => {
+ if (!open) setIsConfirmingDelete(false);
+ }}
+ >
+ <ModalOverlay />
+ <ModalContent>
+ <ModalHeader>
+ <ModalTitle>
+ <Trans>Delete this line?</Trans>
+ </ModalTitle>
+ </ModalHeader>
+ <ModalBody>
+ <p className="text-sm text-muted-foreground">
+ <Trans>This cannot be undone.</Trans>
+ </p>
+ </ModalBody>
+ <ModalFooter>
+ <Button
+ variant="secondary"
+ onClick={() => setIsConfirmingDelete(false)}
+ >
+ <Trans>Cancel</Trans>
+ </Button>
+ <Button
+ variant="destructive"
+ onClick={() => {
+ setIsConfirmingDelete(false);
+ onRemoveItem(item.id);
+ }}
+ >
+ <Trans>Delete</Trans>
+ </Button>
+ </ModalFooter>
+ </ModalContent>
+ </Modal>
+ )}
+ </Reorder.Item>
+ );
+ }
+
return (
<div className={cn("", className)} key={item.id} ref={itemRef}>
<div className="flex w-full items-center">
@@ -232,6 +412,8 @@ export function SortableListItemToggle({
onToggle: () => void;
className?: string;
}) {
+ // Phones open a row by tapping it; its sheet has its own close.
+ if (useContext(PhoneRowContext)) return null;
return (
<button
type="button"
@@ -257,6 +439,36 @@ export function SortableListItemPanel({
isOpen: boolean;
children: ReactNode;
}) {
+ const { t } = useLingui();
+ const phoneRow = useContext(PhoneRowContext);
+ if (phoneRow) {
+ return (
+ <BottomSheet
+ open={isOpen}
+ onOpenChange={(open) => {
+ if (!open) phoneRow.onClose();
+ }}
+ >
+ <BottomSheetContent size="full">
+ <BottomSheetHeader className="max-md:justify-start">
+ {phoneRow.onDelete && (
+ <IconButton
+ aria-label={t`Delete`}
+ icon={<LuTrash />}
+ variant="ghost"
+ className="absolute left-1 top-1/2 size-11 -translate-y-1/2 text-red-500"
+ onClick={phoneRow.onDelete}
+ />
+ )}
+ <BottomSheetTitle asChild>
+ <div className="min-w-0 text-left">{phoneRow.title}</div>
+ </BottomSheetTitle>
+ </BottomSheetHeader>
+ <BottomSheetBody>{children}</BottomSheetBody>
+ </BottomSheetContent>
+ </BottomSheet>
+ );
+ }
return (
<AnimatePresence initial={false}>
{isOpen ? (
@@ -302,6 +514,7 @@ function SortableList<T extends Item>({
isReadOnly = false,
emptyState
}: SortableListProps<T>) {
+ const { isPhone } = useViewport();
if (items && Array.isArray(items) && items.length > 0) {
return (
<LayoutGroup>
@@ -310,7 +523,11 @@ function SortableList<T extends Item>({
values={items}
// biome-ignore lint/suspicious/noEmptyBlockStatements: suppressed due to migration
onReorder={isReadOnly ? () => {} : onReorder}
- className="flex flex-col gap-2"
+ className={cn(
+ "flex flex-col gap-2",
+ // Phones: flat rows edge to edge in the card.
+ isPhone && "-mx-4 -mb-4 gap-0 divide-y divide-border first:-mt-4"
+ )}
>
{items?.map((item, index) =>
renderItem({
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index c0b2f64b82..e4c481acd4 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -29,8 +29,7 @@ import {
toast,
useDisclosure,
useThrottle,
- useViewport,
- VStack
+ useViewport
} from "@carbon/react";
import { getItemById, getItemReadableId } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -43,7 +42,6 @@ import {
LuArrowLeft,
LuChevronDown,
LuChevronRight,
- LuExternalLink,
LuGitPullRequest,
LuGitPullRequestCreate,
LuGitPullRequestCreateArrow,
@@ -54,20 +52,13 @@ import {
LuTruck
} from "react-icons/lu";
import {
- Link,
useFetcher,
useFetchers,
useParams,
useSearchParams
} from "react-router";
import type { z } from "zod";
-import {
- ItemLifecycleBadge,
- MethodIcon,
- MethodItemTypeIcon,
- SourcingTypeIcon,
- TrackingTypeIcon
-} from "~/components";
+import { MethodIcon, SourcingTypeIcon } from "~/components";
import { ConfigurationEditor } from "~/components/Configurator/ConfigurationEditor";
import type { Configuration } from "~/components/Configurator/types";
import {
@@ -111,7 +102,7 @@ import type {
ConfigurationRule,
MakeMethod
} from "../../types";
-import { getLinkToItemDetails } from "./ItemForm";
+import { MaterialRowDetails, MaterialRowTitle } from "./MethodRow";
import type { ReleaseLockProps } from "./ReleaseLockAlert";
import ReleaseLockAlert, { getReleaseLockFlags } from "./ReleaseLockAlert";
@@ -957,7 +948,7 @@ function MaterialForm({
<div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4 w-full">
<HStack
- className="w-full justify-between cursor-pointer"
+ className="w-full justify-between cursor-pointer max-md:flex-wrap max-md:gap-y-2"
onClick={sourceDisclosure.onToggle}
>
<HStack>
@@ -973,7 +964,7 @@ function MaterialForm({
</>
)}
</HStack>
- <HStack>
+ <HStack className="max-md:flex-wrap max-md:gap-y-1">
<Badge variant="secondary">
<MethodIcon type={itemData.methodType} className="size-3 mr-1" />
{itemData.methodType === "Purchase to Order"
@@ -1274,109 +1265,31 @@ function makeItem(
return {
id: material.id!,
title: (
- <VStack spacing={0} className="py-1 cursor-pointer">
- <div className="flex w-full min-w-0 items-center gap-2 group">
- <h3 className="font-semibold min-w-0 truncate">
- {getItemReadableId(items, material.itemId) ?? ""}
- </h3>
- <ItemLifecycleBadge
- mode={items.find((i) => i.id === material.itemId)?.supersessionMode}
- />
- {hasRules && (
- <LuSquareFunction className="h-3.5 w-3.5 text-emerald-500 shrink-0" />
- )}
- {material.itemId && material.itemType && (
- <Link
- to={getLinkToItemDetails(material.itemType, material.itemId)}
- onClick={(e) => e.stopPropagation()}
- className="max-md:hit-area"
- >
- <LuExternalLink className="h-4 w-4 md:opacity-0 group-hover:opacity-100" />
- </Link>
- )}
- </div>
- {material?.description && (
- <span className="text-xs text-muted-foreground">
- {material.description}{" "}
- </span>
- )}
- </VStack>
+ <MaterialRowTitle
+ readableId={getItemReadableId(items, material.itemId)}
+ description={material?.description}
+ itemId={material.itemId}
+ itemType={material.itemType}
+ supersessionMode={
+ items.find((i) => i.id === material.itemId)?.supersessionMode
+ }
+ hasRules={hasRules}
+ />
),
checked,
details: (
- <HStack spacing={2}>
- {["Batch", "Serial"].includes(
- material.item?.itemTrackingType ?? ""
- ) && (
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <TrackingTypeIcon
- type={material.item?.itemTrackingType ?? ""}
- />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.item.itemTrackingType === "Inventory" ? (
- <Trans>Inventory Tracking</Trans>
- ) : material.item.itemTrackingType === "Non-Inventory" ? (
- <Trans>Non-Inventory Tracking</Trans>
- ) : material.item.itemTrackingType === "Serial" ? (
- <Trans>Serial Tracking</Trans>
- ) : (
- <Trans>Batch Tracking</Trans>
- )}
- </TooltipContent>
- </Tooltip>
- )}
-
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <MethodIcon type={material.methodType} isKit={material.kit} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.methodType === "Purchase to Order" ? (
- <Trans>Purchase to Order</Trans>
- ) : material.methodType === "Pull from Inventory" ? (
- <Trans>Pull from Inventory</Trans>
- ) : (
- <Trans>Make to Order</Trans>
- )}
- </TooltipContent>
- </Tooltip>
-
- {replenishmentSystem === "Buy and Make" && (
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <SourcingTypeIcon type={material.sourcingType} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>{material.sourcingType}</TooltipContent>
- </Tooltip>
- )}
-
- <Badge variant="secondary">{material.quantity}</Badge>
-
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <MethodItemTypeIcon type={material.itemType} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.itemType === "Consumable" ? (
- <Trans>Consumable</Trans>
- ) : material.itemType === "Material" ? (
- <Trans>Material</Trans>
- ) : (
- <Trans>Part</Trans>
- )}
- </TooltipContent>
- </Tooltip>
- </HStack>
+ <MaterialRowDetails
+ trackingType={material.item?.itemTrackingType}
+ methodType={material.methodType}
+ isKit={material.kit}
+ sourcingType={
+ replenishmentSystem === "Buy and Make"
+ ? material.sourcingType
+ : undefined
+ }
+ quantity={material.quantity}
+ itemType={material.itemType}
+ />
),
data: {
...material,
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index 53da8e7cf6..6014ecbdbd 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -106,7 +106,6 @@ import {
import AssemblyInstruction from "~/components/Form/AssemblyInstruction";
import InspectionDocument from "~/components/Form/InspectionDocument";
import Procedure from "~/components/Form/Procedure";
-import { SupplierProcessPreview } from "~/components/Form/SupplierProcess";
import { getUnitHint } from "~/components/Form/UnitHint";
import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";
import { OperationTypeIcon, ProcedureStepTypeIcon } from "~/components/Icons";
@@ -163,6 +162,7 @@ import type {
ConfigurationRule,
MakeMethod
} from "../../types";
+import { OperationRowDetails, OperationRowTitle } from "./MethodRow";
import type { ReleaseLockProps } from "./ReleaseLockAlert";
import ReleaseLockAlert, { getReleaseLockFlags } from "./ReleaseLockAlert";
@@ -4110,48 +4110,16 @@ function makeItem(
return {
id: operation.id!,
title: (
- <VStack spacing={0}>
- <h3 className="font-semibold max-w-full truncate cursor-pointer">
- {operation.description}
- </h3>
- {operation.operationType === "Outside Processing" && (
- <SupplierProcessPreview
- processId={operation.processId}
- supplierProcessId={operation.operationSupplierProcessId}
- />
- )}
- </VStack>
+ <OperationRowTitle
+ description={operation.description}
+ operationType={operation.operationType}
+ processId={operation.processId}
+ supplierProcessId={operation.operationSupplierProcessId}
+ />
),
checked: false,
order: operation.operationOrder,
- details: (
- <HStack spacing={1}>
- {operation.operationType === "Outside Processing" ? (
- <Badge>Outside Processing</Badge>
- ) : (
- <>
- {(operation?.setupTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Setup" className="h-3 w-3 mr-1" />
- {operation.setupTime} {operation.setupUnit}
- </Badge>
- )}
- {(operation?.laborTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Labor" className="h-3 w-3 mr-1" />
- {operation.laborTime} {operation.laborUnit}
- </Badge>
- )}
- {(operation?.machineTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Machine" className="h-3 w-3 mr-1" />
- {operation.machineTime} {operation.machineUnit}
- </Badge>
- )}
- </>
- )}
- </HStack>
- ),
+ details: <OperationRowDetails operation={operation} />,
data: operation
};
}
diff --git a/apps/erp/app/modules/items/ui/Item/MethodRow.tsx b/apps/erp/app/modules/items/ui/Item/MethodRow.tsx
new file mode 100644
index 0000000000..ac9c224e82
--- /dev/null
+++ b/apps/erp/app/modules/items/ui/Item/MethodRow.tsx
@@ -0,0 +1,286 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import {
+ Badge,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ useViewport,
+ VStack
+} from "@carbon/react";
+import { Trans } from "@lingui/react/macro";
+import type { ReactNode } from "react";
+import { LuExternalLink, LuSquareFunction } from "react-icons/lu";
+import { Link } from "react-router";
+import {
+ ItemLifecycleBadge,
+ MethodIcon,
+ MethodItemTypeIcon,
+ SourcingTypeIcon,
+ TimeTypeIcon,
+ TrackingTypeIcon
+} from "~/components";
+import { SupplierProcessPreview } from "~/components/Form/SupplierProcess";
+import type { MethodItemType } from "~/modules/shared";
+import { getLinkToItemDetails } from "./ItemForm";
+
+/*
+ * The rows of every Bill of Material and Bill of Process — item methods,
+ * quote lines and jobs build their rows from these, so the six editors look
+ * and behave the same. On phones the icon badges, whose meaning lives in a
+ * hover tooltip, show their label as text instead.
+ */
+
+function MethodTypeLabel({ type }: { type: string }) {
+ return type === "Purchase to Order" ? (
+ <Trans>Purchase to Order</Trans>
+ ) : type === "Pull from Inventory" ? (
+ <Trans>Pull from Inventory</Trans>
+ ) : (
+ <Trans>Make to Order</Trans>
+ );
+}
+
+function ItemTypeLabel({ type }: { type: string }) {
+ return type === "Consumable" ? (
+ <Trans>Consumable</Trans>
+ ) : type === "Material" ? (
+ <Trans>Material</Trans>
+ ) : (
+ <Trans>Part</Trans>
+ );
+}
+
+function TrackingLabel({ type }: { type: string }) {
+ return type === "Serial" ? (
+ <Trans>Serial Tracking</Trans>
+ ) : (
+ <Trans>Batch Tracking</Trans>
+ );
+}
+
+/** An icon badge with its label in a tooltip; on phones, icon and label. */
+function LabelledIcon({ icon, label }: { icon: ReactNode; label: ReactNode }) {
+ const { isPhone } = useViewport();
+ if (isPhone) {
+ return (
+ <span className="inline-flex items-center gap-1 whitespace-nowrap [&_svg]:size-3.5">
+ {icon}
+ {label}
+ </span>
+ );
+ }
+ return (
+ <Tooltip>
+ <TooltipTrigger>
+ <Badge variant="secondary">{icon}</Badge>
+ </TooltipTrigger>
+ <TooltipContent>{label}</TooltipContent>
+ </Tooltip>
+ );
+}
+
+export function MaterialRowTitle({
+ readableId,
+ description,
+ itemId,
+ itemType,
+ supersessionMode,
+ hasRules
+}: {
+ readableId?: string | null;
+ description?: string | null;
+ itemId?: string | null;
+ itemType?: string | null;
+ supersessionMode?: Parameters<typeof ItemLifecycleBadge>[0]["mode"];
+ hasRules?: boolean;
+}) {
+ return (
+ <VStack spacing={0} className="py-1 cursor-pointer max-md:py-0">
+ <div className="flex w-full min-w-0 items-center gap-2 group">
+ <h3 className="font-semibold min-w-0 truncate">{readableId ?? ""}</h3>
+ <ItemLifecycleBadge mode={supersessionMode} />
+ {hasRules && (
+ <LuSquareFunction className="h-3.5 w-3.5 text-emerald-500 shrink-0" />
+ )}
+ {itemId && itemType && (
+ <Link
+ to={getLinkToItemDetails(itemType as MethodItemType, itemId)}
+ onClick={(e) => e.stopPropagation()}
+ className="max-md:hit-area shrink-0"
+ >
+ <LuExternalLink className="h-4 w-4 md:opacity-0 group-hover:opacity-100" />
+ </Link>
+ )}
+ </div>
+ {description && (
+ <span className="text-xs text-muted-foreground max-md:w-full max-md:truncate max-md:text-sm">
+ {description}{" "}
+ </span>
+ )}
+ </VStack>
+ );
+}
+
+export function MaterialRowDetails({
+ trackingType,
+ methodType,
+ isKit,
+ sourcingType,
+ quantity,
+ itemType
+}: {
+ /** "Batch" or "Serial"; anything else shows nothing. */
+ trackingType?: string | null;
+ methodType: string;
+ isKit?: boolean | null;
+ /** Only for items that are bought and made. */
+ sourcingType?: string | null;
+ quantity: ReactNode;
+ itemType: string;
+}) {
+ const { isPhone } = useViewport();
+ const tracking =
+ trackingType === "Batch" || trackingType === "Serial" ? (
+ <LabelledIcon
+ icon={<TrackingTypeIcon type={trackingType} />}
+ label={<TrackingLabel type={trackingType} />}
+ />
+ ) : null;
+ const method = (
+ <LabelledIcon
+ icon={<MethodIcon type={methodType} isKit={isKit ?? undefined} />}
+ label={<MethodTypeLabel type={methodType} />}
+ />
+ );
+ const sourcing = sourcingType ? (
+ <LabelledIcon
+ icon={<SourcingTypeIcon type={sourcingType} />}
+ label={sourcingType}
+ />
+ ) : null;
+ const type = (
+ <LabelledIcon
+ icon={<MethodItemTypeIcon type={itemType} />}
+ label={<ItemTypeLabel type={itemType} />}
+ />
+ );
+
+ if (isPhone) {
+ return (
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[13px] text-muted-foreground">
+ <span className="font-medium text-foreground tabular-nums">
+ <Trans>Qty {quantity}</Trans>
+ </span>
+ {method}
+ {tracking}
+ {sourcing}
+ {type}
+ </div>
+ );
+ }
+
+ return (
+ <HStack spacing={2}>
+ {tracking}
+ {method}
+ {sourcing}
+ <Badge variant="secondary">{quantity}</Badge>
+ {type}
+ </HStack>
+ );
+}
+
+type OperationTimes = {
+ operationType?: string | null;
+ setupTime?: number | null;
+ setupUnit?: string | null;
+ laborTime?: number | null;
+ laborUnit?: string | null;
+ machineTime?: number | null;
+ machineUnit?: string | null;
+};
+
+export function OperationRowTitle({
+ description,
+ operationType,
+ processId,
+ supplierProcessId,
+ badges
+}: {
+ description?: string | null;
+ operationType?: string | null;
+ processId?: string | null;
+ supplierProcessId?: string | null;
+ /** Extra chips beside the name (a job's Rework or batch). */
+ badges?: ReactNode;
+}) {
+ return (
+ <VStack spacing={0}>
+ <HStack spacing={2} className="w-full min-w-0 max-md:flex-wrap">
+ <h3 className="font-semibold min-w-0 truncate cursor-pointer max-md:whitespace-normal max-md:line-clamp-2">
+ {description}
+ </h3>
+ {badges}
+ </HStack>
+ {operationType === "Outside Processing" && (
+ <SupplierProcessPreview
+ processId={processId ?? ""}
+ supplierProcessId={supplierProcessId ?? undefined}
+ />
+ )}
+ </VStack>
+ );
+}
+
+export function OperationRowDetails({
+ operation
+}: {
+ operation: OperationTimes;
+}) {
+ const { isPhone } = useViewport();
+ if (operation.operationType === "Outside Processing") {
+ return (
+ <HStack spacing={1}>
+ <Badge>
+ <Trans>Outside Processing</Trans>
+ </Badge>
+ </HStack>
+ );
+ }
+
+ const times = (
+ [
+ ["Setup", operation.setupTime, operation.setupUnit],
+ ["Labor", operation.laborTime, operation.laborUnit],
+ ["Machine", operation.machineTime, operation.machineUnit]
+ ] as const
+ ).filter(([, time]) => (time ?? 0) > 0);
+
+ if (isPhone) {
+ return (
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[13px] text-muted-foreground">
+ {times.map(([type, time, unit]) => (
+ <span key={type} className="inline-flex items-center gap-1">
+ <TimeTypeIcon type={type} className="size-3.5" />
+ {time} {unit}
+ </span>
+ ))}
+ </div>
+ );
+ }
+
+ return (
+ <HStack spacing={1}>
+ {times.map(([type, time, unit]) => (
+ <Badge key={type} variant="secondary">
+ <TimeTypeIcon type={type} className="h-3 w-3 mr-1" />
+ {time} {unit}
+ </Badge>
+ ))}
+ </HStack>
+ );
+}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 33cd9faed4..ddbe6861d5 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -22,14 +22,10 @@ import {
HStack,
IconButton,
Label,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
toast,
useDebounce,
useDisclosure,
- useViewport,
- VStack
+ useViewport
} from "@carbon/react";
import { getItemReadableId, INPUT_FORMAT } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -41,21 +37,15 @@ import {
LuArrowLeft,
LuChevronDown,
LuChevronRight,
- LuExternalLink,
LuGitPullRequest,
LuGitPullRequestCreate,
LuGitPullRequestCreateArrow,
LuPackage,
LuRedoDot
} from "react-icons/lu";
-import { Link, useFetcher, useFetchers, useParams } from "react-router";
+import { useFetcher, useFetchers, useParams } from "react-router";
import type { z } from "zod";
-import {
- ItemLifecycleBadge,
- MethodIcon,
- MethodItemTypeIcon,
- TrackingTypeIcon
-} from "~/components";
+import { MethodIcon } from "~/components";
import {
DefaultMethodType,
Hidden,
@@ -88,7 +78,10 @@ import {
useUser
} from "~/hooks";
import { ItemTrackingType } from "~/modules/items";
-import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import {
+ MaterialRowDetails,
+ MaterialRowTitle
+} from "~/modules/items/ui/Item/MethodRow";
import type { MethodItemType, MethodType } from "~/modules/shared";
import type { Item as ItemType } from "~/stores";
import { useItems } from "~/stores";
@@ -161,93 +154,31 @@ function makeItem(
return {
id: material.id!,
title: (
- <VStack spacing={0} className="py-1 cursor-pointer">
- <div className="flex w-full min-w-0 items-center gap-2 group">
- <h3 className="font-semibold min-w-0 truncate">
- {itemReadableId ?? ""}
- </h3>
- <ItemLifecycleBadge
- mode={items.find((i) => i.id === material.itemId)?.supersessionMode}
- />
- {material.itemId && material.itemType && (
- <Link
- to={getLinkToItemDetails(material.itemType, material.itemId)}
- onClick={(e) => e.stopPropagation()}
- className="max-md:hit-area"
- >
- <LuExternalLink className="h-4 w-4 md:opacity-0 group-hover:opacity-100" />
- </Link>
- )}
- </div>
- {material?.description && (
- <span className="text-xs text-muted-foreground">
- {material.description}{" "}
- </span>
- )}
- </VStack>
+ <MaterialRowTitle
+ readableId={itemReadableId}
+ description={material?.description}
+ itemId={material.itemId}
+ itemType={material.itemType}
+ supersessionMode={
+ items.find((i) => i.id === material.itemId)?.supersessionMode
+ }
+ />
),
checked: checked,
details: (
- <HStack spacing={2}>
- {material.requiresBatchTracking ? (
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <TrackingTypeIcon type="Batch" />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- <Trans>Batch Tracking</Trans>
- </TooltipContent>
- </Tooltip>
- ) : material.requiresSerialTracking ? (
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <TrackingTypeIcon type="Serial" />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- <Trans>Serial Tracking</Trans>
- </TooltipContent>
- </Tooltip>
- ) : null}
-
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <MethodIcon type={material.methodType} isKit={material.kit} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.methodType === "Purchase to Order" ? (
- <Trans>Purchase to Order</Trans>
- ) : material.methodType === "Pull from Inventory" ? (
- <Trans>Pull from Inventory</Trans>
- ) : (
- <Trans>Make to Order</Trans>
- )}
- </TooltipContent>
- </Tooltip>
- <Badge variant="secondary">{material.quantity}</Badge>
-
- <Tooltip>
- <TooltipTrigger className="max-md:hit-area">
- <Badge variant="secondary">
- <MethodItemTypeIcon type={material.itemType} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.itemType === "Consumable" ? (
- <Trans>Consumable</Trans>
- ) : material.itemType === "Material" ? (
- <Trans>Material</Trans>
- ) : (
- <Trans>Part</Trans>
- )}
- </TooltipContent>
- </Tooltip>
- </HStack>
+ <MaterialRowDetails
+ trackingType={
+ material.requiresBatchTracking
+ ? "Batch"
+ : material.requiresSerialTracking
+ ? "Serial"
+ : null
+ }
+ methodType={material.methodType}
+ isKit={material.kit}
+ quantity={material.quantity}
+ itemType={material.itemType}
+ />
),
data: {
...material,
@@ -361,6 +292,7 @@ const JobBillOfMaterial = ({
const isDisabled = ["Completed", "Cancelled"].includes(
jobData?.job?.status ?? ""
);
+ const isReadOnly = isDisabled || !permissions.can("update", "production");
const onToggleItem = (id: string) => {
if (!permissions.can("update", "production") || isDisabled) return;
@@ -493,6 +425,7 @@ const JobBillOfMaterial = ({
return (
<SortableListItem<Material>
+ isReadOnly={isReadOnly}
item={item}
items={items}
order={order}
@@ -580,6 +513,7 @@ const JobBillOfMaterial = ({
</HStack>
<CardContent>
<SortableList
+ isReadOnly={isReadOnly}
items={items}
onReorder={onReorder}
onToggleItem={onToggleItem}
@@ -876,7 +810,7 @@ function MaterialForm({
<div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4 w-full">
<HStack
- className="w-full justify-between cursor-pointer"
+ className="w-full justify-between cursor-pointer max-md:flex-wrap max-md:gap-y-2"
onClick={sourceDisclosure.onToggle}
>
<HStack>
@@ -896,7 +830,7 @@ function MaterialForm({
</>
)}
</HStack>
- <HStack>
+ <HStack className="max-md:flex-wrap max-md:gap-y-1">
<Badge variant="secondary">
<MethodIcon type={itemData.methodType} className="size-3 mr-1" />
{itemData.methodType === "Purchase to Order"
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index db03963451..d7da4da0cb 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -24,6 +24,7 @@ import {
CardHeader,
CardTitle,
Checkbox,
+ ContextMenuItem,
Count,
cn,
DropdownMenu,
@@ -121,7 +122,6 @@ import {
import AssemblyInstruction from "~/components/Form/AssemblyInstruction";
import InspectionDocument from "~/components/Form/InspectionDocument";
import Procedure from "~/components/Form/Procedure";
-import { SupplierProcessPreview } from "~/components/Form/SupplierProcess";
import { getUnitHint } from "~/components/Form/UnitHint";
import UnitOfMeasure, {
useUnitOfMeasure
@@ -147,6 +147,10 @@ import {
useUrlParams,
useUser
} from "~/hooks";
+import {
+ OperationRowDetails,
+ OperationRowTitle
+} from "~/modules/items/ui/Item/MethodRow";
import type {
OperationParameter,
OperationStep,
@@ -238,6 +242,17 @@ type JobBillOfProcessProps = {
customerId: string;
};
+function newIssueUrl(
+ operation: Operation,
+ urlParams: { [key: string]: string }
+) {
+ return `${path.to.newIssue}?${new URLSearchParams({
+ jobOperationId: operation.id!,
+ operationSupplierProcessId: operation.operationSupplierProcessId ?? "",
+ ...urlParams
+ }).toString()}`;
+}
+
function makeItems(
operations: Operation[],
tags: { name: string }[],
@@ -270,67 +285,40 @@ function makeItem(
return {
id: operation.id!,
title: (
- <VStack spacing={0}>
- <HStack spacing={2} className="w-full min-w-0">
- <h3 className="font-semibold min-w-0 truncate cursor-pointer">
- {operation.description}
- </h3>
- {operation.reworkId && <Badge variant="red">Rework</Badge>}
- {operation.jobOperationBatch &&
- (operation.jobOperationBatch.status === "Active" ||
- operation.jobOperationBatch.status === "Completing") && (
- <Badge
- variant={
- operation.jobOperationBatch.status === "Completing"
- ? "yellow"
- : "secondary"
- }
- >
- {operation.jobOperationBatch.readableId}
- </Badge>
- )}
- </HStack>
- {operation.operationType === "Outside Processing" && (
- <SupplierProcessPreview
- processId={operation.processId}
- supplierProcessId={operation.operationSupplierProcessId}
- />
- )}
- </VStack>
- ),
- checked: false,
- order: operation.operationOrder,
- details: (
- <HStack spacing={1}>
- {operation.operationType === "Outside Processing" ? (
- <Badge>Outside Processing</Badge>
- ) : (
+ <OperationRowTitle
+ description={operation.description}
+ operationType={operation.operationType}
+ processId={operation.processId}
+ supplierProcessId={operation.operationSupplierProcessId}
+ badges={
<>
- {(operation?.setupTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Setup" className="h-3 w-3 mr-1" />
- {operation.setupTime} {operation.setupUnit}
- </Badge>
- )}
- {(operation?.laborTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Labor" className="h-3 w-3 mr-1" />
- {operation.laborTime} {operation.laborUnit}
- </Badge>
- )}
-
- {(operation?.machineTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Machine" className="h-3 w-3 mr-1" />
- {operation.machineTime} {operation.machineUnit}
+ {operation.reworkId && (
+ <Badge variant="red">
+ <Trans>Rework</Trans>
</Badge>
)}
+ {operation.jobOperationBatch &&
+ (operation.jobOperationBatch.status === "Active" ||
+ operation.jobOperationBatch.status === "Completing") && (
+ <Badge
+ variant={
+ operation.jobOperationBatch.status === "Completing"
+ ? "yellow"
+ : "secondary"
+ }
+ >
+ {operation.jobOperationBatch.readableId}
+ </Badge>
+ )}
</>
- )}
- </HStack>
+ }
+ />
),
+ checked: false,
+ order: operation.operationOrder,
+ details: <OperationRowDetails operation={operation} />,
footer: temporaryItems[operation.id!] ? null : (
- <HStack className="w-full justify-between">
+ <HStack className="w-full justify-between max-md:flex-col max-md:items-start max-md:gap-1 max-md:space-x-0">
<HStack>
<JobOperationStatus operation={operation} />
<Assignee
@@ -340,7 +328,7 @@ function makeItem(
value={operation.assignee ?? undefined}
/>
</HStack>
- <HStack>
+ <HStack className="max-md:flex-wrap">
{projectedDate &&
(behindDays > 0 ? (
<Tooltip>
@@ -373,6 +361,7 @@ function makeItem(
<a
href={path.to.external.mesJobOperation(operation.id!)}
title={t`Open in MES`}
+ className="max-md:hidden"
>
<IconButton
icon={<LuPlay />}
@@ -391,13 +380,9 @@ function makeItem(
<Tooltip>
<TooltipTrigger asChild>
<Link
- to={`${path.to.newIssue}?${new URLSearchParams({
- jobOperationId: operation.id,
- operationSupplierProcessId:
- operation.operationSupplierProcessId ?? "",
- ...urlParams
- }).toString()}`}
+ to={newIssueUrl(operation, urlParams)}
title={t`Create Issue`}
+ className="max-md:hidden"
>
<IconButton
icon={<LuShieldX />}
@@ -596,15 +581,12 @@ const JobBillOfProcess = ({
(a, b) => (orderState[a.id!] ?? a.order) - (orderState[b.id!] ?? b.order)
);
+ const issueUrlParams = { itemId, salesOrderLineId, customerId };
const items = makeItems(
operations,
tags,
temporaryItems,
- {
- itemId,
- salesOrderLineId,
- customerId
- },
+ issueUrlParams,
t
).map((item) => ({
...item,
@@ -614,6 +596,7 @@ const JobBillOfProcess = ({
const isDisabled = ["Completed", "Cancelled"].includes(
jobData?.job?.status ?? ""
);
+ const isReadOnly = isDisabled || !permissions.can("update", "production");
const onToggleItem = (id: string) => {
if (!permissions.can("update", "parts")) return;
@@ -1016,6 +999,7 @@ const JobBillOfProcess = ({
return (
<SortableListItem<Operation>
+ isReadOnly={isReadOnly}
item={item}
items={items}
order={order}
@@ -1025,6 +1009,24 @@ const JobBillOfProcess = ({
onToggleItem={onToggleItem}
onRemoveItem={onRemoveItem}
handleDrag={onCloseOnDrag}
+ menuItems={
+ item.id in temporaryItems ? null : (
+ <>
+ <ContextMenuItem asChild>
+ <a href={path.to.external.mesJobOperation(item.id)}>
+ <LuPlay className="mr-2 h-4 w-4" />
+ <Trans>Open in MES</Trans>
+ </a>
+ </ContextMenuItem>
+ <ContextMenuItem asChild>
+ <Link to={newIssueUrl(item.data, issueUrlParams)}>
+ <LuShieldX className="mr-2 h-4 w-4" />
+ <Trans>Create Issue</Trans>
+ </Link>
+ </ContextMenuItem>
+ </>
+ )
+ }
renderExtra={(item) => (
<div>
<SortableListItemToggle
@@ -1070,6 +1072,7 @@ const JobBillOfProcess = ({
</HStack>
<CardContent>
<SortableList
+ isReadOnly={isReadOnly}
items={items}
onReorder={onReorder}
onToggleItem={onToggleItem}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index 69f609b289..68eb724f61 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -23,13 +23,9 @@ import {
HStack,
IconButton,
Label,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
toast,
useDebounce,
- useDisclosure,
- VStack
+ useDisclosure
} from "@carbon/react";
import {
distinctItemText,
@@ -45,15 +41,14 @@ import {
LuArrowLeft,
LuChevronDown,
LuChevronRight,
- LuExternalLink,
LuGitPullRequest,
LuGitPullRequestCreate,
LuGitPullRequestCreateArrow,
LuRedoDot
} from "react-icons/lu";
-import { Link, useFetcher, useFetchers, useParams } from "react-router";
+import { useFetcher, useFetchers, useParams } from "react-router";
import type { z } from "zod";
-import { MethodIcon, MethodItemTypeIcon, TrackingTypeIcon } from "~/components";
+import { MethodIcon } from "~/components";
import {
DefaultMethodType,
Hidden,
@@ -84,7 +79,10 @@ import {
useUser
} from "~/hooks";
import { lookupBuyPrice as lookupBuyPriceAsync } from "~/modules/items";
-import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import {
+ MaterialRowDetails,
+ MaterialRowTitle
+} from "~/modules/items/ui/Item/MethodRow";
import type { MethodItemType, MethodType } from "~/modules/shared";
import type { Item as ItemType } from "~/stores";
import { useItems } from "~/stores";
@@ -150,89 +148,26 @@ function makeItem(
return {
id: material.id!,
title: (
- <VStack spacing={0} className="py-1 cursor-pointer">
- <div className="flex w-full min-w-0 items-center gap-2 group">
- <h3 className="font-semibold min-w-0 truncate">{itemReadableId}</h3>
- {material.itemId && material.itemType && (
- <Link
- to={getLinkToItemDetails(material.itemType, material.itemId)}
- onClick={(e) => e.stopPropagation()}
- >
- <LuExternalLink className="h-4 w-4 md:opacity-0 group-hover:opacity-100" />
- </Link>
- )}
- </div>
- {distinctItemText(itemReadableId, material?.description) && (
- <span className="text-xs text-muted-foreground">
- {material.description}{" "}
- </span>
- )}
- </VStack>
+ <MaterialRowTitle
+ readableId={itemReadableId}
+ description={
+ distinctItemText(itemReadableId, material?.description)
+ ? material.description
+ : null
+ }
+ itemId={material.itemId}
+ itemType={material.itemType}
+ />
),
checked: checked,
details: (
- <HStack spacing={2}>
- {["Batch", "Serial"].includes(
- material.item?.itemTrackingType ?? ""
- ) && (
- <Tooltip>
- <TooltipTrigger>
- <Badge variant="secondary">
- <TrackingTypeIcon
- type={material.item?.itemTrackingType ?? ""}
- />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.item.itemTrackingType === "Inventory" ? (
- <Trans>Inventory Tracking</Trans>
- ) : material.item.itemTrackingType === "Non-Inventory" ? (
- <Trans>Non-Inventory Tracking</Trans>
- ) : material.item.itemTrackingType === "Serial" ? (
- <Trans>Serial Tracking</Trans>
- ) : (
- <Trans>Batch Tracking</Trans>
- )}
- </TooltipContent>
- </Tooltip>
- )}
-
- <Tooltip>
- <TooltipTrigger>
- <Badge variant="secondary">
- <MethodIcon type={material.methodType} isKit={material.kit} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.methodType === "Purchase to Order" ? (
- <Trans>Purchase to Order</Trans>
- ) : material.methodType === "Pull from Inventory" ? (
- <Trans>Pull from Inventory</Trans>
- ) : (
- <Trans>Make to Order</Trans>
- )}
- </TooltipContent>
- </Tooltip>
-
- <Badge variant="secondary">{material.quantity}</Badge>
-
- <Tooltip>
- <TooltipTrigger>
- <Badge variant="secondary">
- <MethodItemTypeIcon type={material.itemType} />
- </Badge>
- </TooltipTrigger>
- <TooltipContent>
- {material.itemType === "Consumable" ? (
- <Trans>Consumable</Trans>
- ) : material.itemType === "Material" ? (
- <Trans>Material</Trans>
- ) : (
- <Trans>Part</Trans>
- )}
- </TooltipContent>
- </Tooltip>
- </HStack>
+ <MaterialRowDetails
+ trackingType={material.item?.itemTrackingType}
+ methodType={material.methodType}
+ isKit={material.kit}
+ quantity={material.quantity}
+ itemType={material.itemType}
+ />
),
data: {
...material,
@@ -355,6 +290,7 @@ const QuoteBillOfMaterial = ({
const quoteData = useRouteData<{ quote: Quotation }>(path.to.quote(quoteId));
const isDisabled = quoteData?.quote?.status !== "Draft";
+ const isReadOnly = isDisabled || !permissions.can("update", "sales");
const onToggleItem = (id: string) => {
if (!permissions.can("update", "sales") || isDisabled) return;
@@ -490,6 +426,7 @@ const QuoteBillOfMaterial = ({
return (
<SortableListItem<Material>
+ isReadOnly={isReadOnly}
item={item}
items={items}
order={order}
@@ -554,6 +491,7 @@ const QuoteBillOfMaterial = ({
</HStack>
<CardContent>
<SortableList
+ isReadOnly={isReadOnly}
items={items}
onReorder={onReorder}
onToggleItem={onToggleItem}
@@ -864,7 +802,7 @@ function MaterialForm({
</div>
<div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4 w-full">
<HStack
- className="w-full justify-between cursor-pointer"
+ className="w-full justify-between cursor-pointer max-md:flex-wrap max-md:gap-y-2"
onClick={sourceDisclosure.onToggle}
>
<HStack>
@@ -884,7 +822,7 @@ function MaterialForm({
</>
)}
</HStack>
- <HStack>
+ <HStack className="max-md:flex-wrap max-md:gap-y-1">
<Badge variant="secondary">
<MethodIcon type={itemData.methodType} className="size-3 mr-1" />
{itemData.methodType === "Purchase to Order"
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index 3258d94c1d..8bfd08df78 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -91,7 +91,6 @@ import {
import AssemblyInstruction from "~/components/Form/AssemblyInstruction";
import InspectionDocument from "~/components/Form/InspectionDocument";
import Procedure from "~/components/Form/Procedure";
-import { SupplierProcessPreview } from "~/components/Form/SupplierProcess";
import { getUnitHint } from "~/components/Form/UnitHint";
import UnitOfMeasure, {
useUnitOfMeasure
@@ -112,6 +111,10 @@ import {
useRouteData,
useUser
} from "~/hooks";
+import {
+ OperationRowDetails,
+ OperationRowTitle
+} from "~/modules/items/ui/Item/MethodRow";
import type {
OperationParameter,
OperationStep,
@@ -190,49 +193,16 @@ function makeItem(
return {
id: operation.id!,
title: (
- <VStack spacing={0}>
- <h3 className="font-semibold max-w-full truncate cursor-pointer">
- {operation.description}
- </h3>
- {operation.operationType === "Outside Processing" && (
- <SupplierProcessPreview
- processId={operation.processId}
- supplierProcessId={operation.operationSupplierProcessId}
- />
- )}
- </VStack>
+ <OperationRowTitle
+ description={operation.description}
+ operationType={operation.operationType}
+ processId={operation.processId}
+ supplierProcessId={operation.operationSupplierProcessId}
+ />
),
checked: false,
order: operation.operationOrder,
- details: (
- <HStack spacing={1}>
- {operation.operationType === "Outside Processing" ? (
- <Badge>Outside Processing</Badge>
- ) : (
- <>
- {(operation?.setupTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Setup" className="h-3 w-3 mr-1" />
- {operation.setupTime} {operation.setupUnit}
- </Badge>
- )}
- {(operation?.laborTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Labor" className="h-3 w-3 mr-1" />
- {operation.laborTime} {operation.laborUnit}
- </Badge>
- )}
-
- {(operation?.machineTime ?? 0) > 0 && (
- <Badge variant="secondary">
- <TimeTypeIcon type="Machine" className="h-3 w-3 mr-1" />
- {operation.machineTime} {operation.machineUnit}
- </Badge>
- )}
- </>
- )}
- </HStack>
- ),
+ details: <OperationRowDetails operation={operation} />,
data: operation
};
}
@@ -335,6 +305,7 @@ const QuoteBillOfProcess = ({
const quoteData = useRouteData<{ quote: Quotation }>(path.to.quote(quoteId));
const isDisabled = quoteData?.quote?.status !== "Draft";
+ const isReadOnly = isDisabled || !permissions.can("update", "sales");
const [selectedItemId, setSelectedItemId] = useState<string | null>(null);
const [temporaryItems, setTemporaryItems] = useState<TemporaryItems>({});
@@ -766,6 +737,7 @@ const QuoteBillOfProcess = ({
return (
<SortableListItem<Operation>
+ isReadOnly={isReadOnly}
item={item}
items={items}
order={order}
@@ -820,6 +792,7 @@ const QuoteBillOfProcess = ({
</HStack>
<CardContent>
<SortableList
+ isReadOnly={isReadOnly}
items={items}
onReorder={onReorder}
onToggleItem={onToggleItem}