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 assignee and tags to kanban cards in mes and erp

Brad Barbin957cb6656a3c
diff --git a/apps/erp/app/components/EmployeeAvatar.tsx b/apps/erp/app/components/EmployeeAvatar.tsx
index 6089e17d54..c5abb06146 100644
--- a/apps/erp/app/components/EmployeeAvatar.tsx
+++ b/apps/erp/app/components/EmployeeAvatar.tsx
@@ -30,14 +30,6 @@ const EmployeeAvatar = ({
const person = people.find((p) => p.id === employeeId);
- if (!person) {
- return (
- <HStack className="no-underline">
- <Avatar size={"xs"} {...props} />
- </HStack>
- );
- }
-
if (!person) {
return null;
}
diff --git a/apps/erp/app/components/Form/Tags.tsx b/apps/erp/app/components/Form/Tags.tsx
index 7a3add1c10..5ecb096e91 100644
--- a/apps/erp/app/components/Form/Tags.tsx
+++ b/apps/erp/app/components/Form/Tags.tsx
@@ -18,15 +18,29 @@ type TagsSelectProps = Omit<
const TagsPreview = (
value: string[],
- options: { value: string; label: string; helper?: string }[]
+ options: { value: string; label: string; helper?: string }[],
+ maxPreview?: number
) => {
return (
<HStack className="space-x-0 flex-grow gap-1 items-start">
- {value.map((label: string) => (
- <Badge key={label} variant="secondary">
- {label}
+ {maxPreview && value.length > maxPreview ? (
+ <Badge
+ variant="secondary"
+ className="border dark:border-none dark:shadow-button-base"
+ >
+ {value.length} tags
</Badge>
- ))}
+ ) : (
+ value.map((label: string) => (
+ <Badge
+ className="max-w-[160px] truncate border dark:border-none dark:shadow-button-base"
+ key={label}
+ variant="secondary"
+ >
+ {label}
+ </Badge>
+ ))
+ )}
</HStack>
);
};
diff --git a/apps/erp/app/components/Layout/Topbar/Notifications.tsx b/apps/erp/app/components/Layout/Topbar/Notifications.tsx
index c5f0264fa2..4b7920cc9b 100644
--- a/apps/erp/app/components/Layout/Topbar/Notifications.tsx
+++ b/apps/erp/app/components/Layout/Topbar/Notifications.tsx
@@ -21,6 +21,7 @@ import {
LuCalendarX,
LuDollarSign,
LuHammer,
+ LuHardHat,
LuInbox,
LuMailCheck,
LuMessageSquare,
@@ -139,6 +140,7 @@ function GenericNotification({
{...props}
/>
);
+ case NotificationEvent.JobOperationAssignment:
case NotificationEvent.JobOperationMessage:
const [jobId, operationId, makeMethodId, materialId] = id.split(":");
const link = materialId
@@ -147,7 +149,13 @@ function GenericNotification({
return (
<Notification
- icon={<LuMessageSquare />}
+ icon={
+ event === NotificationEvent.JobOperationMessage ? (
+ <LuMessageSquare />
+ ) : (
+ <LuHardHat />
+ )
+ }
to={`${link}?selectedOperation=${operationId}`}
{...props}
/>
diff --git a/apps/erp/app/hooks/useTags.tsx b/apps/erp/app/hooks/useTags.tsx
index fb12d3e5b2..ef3bb066cf 100644
--- a/apps/erp/app/hooks/useTags.tsx
+++ b/apps/erp/app/hooks/useTags.tsx
@@ -12,7 +12,7 @@ export function useTags({ id, table }: { id?: string; table: string }) {
formData.append("ids", id);
formData.append("table", table);
value.forEach((v) => {
- formData.append("value", v.replace(/\\\\"/g, '"'));
+ formData.append("value", v);
});
fetcher.submit(formData, {
diff --git a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
index 69bad64ea1..1ca6a71692 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
@@ -1,7 +1,6 @@
import type { Database } from "@carbon/database";
import { ValidatedForm } from "@carbon/form";
import {
- Button,
Card,
CardAction,
CardContent,
@@ -9,11 +8,16 @@ import {
CardFooter,
CardHeader,
CardTitle,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
HStack,
+ IconButton,
} from "@carbon/react";
import { Link, useFetcher } from "@remix-run/react";
import { useState } from "react";
-import { LuExternalLink } from "react-icons/lu";
+import { LuEllipsisVertical } from "react-icons/lu";
import type { z } from "zod";
import { Copy } from "~/components";
import {
@@ -85,12 +89,23 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
<CardDescription>{initialValues.name}</CardDescription>
</CardHeader>
<CardAction>
- <Button isIcon asChild variant="ghost" size="lg">
- {/* @ts-ignore */}
- <Link to={getLinkToItemDetails(type, initialValues.id)}>
- <LuExternalLink />
- </Link>
- </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="secondary"
+ icon={<LuEllipsisVertical />}
+ aria-label="Open menu"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem asChild>
+ {/* @ts-ignore */}
+ <Link to={getLinkToItemDetails(type, initialValues.id)}>
+ View Item Master
+ </Link>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
</CardAction>
</HStack>
<CardContent>
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
index 32282cc325..ae07e245a7 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
@@ -22,6 +22,7 @@ import { createPortal } from "react-dom";
import { path } from "~/utils/path";
import { BoardContainer, ColumnCard } from "./components/ColumnCard";
import { ItemCard } from "./components/ItemCard";
+import { KanbanProvider } from "./context/KanbanContext";
import type { Column, DisplaySettings, Item, Progress } from "./types";
import { coordinateGetter, hasDraggableData } from "./utils";
@@ -29,6 +30,7 @@ type KanbanProps = {
columns: Column[];
items: Item[];
progressByItemId: Record<string, Progress>;
+ tags: { name: string }[];
} & DisplaySettings;
const COLUMN_ORDER_KEY = "kanban-column-order";
@@ -37,6 +39,7 @@ const Kanban = ({
columns,
items: initialItems,
progressByItemId,
+ tags,
...displaySettings
}: KanbanProps) => {
const submit = useSubmit();
@@ -199,76 +202,75 @@ const Kanban = ({
};
return (
- <DndContext
- accessibility={{
- announcements,
- }}
- sensors={sensors}
- onDragStart={onDragStart}
- onDragEnd={onDragEnd}
- onDragOver={onDragOver}
+ <KanbanProvider
+ displaySettings={displaySettings}
+ selectedGroup={selectedGroup}
+ setSelectedGroup={setSelectedGroup}
+ tags={tags}
>
- <BoardContainer>
- <SortableContext items={columnOrder}>
- {columnOrder.map((colId) => {
- const col = columns.find((c) => c.id === colId);
- if (!col) return null;
- return (
- <ColumnCard
- key={col.id}
- column={col}
- items={items.filter((item) => item.columnId === col.id)}
- progressByItemId={progressByItemId}
- {...displaySettings}
- selectedGroup={selectedGroup}
- setSelectedGroup={setSelectedGroup}
- />
- );
- })}
- </SortableContext>
- </BoardContainer>
-
- <ClientOnly fallback={null}>
- {() =>
- createPortal(
- <DragOverlay>
- {activeColumn && (
+ <DndContext
+ accessibility={{
+ announcements,
+ }}
+ sensors={sensors}
+ onDragStart={onDragStart}
+ onDragEnd={onDragEnd}
+ onDragOver={onDragOver}
+ >
+ <BoardContainer>
+ <SortableContext items={columnOrder}>
+ {columnOrder.map((colId) => {
+ const col = columns.find((c) => c.id === colId);
+ if (!col) return null;
+ return (
<ColumnCard
- isOverlay
- column={activeColumn}
- selectedGroup={selectedGroup}
- items={items.filter(
- (item) => item.columnId === activeColumn.id
- )}
+ key={col.id}
+ column={col}
+ items={items.filter((item) => item.columnId === col.id)}
progressByItemId={progressByItemId}
- {...displaySettings}
- setSelectedGroup={setSelectedGroup}
/>
- )}
- {activeItem && (
- <ItemCard
- selectedGroup={selectedGroup}
- item={{
- ...activeItem,
- status: progressByItemId[activeItem.id]?.active
- ? "In Progress"
- : activeItem.status,
- employeeIds: progressByItemId[activeItem.id]?.employees
- ? Array.from(progressByItemId[activeItem.id].employees!)
- : undefined,
- progress: progressByItemId[activeItem.id]?.progress ?? 0,
- }}
- isOverlay
- {...displaySettings}
- setSelectedGroup={setSelectedGroup}
- />
- )}
- </DragOverlay>,
- document.body
- )
- }
- </ClientOnly>
- </DndContext>
+ );
+ })}
+ </SortableContext>
+ </BoardContainer>
+
+ <ClientOnly fallback={null}>
+ {() =>
+ createPortal(
+ <DragOverlay>
+ {activeColumn && (
+ <ColumnCard
+ isOverlay
+ column={activeColumn}
+ items={items.filter(
+ (item) => item.columnId === activeColumn.id
+ )}
+ progressByItemId={progressByItemId}
+ />
+ )}
+ {activeItem && (
+ <ItemCard
+ item={{
+ ...activeItem,
+ status: progressByItemId[activeItem.id]?.active
+ ? "In Progress"
+ : activeItem.status,
+ employeeIds: progressByItemId[activeItem.id]?.employees
+ ? Array.from(progressByItemId[activeItem.id].employees!)
+ : undefined,
+ progress: progressByItemId[activeItem.id]?.progress ?? 0,
+ }}
+ isOverlay
+ progressByItemId={progressByItemId}
+ />
+ )}
+ </DragOverlay>,
+ document.body
+ )
+ }
+ </ClientOnly>
+ </DndContext>
+ </KanbanProvider>
);
function onDragStart(event: DragStartEvent) {
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx
index df07c5f3a5..b68bf12835 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx
@@ -1,26 +1,12 @@
-import {
- Card,
- CardContent,
- CardHeader,
- cn,
- IconButton,
- ScrollArea,
- ScrollBar,
-} from "@carbon/react";
+import { cn, IconButton, ScrollArea, ScrollBar } from "@carbon/react";
import { formatDurationMilliseconds } from "@carbon/utils";
import { useDndContext } from "@dnd-kit/core";
import { SortableContext, useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { cva } from "class-variance-authority";
+import { useMemo } from "react";
import { LuGripVertical } from "react-icons/lu";
-import { useUrlParams } from "~/hooks";
-import type {
- Column,
- ColumnDragData,
- DisplaySettings,
- Item,
- Progress,
-} from "../types";
+import type { Column, Item, Progress } from "../types";
import { ItemCard } from "./ItemCard";
type ColumnCardProps = {
@@ -28,28 +14,20 @@ type ColumnCardProps = {
items: Item[];
isOverlay?: boolean;
progressByItemId: Record<string, Progress>;
- selectedGroup: string | null;
- setSelectedGroup: (jobId: string | null) => void;
-} & DisplaySettings;
+};
export function ColumnCard({
column,
items,
isOverlay,
progressByItemId,
- selectedGroup,
- setSelectedGroup,
- ...displaySettings
}: ColumnCardProps) {
- const [params] = useUrlParams();
- const currentFilters = params.getAll("filter");
- const itemsIds = items.map((item) => item.id);
+ const itemsIds = useMemo(() => {
+ return items.map((item) => item.id);
+ }, [items]);
const totalDuration = items.reduce((acc, item) => {
- const progress = progressByItemId[item.id]?.progress ?? 0;
- const duration = item.duration ?? 0;
- const effectiveDuration = Math.max(duration - progress, 0);
- return acc + effectiveDuration;
+ return acc + Math.max((item.duration ?? 0) - (item.progress ?? 0), 0);
}, 0);
const {
@@ -64,7 +42,7 @@ export function ColumnCard({
data: {
type: "column",
column,
- } satisfies ColumnDragData,
+ },
attributes: {
roleDescription: `Column: ${column.title}`,
},
@@ -76,40 +54,32 @@ export function ColumnCard({
};
const variants = cva(
- "w-[350px] max-w-full flex flex-col flex-shrink-0 snap-center rounded-none from-card/50 via-card/50 to-card/50 flex flex-col p-[1px] pt-0",
+ "w-[350px] max-w-full flex flex-col flex-shrink-0 snap-center rounded-none bg-card/30 border-0 border-r",
{
variants: {
dragging: {
- default: "border-2 border-transparent",
+ default: "",
over: "ring-2 opacity-30",
overlay: "ring-2 ring-primary",
},
- height: {
- filtered: "h-[calc(100dvh-135px)]",
- default: "h-[calc(100dvh-98px)]",
- },
- },
- defaultVariants: {
- dragging: "default",
- height: "default",
},
}
);
- const isActive = items.some((item) => progressByItemId[item.id]?.active);
-
return (
- <Card
+ <div
ref={setNodeRef}
style={style}
- className={variants({
- dragging: isOverlay ? "overlay" : isDragging ? "over" : "default",
- height: currentFilters.length > 0 ? "filtered" : "default",
- })}
+ className={cn(
+ `${variants({
+ dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,
+ })} flex flex-col p-[1px] pt-0`,
+ `h-[calc(100dvh-var(--header-height)*2)]`
+ )}
>
- <CardHeader className="p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 bg-card z-10 border-b">
+ <div className="p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 bg-card z-1 border-b">
<div className="flex flex-grow items-start space-x-2">
- {isActive ? (
+ {column.active ? (
<PulsingDot />
) : (
<div
@@ -140,39 +110,29 @@ export function ColumnCard({
{...listeners}
className="cursor-grab relative"
/>
- </CardHeader>
+ </div>
<ScrollArea className="flex-grow">
- <CardContent className="flex flex-col gap-2 p-2">
+ <div className="flex flex-col gap-2 p-2">
<SortableContext items={itemsIds}>
{items.map((item) => (
<ItemCard
- key={item.id}
- item={{
- ...item,
- status: progressByItemId[item.id]?.active
- ? "In Progress"
- : item.status,
- employeeIds: progressByItemId[item.id]?.employees
- ? Array.from(progressByItemId[item.id].employees!)
- : undefined,
- progress: progressByItemId[item.id]?.progress ?? 0,
- }}
- selectedGroup={selectedGroup}
- setSelectedGroup={setSelectedGroup}
- {...displaySettings}
+ key={item.id!}
+ item={item}
+ progressByItemId={progressByItemId}
/>
))}
</SortableContext>
- </CardContent>
+ </div>
+ <ScrollBar orientation="horizontal" />
</ScrollArea>
- </Card>
+ </div>
);
}
export function BoardContainer({ children }: { children: React.ReactNode }) {
const dndContext = useDndContext();
- const variations = cva("px-0 flex lg:justify-center", {
+ const variations = cva("relative px-0 flex lg:justify-center", {
variants: {
dragging: {
default: "snap-x snap-mandatory",
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
index 078918d258..fa3f0fcc13 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
@@ -1,11 +1,17 @@
import {
Card,
CardContent,
+ CardFooter,
CardHeader,
cn,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuIcon,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
HStack,
IconButton,
- Progress,
+ Progress as ProgressComponent,
Tooltip,
TooltipContent,
TooltipTrigger,
@@ -24,10 +30,12 @@ import {
LuCircleCheck,
LuCircleX,
LuClipboardCheck,
- LuExternalLink,
+ LuEllipsisVertical,
LuFlashlight,
LuFlashlightOff,
LuGripVertical,
+ LuHardHat,
+ LuPencil,
LuSquareUser,
LuTimer,
LuTrash,
@@ -39,22 +47,27 @@ import { RiProgress8Line } from "react-icons/ri";
import { AlmostDoneIcon } from "~/assets/icons/AlmostDoneIcon";
import { InProgressStatusIcon } from "~/assets/icons/InProgressStatusIcon";
import { TodoStatusIcon } from "~/assets/icons/TodoStatusIcon";
-import { CustomerAvatar, EmployeeAvatarGroup } from "~/components";
+import { Assignee, CustomerAvatar, EmployeeAvatarGroup } from "~/components";
+import { ValidatedForm } from "@carbon/form";
import { FaTasks } from "react-icons/fa";
+import { z } from "zod";
+import { Tags } from "~/components/Form";
+import { useTags } from "~/hooks/useTags";
import { getPrivateUrl, path } from "~/utils/path";
import { getDeadlineIcon, getDeadlineText } from "../../../Jobs/Deadline";
-import type { DisplaySettings, Item, ItemDragData } from "../types";
+import { useKanban } from "../context/KanbanContext";
+import type { Item } from "../types";
-type ItemCardProps = {
- item: Item;
- isOverlay?: boolean;
- selectedGroup: string | null;
- setSelectedGroup: (jobId: string | null) => void;
-} & DisplaySettings;
+interface Progress {
+ totalDuration: number;
+ progress: number;
+ active: boolean;
+ employees?: Set<string>;
+}
const cardVariants = cva(
- "dark:bg-gradient-to-tr dark:via-card dark:to-card dark:hover:to-muted/30 dark:hover:via-muted/30 bg-card hover:bg-muted/30",
+ "bg-card hover:bg-muted/30 dark:border-none dark:shadow-[inset_0_0.5px_0_rgb(255_255_255_/_0.08),_inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)]",
{
variants: {
highlighted: {
@@ -63,16 +76,14 @@ const cardVariants = cva(
},
dragging: {
over: "ring-2 ring-primary opacity-30",
- overlay:
- "ring-2 ring-primary dark:hover:from-muted dark:hover:via-muted dark:hover:to-muted hover:bg-muted",
+ overlay: "ring-2 ring-primary hover:bg-muted",
},
status: {
- "In Progress":
- "border-emerald-600/30 dark:from-emerald-600/10 bg-emerald-600/5",
+ "In Progress": "border-emerald-600/30",
Ready: "",
Done: "",
Paused: "",
- Canceled: "border-red-500/30 dark:from-red-500/10 bg-red-500/5",
+ Canceled: "border-red-500/30",
Waiting: "",
Todo: "border-border",
},
@@ -83,39 +94,35 @@ const cardVariants = cva(
}
);
-const cardHeaderVariants = cva("border-b", {
- variants: {
- status: {
- "In Progress": "border-emerald-600/10",
- Ready: "",
- Done: "",
- Paused: "border-yellow-500/10",
- Canceled: "border-red-500/10",
- Waiting: "border-yellow-500/10",
- Todo: "border-border",
+const cardHeaderVariants = cva(
+ "-mx-4 relative border-b border-border/50 pt-4 pl-4 pr-6 rounded-t-lg",
+ {
+ variants: {
+ status: {
+ "In Progress": "",
+ Ready: "",
+ Done: "",
+ Todo: "",
+ Paused: "",
+ Canceled: "",
+ Waiting: "",
+ },
+ },
+ defaultVariants: {
+ status: "Todo",
},
- },
- defaultVariants: {
- status: "Todo",
- },
-});
+ }
+);
-export function ItemCard({
- selectedGroup,
- item,
- isOverlay,
- showCustomer,
- showDescription,
- showDueDate,
- showDuration,
- showEmployee,
- showProgress,
- showQuantity,
- showStatus,
- showSalesOrder,
- showThumbnail,
- setSelectedGroup,
-}: ItemCardProps) {
+type ItemCardProps = {
+ item: Item;
+ isOverlay?: boolean;
+ progressByItemId: Record<string, Progress>;
+};
+
+export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {
+ const { displaySettings, selectedGroup, setSelectedGroup, tags } =
+ useKanban();
const {
setNodeRef,
attributes,
@@ -128,13 +135,13 @@ export function ItemCard({
data: {
type: "item",
item,
- } satisfies ItemDragData,
+ },
attributes: {
roleDescription: "item",
},
});
- const isHighlighted = selectedGroup === item.title;
+ const isHighlighted = selectedGroup === item.jobReadableId;
const style = {
transition,
@@ -146,50 +153,49 @@ export function ItemCard({
? new Date(item.dueDate) < new Date()
: false;
+ const progress = progressByItemId[item.id]?.progress ?? 0;
+ const status = progressByItemId[item.id]?.active
+ ? "In Progress"
+ : item.status;
+ const employeeIds = progressByItemId[item.id]?.employees
+ ? Array.from(progressByItemId[item.id].employees!)
+ : undefined;
+
return (
<Card
ref={setNodeRef}
style={style}
className={cn(
- "max-w-[330px] shadow-sm dark:shadow-sm",
+ "max-w-[330px] shadow-sm dark:shadow-sm py-0",
cardVariants({
dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,
- status: item.status,
+ status: status,
highlighted: isHighlighted,
})
)}
>
<CardHeader
className={cn(
- "max-w-full p-3 border-b relative",
cardHeaderVariants({
- status: item.status,
+ status: status,
})
)}
>
<div className="flex w-full max-w-full justify-between items-start gap-0">
<div className="flex flex-col space-y-0 min-w-0">
- {item.subtitle && (
- <span className="text-xs text-muted-foreground truncate">
- {item.subtitle}
+ {item.itemReadableId && (
+ <span className="text-xs text-muted-foreground line-clamp-1">
+ {item.itemReadableId}
</span>
)}
<Link
to={`${item.link}?selectedOperation=${item.id}`}
- className="mr-auto font-semibold truncate"
+ className="mr-auto font-semibold line-clamp-2 leading-tight"
>
- {item.title}
+ {item.itemDescription || item.itemReadableId}
</Link>
</div>
- <HStack spacing={0} className="flex-shrink-0 -mr-4">
- <IconButton
- aria-label="Highlight job"
- icon={isHighlighted ? <LuFlashlightOff /> : <LuFlashlight />}
- variant={"ghost"}
- onClick={() =>
- setSelectedGroup?.(isHighlighted ? null : item.title)
- }
- />
+ <HStack spacing={1} className="flex-shrink-0 -mr-2">
<IconButton
aria-label="Move item"
icon={<LuGripVertical />}
@@ -198,42 +204,64 @@ export function ItemCard({
{...listeners}
className="cursor-grab"
/>
- {item.link && (
- <Link to={`${item.link}?selectedOperation=${item.id}`}>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
<IconButton
- aria-label="Link to job operation"
- icon={<LuExternalLink />}
- variant={"ghost"}
- className="cursor-grab"
+ aria-label="More options"
+ icon={<LuEllipsisVertical />}
+ variant="secondary"
/>
- </Link>
- )}
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem
+ onClick={() =>
+ setSelectedGroup?.(
+ isHighlighted ? null : item.jobReadableId
+ )
+ }
+ destructive={isHighlighted}
+ >
+ <DropdownMenuIcon
+ icon={
+ isHighlighted ? <LuFlashlightOff /> : <LuFlashlight />
+ }
+ />
+ {isHighlighted ? "Remove Highlight" : "Highlight Job"}
+ </DropdownMenuItem>
+ {item.link && (
+ <DropdownMenuItem asChild>
+ <Link to={`${item.link}?selectedOperation=${item.id}`}>
+ <DropdownMenuIcon icon={<LuPencil />} />
+ Edit Operation
+ </Link>
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
</HStack>
</div>
- {showProgress &&
- Number.isFinite(item?.progress) &&
+ {displaySettings.showProgress &&
+ Number.isFinite(progress) &&
Number.isFinite(item?.duration) &&
- Number(item?.progress) >= 0 &&
+ Number(progress) >= 0 &&
Number(item?.duration) >= 0 && (
<HStack>
- <Progress
+ <ProgressComponent
indicatorClassName={
- (item.progress ?? 0) > (item.duration ?? 0)
+ (progress ?? 0) > (item.duration ?? 0)
? "bg-destructive"
- : item.status === "Paused"
+ : status === "Paused"
? "bg-yellow-500"
: ""
}
- numerator={
- item.progress ? formatDurationMilliseconds(item.progress) : ""
- }
+ numerator={progress ? formatDurationMilliseconds(progress) : ""}
denominator={
item.duration ? formatDurationMilliseconds(item.duration) : ""
}
value={Math.min(
- item.progress && item.duration
- ? (item.progress / item.duration) * 100
+ progress && item.duration
+ ? (progress / item.duration) * 100
: 0,
100
)}
@@ -241,11 +269,11 @@ export function ItemCard({
<LuTimer className="text-muted-foreground w-4 h-4" />
</HStack>
)}
- {showProgress &&
+ {displaySettings.showProgress &&
Number.isFinite(item.quantity) &&
Number(item.quantity) > 0 && (
<HStack>
- <Progress
+ <ProgressComponent
numerator={(item.quantityCompleted ?? 0).toString()}
denominator={(item.quantity ?? 0).toString()}
value={
@@ -258,29 +286,33 @@ export function ItemCard({
</HStack>
)}
</CardHeader>
- <CardContent className="p-3 space-y-2 text-left whitespace-pre-wrap text-sm">
- {showThumbnail && item.thumbnailPath && (
+ <CardContent className="pt-3 px-1 gap-2 text-left whitespace-pre-wrap text-sm">
+ {displaySettings.showThumbnail && item.thumbnailPath && (
<div className="flex justify-center">
<img
src={getPrivateUrl(item.thumbnailPath)}
- alt={item.title}
+ alt={item.itemDescription}
className="w-full h-auto rounded-lg"
/>
</div>
)}
- {showDescription && item.description && (
+ <HStack className="justify-start space-x-2">
+ <LuHardHat className="text-muted-foreground" />
+ <span className="text-sm line-clamp-1">{item.title}</span>
+ </HStack>
+ {displaySettings.showDescription && item.description && (
<HStack className="justify-start space-x-2">
<LuClipboardCheck className="text-muted-foreground" />
<span className="text-sm line-clamp-1">{item.description}</span>
</HStack>
)}
- {showStatus && item.status && (
+ {displaySettings.showStatus && status && (
<HStack className="justify-start space-x-2">
- {getStatusIcon(item.status)}
- <span className="text-sm">{item.status}</span>
+ {getStatusIcon(status)}
+ <span className="text-sm">{status}</span>
</HStack>
)}
- {showDuration && typeof item.duration === "number" && (
+ {displaySettings.showDuration && typeof item.duration === "number" && (
<HStack className="justify-start space-x-2">
<LuTimer className="text-muted-foreground" />
<span className="text-sm">
@@ -288,7 +320,7 @@ export function ItemCard({
</span>
</HStack>
)}
- {showDueDate && item.deadlineType && (
+ {displaySettings.showDueDate && item.deadlineType && (
<HStack className="justify-start space-x-2">
{getDeadlineIcon(item.deadlineType, isOverdue)}
<Tooltip>
@@ -311,14 +343,14 @@ export function ItemCard({
</Tooltip>
</HStack>
)}
- {showDueDate && item.dueDate && (
+ {displaySettings.showDueDate && item.dueDate && (
<HStack className="justify-start space-x-2">
<LuCalendarDays />
<span className="text-sm">{formatDate(item.dueDate)}</span>
</HStack>
)}
- {showSalesOrder &&
+ {displaySettings.showSalesOrder &&
item.salesOrderReadableId &&
item.salesOrderId &&
item.salesOrderLineId && (
@@ -336,33 +368,76 @@ export function ItemCard({
</HStack>
)}
- {showCustomer && item.customerId && (
+ {displaySettings.showCustomer && item.customerId && (
<HStack className="justify-start space-x-2">
<LuSquareUser className="text-muted-foreground" />
<CustomerAvatar customerId={item.customerId} />
</HStack>
)}
- {showEmployee &&
- Array.isArray(item.employeeIds) &&
- item.employeeIds.length > 0 && (
+ {displaySettings.showEmployee &&
+ Array.isArray(employeeIds) &&
+ employeeIds.length > 0 && (
<HStack className="justify-start space-x-2">
<LuUsers className="text-muted-foreground" />
- <EmployeeAvatarGroup employeeIds={item.employeeIds} />
+ <EmployeeAvatarGroup employeeIds={employeeIds} />
</HStack>
)}
- {showQuantity && Number(item.quantityScrapped) > 0 && (
+ {displaySettings.showQuantity && Number(item.quantityScrapped) > 0 && (
<HStack className="justify-start space-x-2 text-red-500">
<LuTrash className="w-4 h-4" />
<span className="text-sm">{item.quantityScrapped} Scrapped</span>
</HStack>
)}
</CardContent>
+ <CardFooter className="bg-accent/50 -mx-4 border-t px-4 py-2 items-center justify-between rounded-b-lg">
+ <HStack>
+ <Assignee
+ table="jobOperation"
+ id={item.id!}
+ size="sm"
+ value={item.assignee ?? undefined}
+ />
+ <JobOperationTags operation={item} availableTags={tags} />
+ </HStack>
+ </CardFooter>
</Card>
);
}
+function JobOperationTags({
+ operation,
+ availableTags,
+}: {
+ operation: Item;
+ availableTags: { name: string }[];
+}) {
+ const { onUpdateTags } = useTags({ id: operation.id, table: "jobOperation" });
+
+ return (
+ <ValidatedForm
+ defaultValues={{
+ tags: operation.tags ?? [],
+ }}
+ validator={z.object({
+ tags: z.array(z.string()).optional(),
+ })}
+ className="w-full"
+ >
+ <Tags
+ availableTags={availableTags}
+ label=""
+ name="tags"
+ table="operation"
+ inline
+ maxPreview={1}
+ onChange={onUpdateTags}
+ />
+ </ValidatedForm>
+ );
+}
+
function getStatusIcon(status: Item["status"]) {
switch (status) {
case "Ready":
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts b/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts
index db5109a368..a2dac1708a 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts
@@ -38,30 +38,35 @@ export type Event = Pick<
const itemValidator = z.object({
id: z.string(),
+ assignee: z.string().optional(),
columnId: z.string(),
columnType: z.string(),
- title: z.string(),
- link: z.string().optional(),
- subtitle: z.string().optional(),
- priority: z.number(),
customerId: z.string().optional(),
- employeeIds: z.array(z.string()).optional(),
+ deadlineType: z.enum(deadlineTypes).optional(),
description: z.string().optional(),
dueDate: z.string().optional(), // 2024-05-28
duration: z.number().optional(), // miliseconds
- deadlineType: z.enum(deadlineTypes).optional(),
+ employeeIds: z.array(z.string()).optional(),
+ itemDescription: z.string().optional(),
+ itemReadableId: z.string(),
+ jobReadableId: z.string(),
+ laborDuration: z.number().optional(),
+ link: z.string().optional(),
+ machineDuration: z.number().optional(),
+ priority: z.number(),
progress: z.number().optional(), // miliseconds
quantity: z.number().optional(),
quantityCompleted: z.number().optional(),
quantityScrapped: z.number().optional(),
- status: z.enum(jobOperationStatus).optional(),
- salesOrderReadableId: z.string().optional(),
salesOrderId: z.string().optional(),
salesOrderLineId: z.string().optional(),
+ salesOrderReadableId: z.string().optional(),
setupDuration: z.number().optional(),
- laborDuration: z.number().optional(),
- machineDuration: z.number().optional(),
+ status: z.enum(jobOperationStatus).optional(),
+ subtitle: z.string().optional(),
+ tags: z.array(z.string()).optional(),
thumbnailPath: z.string().optional(),
+ title: z.string(),
});
export type Item = z.infer<typeof itemValidator>;
diff --git a/apps/erp/app/novu/workflows.ts b/apps/erp/app/novu/workflows.ts
index 2d460032ef..b7ebddb5b9 100644
--- a/apps/erp/app/novu/workflows.ts
+++ b/apps/erp/app/novu/workflows.ts
@@ -12,6 +12,8 @@ const payloadSchema = z.object({
event: z.enum([
NotificationEvent.DigitalQuoteResponse,
NotificationEvent.JobAssignment,
+ NotificationEvent.JobOperationAssignment,
+ NotificationEvent.JobOperationMessage,
NotificationEvent.PurchaseInvoiceAssignment,
NotificationEvent.PurchaseOrderAssignment,
NotificationEvent.QuoteAssignment,
@@ -19,7 +21,6 @@ const payloadSchema = z.object({
NotificationEvent.SalesOrderAssignment,
NotificationEvent.SalesRfqAssignment,
NotificationEvent.SupplierQuoteAssignment,
- NotificationEvent.JobOperationMessage,
]),
from: z.string().optional(),
});
diff --git a/apps/erp/app/routes/api+/assign.ts b/apps/erp/app/routes/api+/assign.ts
index c0ed26a45f..93a9e7c11d 100644
--- a/apps/erp/app/routes/api+/assign.ts
+++ b/apps/erp/app/routes/api+/assign.ts
@@ -71,6 +71,8 @@ function getNotificationEvent(table: string): NotificationEvent | null {
return NotificationEvent.SalesOrderAssignment;
case "job":
return NotificationEvent.JobAssignment;
+ case "jobOperation":
+ return NotificationEvent.JobOperationAssignment;
case "purchaseOrder":
return NotificationEvent.PurchaseOrderAssignment;
case "purchaseInvoice":
diff --git a/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx b/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx
index e2fd839eb9..00ca8c40de 100644
--- a/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx
+++ b/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx
@@ -36,6 +36,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
});
}
+ const companySettings = await getCompanySettings(
+ serviceRole,
+ quote.data.companyId
+ );
+
switch (type) {
case "accept":
const digitalQuoteAcceptedBy = String(
@@ -62,7 +67,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const selectedLines = parseResult.data;
- const [convert, companySettings, opportunity] = await Promise.all([
+ const [convert, opportunity] = await Promise.all([
convertQuoteToOrder(serviceRole, {
id: quote.data.id,
companyId: quote.data.companyId,
@@ -71,7 +76,6 @@ export async function action({ request, params }: ActionFunctionArgs) {
digitalQuoteAcceptedBy,
digitalQuoteAcceptedByEmail,
}),
- getCompanySettings(serviceRole, quote.data.companyId),
getOpportunityByQuote(serviceRole, quote.data.id),
]);
@@ -180,6 +184,27 @@ export async function action({ request, params }: ActionFunctionArgs) {
});
}
+ if (companySettings.data?.digitalQuoteNotificationGroup?.length) {
+ try {
+ await tasks.trigger<typeof notifyTask>("notify", {
+ companyId: companySettings.data.id,
+ documentId: quote.data.id,
+ event: NotificationEvent.DigitalQuoteResponse,
+ recipient: {
+ type: "group",
+ groupIds:
+ companySettings.data?.digitalQuoteNotificationGroup ?? [],
+ },
+ });
+ } catch (err) {
+ console.error("Failed to trigger notification", err);
+ return json({
+ success: false,
+ message: "Failed to send notification",
+ });
+ }
+ }
+
return json({
success: true,
message: "Quote rejected!",
diff --git a/apps/erp/app/routes/x+/schedule+/index.tsx b/apps/erp/app/routes/x+/schedule+/index.tsx
index 8cd648853e..c603b1f8a4 100644
--- a/apps/erp/app/routes/x+/schedule+/index.tsx
+++ b/apps/erp/app/routes/x+/schedule+/index.tsx
@@ -50,6 +50,7 @@ import {
getProcessesList,
getWorkCentersByLocation,
} from "~/modules/resources";
+import { getTagsList } from "~/modules/shared";
import { getUserDefaults } from "~/modules/users/users.server";
import { makeDurations } from "~/utils/duration";
@@ -129,10 +130,11 @@ export async function loader({ request }: LoaderFunctionArgs) {
locationId = locations.data?.[0].id as string;
}
- const [workCenters, processes, operations] = await Promise.all([
+ const [workCenters, processes, operations, tags] = await Promise.all([
getWorkCentersByLocation(client, locationId),
getProcessesList(client, companyId),
getActiveJobOperationsByLocation(client, locationId, selectedWorkCenterIds),
+ getTagsList(client, companyId, "operation"),
]);
const activeWorkCenters = new Set();
@@ -210,13 +212,18 @@ export async function loader({ request }: LoaderFunctionArgs) {
)
: path.to.jobMethod(op.jobId, op.jobMakeMethodId),
subtitle: op.itemReadableId,
+ assignee: op.assignee,
+ tags: op.tags,
description: op.description,
dueDate: op.jobDueDate,
duration:
operation.setupDuration +
operation.laborDuration +
- operation.machineDuration, // set in the client
- progress: 0, // set in the client
+ operation.machineDuration,
+ jobReadableId: op.jobReadableId,
+ itemReadableId: op.itemReadableId,
+ itemDescription: op.itemDescription,
+ progress: 0,
deadlineType: op.jobDeadlineType,
customerId: op.jobCustomerId,
quantity: op.operationQuantity,
@@ -241,6 +248,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
return acc;
}, {} as Record<string, string>) ?? {}
).map(([id, readableId]) => ({ id, readableId })),
+ tags: tags.data ?? [],
});
}
@@ -264,6 +272,7 @@ function KanbanSchedule() {
items: initialItems,
processes,
salesOrders,
+ tags,
} = useLoaderData<typeof loader>();
const [items, setItems] = useState<Item[]>(initialItems);
@@ -348,7 +357,7 @@ function KanbanSchedule() {
variant="secondary"
className="border-dashed border-border"
>
- Settings
+ Display
</Button>
</PopoverTrigger>
<PopoverContent className="w-48">
@@ -395,7 +404,17 @@ function KanbanSchedule() {
columns={columns}
items={items}
progressByItemId={progressByOperation}
- {...displaySettings}
+ tags={tags}
+ showCustomer={displaySettings.showCustomer}
+ showDescription={displaySettings.showDescription}
+ showDueDate={displaySettings.showDueDate}
+ showDuration={displaySettings.showDuration}
+ showEmployee={displaySettings.showEmployee}
+ showProgress={displaySettings.showProgress}
+ showQuantity={displaySettings.showQuantity}
+ showStatus={displaySettings.showStatus}
+ showSalesOrder={displaySettings.showSalesOrder}
+ showThumbnail={displaySettings.showThumbnail}
/>
) : hasFilters ? (
<div className="flex flex-col w-full h-full items-center justify-center gap-4">
diff --git a/apps/erp/app/trigger/notify.ts b/apps/erp/app/trigger/notify.ts
index fa9b27b6f0..40059de7f4 100644
--- a/apps/erp/app/trigger/notify.ts
+++ b/apps/erp/app/trigger/notify.ts
@@ -151,6 +151,10 @@ export const notifyTask = task({
return `Digital Quote ${digitalQuote?.data?.quoteId} was completed by ${digitalQuote.data.digitalQuoteAcceptedBy}`;
}
+ if (digitalQuote.data.digitalQuoteRejectedBy) {
+ return `Digital Quote ${digitalQuote?.data?.quoteId} was rejected by ${digitalQuote.data.digitalQuoteRejectedBy}`;
+ }
+
return `Digital Quote ${digitalQuote?.data?.quoteId} was accepted`;
default:
return null;
diff --git a/apps/mes/app/components/Filter/Filter.tsx b/apps/mes/app/components/Filter/Filter.tsx
index ed0d4d269f..0f8a7837a0 100644
--- a/apps/mes/app/components/Filter/Filter.tsx
+++ b/apps/mes/app/components/Filter/Filter.tsx
@@ -112,7 +112,6 @@ const Filter = forwardRef<HTMLButtonElement, FilterProps>(
ref={ref}
variant="secondary"
onClick={clearFilters}
- className={"!border-dashed border-border"}
{...props}
>
Clear Filters
diff --git a/apps/mes/app/components/JobOperation.tsx b/apps/mes/app/components/JobOperation.tsx
index f70493cf88..290852efbe 100644
--- a/apps/mes/app/components/JobOperation.tsx
+++ b/apps/mes/app/components/JobOperation.tsx
@@ -342,9 +342,11 @@ export const JobOperation = ({
<ItemThumbnail thumbnailPath={thumbnailPath} size="xl" />
)}
<div className="flex flex-col flex-grow">
- <Heading size="h3">{operation.itemReadableId}</Heading>
- <p className="text-muted-foreground line-clamp-1">
+ <Heading size="h3" className="line-clamp-1">
{operation.itemDescription}
+ </Heading>
+ <p className="text-muted-foreground line-clamp-1">
+ {operation.itemReadableId}
</p>
</div>
</HStack>
diff --git a/apps/mes/app/components/Kanban/components/ColumnCard.tsx b/apps/mes/app/components/Kanban/components/ColumnCard.tsx
index 08e35dcf20..6d63ebaa64 100644
--- a/apps/mes/app/components/Kanban/components/ColumnCard.tsx
+++ b/apps/mes/app/components/Kanban/components/ColumnCard.tsx
@@ -1,12 +1,4 @@
-import {
- Card,
- CardContent,
- CardHeader,
- cn,
- IconButton,
- ScrollArea,
- ScrollBar,
-} from "@carbon/react";
+import { cn, IconButton, ScrollArea, ScrollBar } from "@carbon/react";
import { formatDurationMilliseconds } from "@carbon/utils";
import { useDndContext } from "@dnd-kit/core";
import { SortableContext, useSortable } from "@dnd-kit/sortable";
@@ -64,11 +56,11 @@ export function ColumnCard({
};
const variants = cva(
- "w-[350px] max-w-full flex flex-col flex-shrink-0 snap-center rounded-none from-card/20 via-card/20",
+ "w-[350px] max-w-full flex flex-col flex-shrink-0 snap-center rounded-none bg-card/30 border-0 border-r",
{
variants: {
dragging: {
- default: "border-2 border-transparent",
+ default: "",
over: "ring-2 opacity-30",
overlay: "ring-2 ring-primary",
},
@@ -77,7 +69,7 @@ export function ColumnCard({
);
return (
- <Card
+ <div
ref={setNodeRef}
style={style}
className={cn(
@@ -89,7 +81,7 @@ export function ColumnCard({
: `h-[calc(100dvh-var(--header-height)*2)]`
)}
>
- <CardHeader className="p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 bg-card z-1 border-b">
+ <div className="p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 bg-card z-1 border-b">
<div className="flex flex-grow items-start space-x-2">
{column.active ? (
<PulsingDot />
@@ -122,17 +114,18 @@ export function ColumnCard({
{...listeners}
className="cursor-grab relative"
/>
- </CardHeader>
+ </div>
<ScrollArea className="flex-grow">
- <CardContent className="flex flex-col gap-2 p-2">
+ <div className="flex flex-col gap-2 p-2">
<SortableContext items={itemsIds}>
{items.map((item) => (
<ItemCard key={item.id!} item={item} {...displaySettings} />
))}
</SortableContext>
- </CardContent>
+ </div>
+ <ScrollBar orientation="horizontal" />
</ScrollArea>
- </Card>
+ </div>
);
}
diff --git a/apps/mes/app/components/Kanban/components/ItemCard.tsx b/apps/mes/app/components/Kanban/components/ItemCard.tsx
index 64f87a1cb3..ef09fd85a9 100644
--- a/apps/mes/app/components/Kanban/components/ItemCard.tsx
+++ b/apps/mes/app/components/Kanban/components/ItemCard.tsx
@@ -1,10 +1,14 @@
import {
+ Badge,
Card,
CardContent,
+ CardFooter,
CardHeader,
cn,
HStack,
- Progress,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from "@carbon/react";
import {
convertDateStringToIsoString,
@@ -18,6 +22,7 @@ import {
LuCircleCheck,
LuCircleX,
LuClipboardCheck,
+ LuHardHat,
LuSquareUser,
LuTimer,
} from "react-icons/lu";
@@ -30,6 +35,7 @@ import { TodoStatusIcon } from "~/assets/icons/TodoStatusIcon";
import { useRouteData } from "@carbon/remix";
import Avatar from "~/components/Avatar";
+import EmployeeAvatar from "~/components/EmployeeAvatar";
import { DeadlineIcon } from "~/components/Icons";
import { getPrivateUrl, path } from "~/utils/path";
import type { DisplaySettings, Item } from "../types";
@@ -39,17 +45,16 @@ type ItemCardProps = {
} & DisplaySettings;
const cardVariants = cva(
- "dark:bg-gradient-to-tr dark:via-card dark:to-card dark:hover:to-muted/30 dark:hover:via-muted/30 bg-card hover:bg-muted/30",
+ "bg-card hover:bg-muted/30 dark:border-none dark:shadow-[inset_0_0.5px_0_rgb(255_255_255_/_0.08),_inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)]",
{
variants: {
status: {
- "In Progress":
- "border-emerald-600/30 dark:from-emerald-600/10 bg-emerald-600/5",
+ "In Progress": "border-emerald-600/30",
Ready: "",
Done: "",
- Paused: "border-yellow-500/30 dark:from-yellow-500/10 bg-yellow-500/5",
- Canceled: "border-red-500/30 dark:from-red-500/10 bg-red-500/5",
- Waiting: "border-yellow-500/30 dark:from-yellow-500/10 bg-yellow-500/5",
+ Paused: "",
+ Canceled: "border-red-500/30",
+ Waiting: "",
Todo: "border-border",
},
},
@@ -59,23 +64,6 @@ const cardVariants = cva(
}
);
-const cardHeaderVariants = cva("border-b", {
- variants: {
- status: {
- "In Progress": "border-emerald-600/10",
- Ready: "",
- Done: "",
- Paused: "border-yellow-500/10",
- Canceled: "border-red-500/10",
- Waiting: "border-yellow-500/10",
- Todo: "border-border",
- },
- },
- defaultVariants: {
- status: "Todo",
- },
-});
-
export function ItemCard({
item,
showCustomer,
@@ -102,131 +90,135 @@ export function ItemCard({
: false;
return (
- <Link to={path.to.operation(item.id)}>
- <Card
- className={cn(
- "max-w-[330px] shadow-sm dark:shadow-sm",
- cardVariants({
- status: item.status,
- })
- )}
- >
- <CardHeader
- className={cn(
- "max-w-full p-3 border-b relative",
- cardHeaderVariants({
- status: item.status,
- })
- )}
- >
- <div className="flex w-full max-w-full justify-between">
- <div className="flex flex-col space-y-0">
- {item.subtitle && (
- <span className="text-xs text-muted-foreground line-clamp-1">
- {item.subtitle}
- </span>
- )}
- <span className="font-semibold truncate">{item.title}</span>
- </div>
+ <Card
+ className={cn(
+ "max-w-[330px] shadow-sm dark:shadow-sm py-0",
+ cardVariants({
+ status: item.status,
+ })
+ )}
+ >
+ <CardHeader className="-mx-4 relative border-b py-3 px-4 rounded-t-lg">
+ <div className="flex w-full max-w-full justify-between items-start gap-0">
+ <div className="flex flex-col space-y-0 min-w-0">
+ {item.itemReadableId && (
+ <span className="text-xs text-muted-foreground line-clamp-1">
+ {item.itemReadableId}
+ </span>
+ )}
+ <Link
+ to={path.to.operation(item.id)}
+ className="mr-auto font-semibold line-clamp-2 leading-tight"
+ >
+ {item.itemDescription || item.itemReadableId}
+ </Link>
</div>
+ </div>
+ </CardHeader>
- {showProgress &&
- ["Paused", "Done", "In Progress"].includes(item.status!) && (
- <Progress
- indicatorClassName={
- item.status === "Paused" ? "bg-yellow-500" : ""
- }
- numerator={
- item.progress ? formatDurationMilliseconds(item.progress) : ""
- }
- denominator={
- item.duration ? formatDurationMilliseconds(item.duration) : ""
- }
- value={
- item.progress && item.duration
- ? (item.progress / item.duration) * 100
- : 0
- }
- />
- )}
- </CardHeader>
- <CardContent className="p-3 space-y-2 text-left whitespace-pre-wrap text-sm">
- {showThumbnail && item.thumbnailPath && (
- <div className="flex justify-center">
- <img
- src={getPrivateUrl(item.thumbnailPath)}
- alt={item.title}
- className="w-full h-auto"
- />
- </div>
- )}
- {showDescription && item.description && (
- <HStack className="justify-start space-x-2">
- <LuClipboardCheck className="text-muted-foreground" />
- <span className="text-sm line-clamp-1">{item.description}</span>
- </HStack>
- )}
- {showStatus && item.status && (
- <HStack className="justify-start space-x-2">
- {getStatusIcon(item.status)}
- <span className="text-sm">{item.status}</span>
- </HStack>
- )}
- {showDuration && typeof item.duration === "number" && (
- <HStack className="justify-start space-x-2">
- <LuTimer className="text-muted-foreground" />
- <span className="text-sm">
- {formatDurationMilliseconds(item.duration)}
- </span>
- </HStack>
- )}
- {showDueDate && item.deadlineType && (
- <HStack className="justify-start space-x-2">
- <DeadlineIcon
- deadlineType={item.deadlineType}
- overdue={isOverdue}
- />
+ <CardContent className="pt-3 px-1 gap-2 text-left whitespace-pre-wrap text-sm">
+ {showThumbnail && item.thumbnailPath && (
+ <div className="flex justify-center">
+ <img
+ src={getPrivateUrl(item.thumbnailPath)}
+ alt={item.title}
+ className="w-full h-auto rounded-lg"
+ />
+ </div>
+ )}
+ <HStack className="justify-start space-x-2">
+ <LuHardHat className="text-muted-foreground" />
+ <span className="text-sm line-clamp-1">{item.title}</span>
+ </HStack>
- <span className={cn("text-sm", isOverdue ? "text-red-500" : "")}>
- {["ASAP", "No Deadline"].includes(item.deadlineType)
- ? item.deadlineType
- : item.dueDate
- ? `Due ${formatRelativeTime(
- convertDateStringToIsoString(item.dueDate)
- )}`
- : "–"}
- </span>
- </HStack>
- )}
- {showDueDate && item.dueDate && (
+ {showDescription && item.description && (
+ <HStack className="justify-start space-x-2">
+ <LuClipboardCheck className="text-muted-foreground" />
+ <span className="text-sm line-clamp-1">{item.description}</span>
+ </HStack>
+ )}
+ {showStatus && item.status && (
+ <HStack className="justify-start space-x-2">
+ {getStatusIcon(item.status)}
+ <span className="text-sm">{item.status}</span>
+ </HStack>
+ )}
+ {showDuration && typeof item.duration === "number" && (
+ <HStack className="justify-start space-x-2">
+ <LuTimer className="text-muted-foreground" />
+ <span className="text-sm">
+ {formatDurationMilliseconds(item.duration)}
+ </span>
+ </HStack>
+ )}
+ {showDueDate && item.deadlineType && (
+ <HStack className="justify-start space-x-2">
+ <DeadlineIcon
+ deadlineType={item.deadlineType}
+ overdue={isOverdue}
+ />
+ <Tooltip>
+ <TooltipTrigger>
+ <span
+ className={cn("text-sm", isOverdue ? "text-red-500" : "")}
+ >
+ {["ASAP", "No Deadline"].includes(item.deadlineType)
+ ? item.deadlineType
+ : item.dueDate
+ ? `Due ${formatRelativeTime(
+ convertDateStringToIsoString(item.dueDate)
+ )}`
+ : "–"}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="right">{item.deadlineType}</TooltipContent>
+ </Tooltip>
+ </HStack>
+ )}
+ {showDueDate && item.dueDate && (
+ <HStack className="justify-start space-x-2">
+ <LuCalendarDays />
+ <span className="text-sm">{formatDate(item.dueDate)}</span>
+ </HStack>
+ )}
+
+ {showSalesOrder &&
+ item.salesOrderReadableId &&
+ item.salesOrderId &&
+ item.salesOrderLineId && (
<HStack className="justify-start space-x-2">
- <LuCalendarDays />
- <span className="text-sm">{formatDate(item.dueDate)}</span>
+ <RiProgress8Line className="text-muted-foreground" />
+ <span className="text-sm">{item.salesOrderReadableId}</span>
</HStack>
)}
- {showSalesOrder &&
- item.salesOrderReadableId &&
- item.salesOrderId &&
- item.salesOrderLineId && (
- <HStack className="justify-start space-x-2">
- <RiProgress8Line className="text-muted-foreground" />
- <span className="text-sm">{item.salesOrderReadableId}</span>
- </HStack>
- )}
-
- {showCustomer && item.customerId && (
- <HStack className="justify-start space-x-2">
- <LuSquareUser className="text-muted-foreground" />
- <HStack className="truncate no-underline hover:no-underline">
- <Avatar size="xs" name={customer?.name ?? ""} />
- <span>{customer?.name}</span>
- </HStack>
+ {showCustomer && item.customerId && (
+ <HStack className="justify-start space-x-2">
+ <LuSquareUser className="text-muted-foreground" />
+ <HStack className="truncate no-underline hover:no-underline">
+ <Avatar size="xs" name={customer?.name ?? ""} />
+ <span>{customer?.name}</span>
</HStack>
+ </HStack>
+ )}
+ </CardContent>
+ {(item.assignee || (item.tags && item.tags.length > 0)) && (
+ <CardFooter className="bg-accent/50 -mx-4 border-t px-4 py-2 items-center justify-start space-2 rounded-b-lg text-xs flex-wrap">
+ {item.assignee && (
+ <EmployeeAvatar size="xs" employeeId={item.assignee} />
)}
- </CardContent>
- </Card>
- </Link>
+ {item.tags?.map((tag) => (
+ <Badge
+ key={tag}
+ variant="secondary"
+ className="border dark:border-none dark:shadow-button-base"
+ >
+ {tag}
+ </Badge>
+ ))}
+ </CardFooter>
+ )}
+ </Card>
);
}
diff --git a/apps/mes/app/components/Kanban/types.ts b/apps/mes/app/components/Kanban/types.ts
index 201b80a199..3983fd1287 100644
--- a/apps/mes/app/components/Kanban/types.ts
+++ b/apps/mes/app/components/Kanban/types.ts
@@ -31,6 +31,7 @@ export type DraggableData = ColumnDragData | ItemDragData;
const itemValidator = z.object({
id: z.string(),
+ assignee: z.string().optional(),
columnId: z.string(),
columnType: z.string(),
title: z.string(),
@@ -43,11 +44,15 @@ const itemValidator = z.object({
dueDate: z.string().optional(), // 2024-05-28
duration: z.number().optional(), // miliseconds
deadlineType: z.enum(deadlineTypes).optional(),
+ itemDescription: z.string().optional(),
+ itemReadableId: z.string().optional(),
+ jobReadableId: z.string().optional(),
progress: z.number().optional(), // miliseconds
status: z.enum(jobOperationStatus).optional(),
salesOrderReadableId: z.string().optional(),
salesOrderId: z.string().optional(),
salesOrderLineId: z.string().optional(),
+ tags: z.array(z.string()).optional(),
thumbnailPath: z.string().optional(),
});
diff --git a/apps/mes/app/routes/x+/operations.tsx b/apps/mes/app/routes/x+/operations.tsx
index a857bfed05..4959502275 100644
--- a/apps/mes/app/routes/x+/operations.tsx
+++ b/apps/mes/app/routes/x+/operations.tsx
@@ -183,11 +183,12 @@ export async function loader({ request }: LoaderFunctionArgs) {
const operation = makeDurations(op);
return {
id: op.id,
+ assignee: op.assignee,
+ tags: op.tags,
columnId: op.workCenterId,
columnType: op.processId,
priority: op.priority,
title: op.jobReadableId,
-
subtitle: op.itemReadableId,
description: op.description,
dueDate: op.jobDueDate,
@@ -196,6 +197,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
Math.max(operation.laborDuration, operation.machineDuration),
deadlineType: op.jobDeadlineType,
customerId: op.jobCustomerId,
+ jobReadableId: op.jobReadableId,
+ itemReadableId: op.itemReadableId,
+ itemDescription: op.itemDescription,
salesOrderReadableId: op.salesOrderReadableId,
salesOrderId: op.salesOrderId,
salesOrderLineId: op.salesOrderLineId,
@@ -291,13 +295,13 @@ function KanbanSchedule() {
<Heading size="h4">Schedule</Heading>
</div>
</header>
- <div className="flex flex-col h-full max-h-full overflow-auto relative">
+ <div className="flex flex-col h-full max-h-full overflow-auto relative">
<HStack className="px-4 py-2 justify-between bg-card border-b border-border">
<HStack>
<SearchFilter param="search" size="sm" placeholder="Search" />
-
<Filter filters={filters} />
</HStack>
+
<Popover>
<PopoverTrigger asChild>
<Button
@@ -305,105 +309,34 @@ function KanbanSchedule() {
variant="secondary"
className="border-dashed border-border"
>
- Settings
+ Display
</Button>
</PopoverTrigger>
<PopoverContent className="w-48">
<VStack>
- <Switch
- variant="small"
- label="Customer"
- checked={displaySettings.showCustomer}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showCustomer: checked,
- }))
- }
- />
- <Switch
- variant="small"
- label="Description"
- checked={displaySettings.showDescription}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showDescription: checked,
- }))
- }
- />
- <Switch
- variant="small"
- label="Due Date"
- checked={displaySettings.showDueDate}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showDueDate: checked,
- }))
- }
- />
- <Switch
- variant="small"
- label="Duration"
- checked={displaySettings.showDuration}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showDuration: checked,
- }))
- }
- />
- {/* <Switch
- variant="small"
- label="Employee"
- checked={displaySettings.showEmployee}
- onCheckedChange={(checked) => setDisplaySettings(prev => ({...prev, showEmployee: checked}))}
- /> */}
- <Switch
- variant="small"
- label="Progress"
- checked={displaySettings.showProgress}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showProgress: checked,
- }))
- }
- />
- <Switch
- variant="small"
- label="Status"
- checked={displaySettings.showStatus}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showStatus: checked,
- }))
- }
- />
- <Switch
- variant="small"
- label="Sales Order"
- checked={displaySettings.showSalesOrder}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showSalesOrder: checked,
- }))
- }
- />
- <Switch
- variant="small"
- label="Thumbnail"
- checked={displaySettings.showThumbnail}
- onCheckedChange={(checked) =>
- setDisplaySettings((prev) => ({
- ...prev,
- showThumbnail: checked,
- }))
- }
- />
+ {[
+ { key: "showCustomer", label: "Customer" },
+ { key: "showDescription", label: "Description" },
+ { key: "showDueDate", label: "Due Date" },
+ { key: "showDuration", label: "Duration" },
+ { key: "showProgress", label: "Progress" },
+ { key: "showStatus", label: "Status" },
+ { key: "showSalesOrder", label: "Sales Order" },
+ { key: "showThumbnail", label: "Thumbnail" },
+ ].map(({ key, label }) => (
+ <Switch
+ key={key}
+ variant="small"
+ label={label}
+ checked={displaySettings[key as keyof DisplaySettings]}
+ onCheckedChange={(checked) =>
+ setDisplaySettings((prev) => ({
+ ...prev,
+ [key]: checked,
+ }))
+ }
+ />
+ ))}
</VStack>
</PopoverContent>
</Popover>
diff --git a/apps/mes/app/styles/tailwind.css b/apps/mes/app/styles/tailwind.css
index 28a85e7971..4cc78dfbf5 100644
--- a/apps/mes/app/styles/tailwind.css
+++ b/apps/mes/app/styles/tailwind.css
@@ -21,6 +21,28 @@
--header-height: 50px;
--filters-height: 38px;
--controls-width: 240px;
+
+ --base-shadow-color: rgb(0 0 0 / 0.16);
+
+ --button-drop-shadow: rgb(0 0 0 / 0.4);
+ --danger-drop-shadow: rgb(127 29 29 / 0.8);
+ --button-shadow: 0px -1px 0px 0px rgb(255 255 255 / 0.04),
+ 0px 0px 0px 1px rgb(255 255 255 / 0.12), 0px 0px 1px 0px rgb(0 0 0 / 0.04),
+ 0px 2px 2px 0px rgb(0 0 0 / 0.04), 0px 4px 2px 0px rgb(0 0 0 / 0.04),
+ 0px 6px 3px 0px rgb(0 0 0 / 0.04);
+ --popover-shadow: 0px 0px 4px rgba(0, 0, 0, 0.08),
+ 0px 0px 10px rgba(0, 0, 0, 0.12), 0px 0px 24px rgba(0, 0, 0, 0.16),
+ 0px 0px 80px rgba(0, 0, 0, 0.2);
+ --button-base-shadow: 0px 0px 0px 0.5px rgb(0 0 0 / 0.2),
+ 0px 1px 1px -1px rgb(0 0 0 / 0.08), 0px 2px 2px -1px rgb(0 0 0 / 0.08),
+ inset 0px 0.5px 0px rgb(255 255 255 / 0.04),
+ inset 0px 0px 1px 0px rgb(255 255 255 / 0.12),
+ inset 0px -4px 8px -4px rgb(0 0 0 / 0.12);
+ --button-primary-shadow: 0px 1px 1px -1px rgb(0 0 0 / 0.08),
+ 0px 2px 2px -1px rgb(0 0 0 / 0.08), 0px 0px 0px 1px rgb(0 0 0 / 0.06),
+ inset 0px 1px 0px #fff, inset 0px 0px 2px 1px #fff,
+ inset 0px 1px 2px rgb(0 0 0 / 0.06),
+ inset 0px -4px 8px -4px rgb(0 0 0 / 0.06);
}
.dark {
@@ -32,6 +54,26 @@
--sidebar-accent-foreground: 240 4.8% 95.9%;
--sidebar-border: 240 3.7% 15.9%;
--sidebar-ring: 217.2 91.2% 59.8%;
+
+ --button-drop-shadow: rgb(0 0 0 / 0.4);
+ --danger-drop-shadow: rgb(127 29 29 / 0.8);
+ --button-shadow: 0px -1px 0px 0px rgb(255 255 255 / 0.04),
+ 0px 0px 0px 1px rgb(255 255 255 / 0.12), 0px 0px 1px 0px rgb(0 0 0 / 0.04),
+ 0px 2px 2px 0px rgb(0 0 0 / 0.04), 0px 4px 2px 0px rgb(0 0 0 / 0.04),
+ 0px 6px 3px 0px rgb(0 0 0 / 0.04);
+ --popover-shadow: 0px 0px 4px rgba(0, 0, 0, 0.08),
+ 0px 0px 10px rgba(0, 0, 0, 0.12), 0px 0px 24px rgba(0, 0, 0, 0.16),
+ 0px 0px 80px rgba(0, 0, 0, 0.2);
+ --button-base-shadow: 0px 0px 0px 0.5px rgb(0 0 0 / 0.4),
+ 0px 1px 1px -1px rgb(0 0 0 / 0.12), 0px 2px 2px -1px rgb(0 0 0 / 0.12),
+ inset 0px 0.5px 0px rgb(255 255 255 / 0.06),
+ inset 0px 0px 1px 0px rgb(255 255 255 / 0.16),
+ inset 0px -6px 12px -4px rgb(0 0 0 / 0.16);
+ --button-primary-shadow: 0px 1px 1px -1px rgb(0 0 0 / 0.08),
+ 0px 2px 2px -1px rgb(0 0 0 / 0.08), 0px 0px 0px 1px rgb(0 0 0 / 0.06),
+ inset 0px 1px 0px #fff, inset 0px 0px 2px 1px #fff,
+ inset 0px 1px 2px rgb(0 0 0 / 0.06),
+ inset 0px -4px 8px -4px rgb(0 0 0 / 0.06);
}
}
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 1d23052de3..782cb67582 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -32396,6 +32396,8 @@ export type Database = {
machineUnit: Database["public"]["Enums"]["factor"]
operationOrderType: Database["public"]["Enums"]["methodOperationOrder"]
jobMakeMethodId: string
+ assignee: string
+ tags: string[]
jobReadableId: string
jobStatus: Database["public"]["Enums"]["jobStatus"]
jobDueDate: string
@@ -32406,6 +32408,7 @@ export type Database = {
salesOrderLineId: string
parentMaterialId: string
itemReadableId: string
+ itemDescription: string
operationStatus: Database["public"]["Enums"]["jobOperationStatus"]
operationQuantity: number
quantityComplete: number
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 1d23052de3..782cb67582 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -32396,6 +32396,8 @@ export type Database = {
machineUnit: Database["public"]["Enums"]["factor"]
operationOrderType: Database["public"]["Enums"]["methodOperationOrder"]
jobMakeMethodId: string
+ assignee: string
+ tags: string[]
jobReadableId: string
jobStatus: Database["public"]["Enums"]["jobStatus"]
jobDueDate: string
@@ -32406,6 +32408,7 @@ export type Database = {
salesOrderLineId: string
parentMaterialId: string
itemReadableId: string
+ itemDescription: string
operationStatus: Database["public"]["Enums"]["jobOperationStatus"]
operationQuantity: number
quantityComplete: number
diff --git a/packages/database/supabase/migrations/20250120143155_job-operation-assignments.sql b/packages/database/supabase/migrations/20250120143155_job-operation-assignments.sql
index 45c5467662..c73c4c117c 100644
--- a/packages/database/supabase/migrations/20250120143155_job-operation-assignments.sql
+++ b/packages/database/supabase/migrations/20250120143155_job-operation-assignments.sql
@@ -1,2 +1,120 @@
ALTER TABLE "jobOperation" ADD COLUMN "assignee" TEXT REFERENCES "user"("id") ON DELETE SET NULL;
-ALTER TABLE "jobOperation" ADD COLUMN "tags" TEXT[] DEFAULT '{}';
\ No newline at end of file
+ALTER TABLE "jobOperation" ADD COLUMN "tags" TEXT[] DEFAULT '{}';
+
+
+DROP FUNCTION IF EXISTS get_active_job_operations_by_location;
+CREATE OR REPLACE FUNCTION get_active_job_operations_by_location(
+ location_id TEXT,
+ work_center_ids TEXT[]
+)
+RETURNS TABLE (
+ "id" TEXT,
+ "jobId" TEXT,
+ "operationOrder" DOUBLE PRECISION,
+ "priority" DOUBLE PRECISION,
+ "processId" TEXT,
+ "workCenterId" TEXT,
+ "description" TEXT,
+ "setupTime" NUMERIC(10,2),
+ "setupUnit" factor,
+ "laborTime" NUMERIC(10,2),
+ "laborUnit" factor,
+ "machineTime" NUMERIC(10,2),
+ "machineUnit" factor,
+ "operationOrderType" "methodOperationOrder",
+ "jobMakeMethodId" TEXT,
+ "assignee" TEXT,
+ "tags" TEXT[],
+ "jobReadableId" TEXT,
+ "jobStatus" "jobStatus",
+ "jobDueDate" DATE,
+ "jobDeadlineType" "deadlineType",
+ "jobCustomerId" TEXT,
+ "salesOrderReadableId" TEXT,
+ "salesOrderId" TEXT,
+ "salesOrderLineId" TEXT,
+ "parentMaterialId" TEXT,
+ "itemReadableId" TEXT,
+ "itemDescription" TEXT,
+ "operationStatus" "jobOperationStatus",
+ "operationQuantity" NUMERIC(10,2),
+ "quantityComplete" NUMERIC(10,2),
+ "quantityScrapped" NUMERIC(10,2),
+ "thumbnailPath" TEXT
+)
+SECURITY INVOKER
+AS $$
+BEGIN
+ RETURN QUERY
+ WITH relevant_jobs AS (
+ SELECT
+ j."id",
+ j."jobId",
+ j."status",
+ j."dueDate",
+ j."deadlineType",
+ j."customerId",
+ so."salesOrderId" AS "salesOrderReadableId",
+ so."id" AS "salesOrderId",
+ j."salesOrderLineId",
+ mu."thumbnailPath"
+ FROM "job" j
+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"
+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"
+ LEFT JOIN "modelUpload" mu ON mu.id = j."modelUploadId"
+ WHERE j."locationId" = location_id
+ AND (j."status" = 'Ready' OR j."status" = 'In Progress' OR j."status" = 'Paused')
+ )
+ SELECT
+ jo."id",
+ jo."jobId",
+ jo."order" AS "operationOrder",
+ jo."priority",
+ jo."processId",
+ jo."workCenterId",
+ jo."description",
+ jo."setupTime",
+ jo."setupUnit",
+ jo."laborTime",
+ jo."laborUnit",
+ jo."machineTime",
+ jo."machineUnit",
+ jo."operationOrder" AS "operationOrderType",
+ jo."jobMakeMethodId",
+ jo."assignee",
+ jo."tags",
+ rj."jobId" AS "jobReadableId",
+ rj."status" AS "jobStatus",
+ rj."dueDate" AS "jobDueDate",
+ rj."deadlineType" AS "jobDeadlineType",
+ rj."customerId" AS "jobCustomerId",
+ rj."salesOrderReadableId",
+ rj."salesOrderId",
+ rj."salesOrderLineId",
+ jmm."parentMaterialId",
+ i."readableId" as "itemReadableId",
+ i."name" as "itemDescription",
+ CASE
+ WHEN rj."status" = 'Paused' THEN 'Paused'
+ ELSE jo."status"
+ END AS "operationStatus",
+ jo."operationQuantity",
+ jo."quantityComplete",
+ jo."quantityScrapped",
+ CASE
+ WHEN jmm."parentMaterialId" IS NULL THEN COALESCE(rj."thumbnailPath", mu."thumbnailPath")
+ ELSE mu."thumbnailPath"
+ END as "thumbnailPath"
+ FROM "jobOperation" jo
+ JOIN relevant_jobs rj ON rj.id = jo."jobId"
+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id
+ LEFT JOIN "item" i ON jmm."itemId" = i.id
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ WHERE CASE
+ WHEN array_length(work_center_ids, 1) > 0 THEN
+ jo."workCenterId" = ANY(work_center_ids) AND jo."status" != 'Done' AND jo."status" != 'Canceled'
+ ELSE jo."status" != 'Done' AND jo."status" != 'Canceled'
+ END
+ ORDER BY jo."priority";
+END;
+$$ LANGUAGE plpgsql;
\ No newline at end of file
diff --git a/packages/form/src/components/CreatableMultiSelect.tsx b/packages/form/src/components/CreatableMultiSelect.tsx
index ba058749ca..de1a0ea0ec 100644
--- a/packages/form/src/components/CreatableMultiSelect.tsx
+++ b/packages/form/src/components/CreatableMultiSelect.tsx
@@ -6,7 +6,7 @@ import {
FormHelperText,
FormLabel,
} from "@carbon/react";
-import { forwardRef, useEffect } from "react";
+import { forwardRef, useEffect, useMemo } from "react";
import { useControlField, useField } from "../hooks";
@@ -25,56 +25,80 @@ export type CreatableMultiSelectProps = Omit<
const CreatableMultiSelect = forwardRef<
HTMLButtonElement,
CreatableMultiSelectProps
->(({ name, label, helperText, isOptional = false, ...props }, ref) => {
- const { error } = useField(name);
- const [value, setValue] = useControlField<string[] | undefined>(name);
+>(
+ (
+ { name, label, helperText, isOptional = false, options = [], ...props },
+ ref
+ ) => {
+ const { error } = useField(name);
+ const [value, setValue] = useControlField<string[] | undefined>(name);
- useEffect(() => {
- if (props.value !== null && props.value !== undefined)
- setValue(props.value);
- }, [props.value, setValue]);
+ useEffect(() => {
+ if (props.value !== null && props.value !== undefined)
+ setValue(props.value);
+ }, [props.value, setValue]);
- const onChange = (value: string[]) => {
- setValue(value);
- props.onChange?.(value);
- };
+ const onChange = (value: string[]) => {
+ setValue(value);
+ props.onChange?.(value);
+ };
- return (
- <FormControl isInvalid={!!error}>
- {label && (
- <FormLabel htmlFor={name} isOptional={isOptional}>
- {label}
- </FormLabel>
- )}
- {(value ?? []).filter(Boolean).map((selection, index) => (
- <input
- key={`${name}[${index}]`}
- type="hidden"
- name={`${name}[${index}]`}
- value={selection}
+ const sortedOptions = useMemo(() => {
+ // Split options into selected and unselected
+ const selectedOptions = options.filter((opt) =>
+ value?.includes(opt.value)
+ );
+ const unselectedOptions = options.filter(
+ (opt) => !value?.includes(opt.value)
+ );
+
+ // Sort unselected options alphabetically by label
+ const sortedUnselected = [...unselectedOptions].sort((a, b) =>
+ a.label.localeCompare(b.label)
+ );
+
+ // Combine selected options first, followed by sorted unselected options
+ return [...selectedOptions, ...sortedUnselected];
+ }, [options, value]);
+
+ return (
+ <FormControl isInvalid={!!error}>
+ {label && (
+ <FormLabel htmlFor={name} isOptional={isOptional}>
+ {label}
+ </FormLabel>
+ )}
+ {(value ?? []).filter(Boolean).map((selection, index) => (
+ <input
+ key={`${name}[${index}]`}
+ type="hidden"
+ name={`${name}[${index}]`}
+ value={selection}
+ />
+ ))}
+ <CreatableMultiSelectBase
+ ref={ref}
+ {...props}
+ options={sortedOptions}
+ value={value ?? []}
+ onChange={(newValue) => {
+ setValue(newValue ?? []);
+ onChange(newValue ?? []);
+ }}
+ isClearable={isOptional && !props.isReadOnly}
+ label={label}
+ className="w-full"
/>
- ))}
- <CreatableMultiSelectBase
- ref={ref}
- {...props}
- value={(value ?? []).map((v) => v.replace(/"/g, '\\"'))}
- onChange={(newValue) => {
- setValue((newValue ?? []).map((v) => v.replace(/"/g, '\\"') ?? ""));
- onChange((newValue ?? []).map((v) => v.replace(/"/g, '\\"') ?? ""));
- }}
- isClearable={isOptional && !props.isReadOnly}
- label={label}
- className="w-full"
- />
- {error ? (
- <FormErrorMessage>{error}</FormErrorMessage>
- ) : (
- helperText && <FormHelperText>{helperText}</FormHelperText>
- )}
- </FormControl>
- );
-});
+ {error ? (
+ <FormErrorMessage>{error}</FormErrorMessage>
+ ) : (
+ helperText && <FormHelperText>{helperText}</FormHelperText>
+ )}
+ </FormControl>
+ );
+ }
+);
CreatableMultiSelect.displayName = "CreatableMultiSelect";
diff --git a/packages/notifications/src/index.ts b/packages/notifications/src/index.ts
index 3b20f3ff58..4c49126528 100644
--- a/packages/notifications/src/index.ts
+++ b/packages/notifications/src/index.ts
@@ -12,6 +12,7 @@ export enum NotificationWorkflow {
export enum NotificationEvent {
DigitalQuoteResponse = "digital-quote-response",
JobAssignment = "job-assignment",
+ JobOperationAssignment = "job-operation-assignment",
JobOperationMessage = "job-operation-message",
PurchaseInvoiceAssignment = "purchase-invoice-assignment",
PurchaseOrderAssignment = "purchase-order-assignment",
diff --git a/packages/react/src/Badge.tsx b/packages/react/src/Badge.tsx
index 52854f7893..2d31c17ffb 100644
--- a/packages/react/src/Badge.tsx
+++ b/packages/react/src/Badge.tsx
@@ -10,7 +10,7 @@ import { LuX } from "react-icons/lu";
import { cn } from "./utils/cn";
const badgeVariants = cva(
- "inline-flex items-center rounded-md px-2.5 py-0.5 h-6 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 truncate uppercase font-bold text-xs tracking-tight",
+ "inline-flex items-center rounded-md px-2.5 py-0.5 h-6 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase font-bold text-xs truncate tracking-tight",
{
variants: {
variant: {
@@ -44,7 +44,10 @@ export interface BadgeProps
function Badge({ className, variant, ...props }: BadgeProps) {
return (
- <div className={cn(badgeVariants({ variant }), className)} {...props} />
+ <div
+ className={cn(badgeVariants({ variant }), "min-w-0", className)}
+ {...props}
+ />
);
}
@@ -54,7 +57,7 @@ const BadgeCloseButton = forwardRef<
>(({ className, ...props }, ref) => (
<button
className={cn(
- "ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-muted-foreground hover:text-foreground",
+ "ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-muted-foreground hover:text-foreground flex-shrink-0",
className
)}
{...props}
diff --git a/packages/react/src/CreateableMultiSelect.tsx b/packages/react/src/CreateableMultiSelect.tsx
index 66b22f7f35..940db4300a 100644
--- a/packages/react/src/CreateableMultiSelect.tsx
+++ b/packages/react/src/CreateableMultiSelect.tsx
@@ -35,11 +35,13 @@ export type CreatableMultiSelectProps = Omit<
isReadOnly?: boolean;
label?: string;
placeholder?: string;
+ maxPreview?: number;
itemHeight?: number;
showCreateOptionOnEmpty?: boolean;
inline?: (
value: string[],
- options: { value: string; label: string; helper?: string }[]
+ options: { value: string; label: string; helper?: string }[],
+ maxPreview?: number
) => React.ReactNode;
inlineIcon?: React.ReactElement;
onChange: (selected: string[]) => void;
@@ -62,6 +64,7 @@ const CreatableMultiSelect = forwardRef<
label,
className,
itemHeight = 40,
+ maxPreview,
showCreateOptionOnEmpty = true,
inline,
inlineIcon,
@@ -89,8 +92,11 @@ const CreatableMultiSelect = forwardRef<
spacing={1}
>
{isInlinePreview && Array.isArray(value) && value.length > 0 && (
- <span className="flex-grow line-clamp-1">
- {inline(value, options)}
+ <span
+ className="flex-grow line-clamp-1 cursor-pointer"
+ onClick={() => setOpen(true)}
+ >
+ {inline(value, options, maxPreview)}
</span>
)}
@@ -161,7 +167,7 @@ const CreatableMultiSelect = forwardRef<
)}
</PopoverTrigger>
<PopoverContent
- align="start"
+ align="end"
className="min-w-[260px] w-[--radix-popover-trigger-width] p-1"
>
<VirtualizedCommand