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.

refactor(quality): remove the steps sidebar from quality documents (#1566)

Brad Barbind7169ecc4f99
diff --git a/apps/erp/app/components/Layout/Panels.tsx b/apps/erp/app/components/Layout/Panels.tsx
index f783fb9acd..955b4013a7 100644
--- a/apps/erp/app/components/Layout/Panels.tsx
+++ b/apps/erp/app/components/Layout/Panels.tsx
@@ -172,22 +172,29 @@ export function ResizablePanels({
);
}
+ // A layout with no explorer renders no left panel at all -- an always-present
+ // `ResizablePanel` would leave an empty column and a drag handle with nothing
+ // behind it.
return (
<ResizablePanelGroup direction="horizontal">
- <ResizablePanel
- ref={panelRef}
- order={1}
- minSize={10}
- className="bg-card shadow-lg"
- collapsible
- defaultSize={isExplorerCollapsed ? 0 : 20}
- collapsedSize={0}
- onCollapse={() => setIsExplorerCollapsed(true)}
- onExpand={() => setIsExplorerCollapsed(false)}
- >
- {!isExplorerCollapsed && explorer}
- </ResizablePanel>
- <ResizableHandle withHandle />
+ {explorer && (
+ <>
+ <ResizablePanel
+ ref={panelRef}
+ order={1}
+ minSize={10}
+ className="bg-card shadow-lg"
+ collapsible
+ defaultSize={isExplorerCollapsed ? 0 : 20}
+ collapsedSize={0}
+ onCollapse={() => setIsExplorerCollapsed(true)}
+ onExpand={() => setIsExplorerCollapsed(false)}
+ >
+ {!isExplorerCollapsed && explorer}
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ </>
+ )}
<ResizablePanel order={2} className="z-1 relative">
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-hidden w-full">
{content}
diff --git a/apps/erp/app/modules/quality/AGENTS.md b/apps/erp/app/modules/quality/AGENTS.md
index c086b14657..70c767f92b 100644
--- a/apps/erp/app/modules/quality/AGENTS.md
+++ b/apps/erp/app/modules/quality/AGENTS.md
@@ -53,7 +53,7 @@ pnpm --filter @carbon/erp test
| `inspectionSamplingPlan` / `inspectionMeasurement` | Per-inspection resolved feature plans (n/Ac/Re) and per sample × feature readings |
| `itemInspectionDocumentAssignment` | Item × usage slot → inspection document (v1 usage: `Receipt`) |
| `gauge` / `gaugeCalibrationRecord` / `gaugeType` | Measurement instrument tracking |
-| `qualityDocument` / `qualityDocumentStep` | Versioned SOPs with ordered steps |
+| `qualityDocument` / `qualityDocumentStep` | Versioned SOPs. The document body is the editor content; `qualityDocumentStep` rows remain in the schema but have no authoring UI (the steps sidebar was removed) |
| `riskRegister` / `riskRegisters` (view) | Risk/opportunity tracking by source |
## Key Service Functions
diff --git a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx
deleted file mode 100644
index 2f9f602ca0..0000000000
--- a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx
+++ /dev/null
@@ -1,665 +0,0 @@
-import { useCarbon } from "@carbon/auth";
-import {
- Array as ArrayInput,
- Hidden,
- Input,
- Number,
- SelectControlled,
- Submit,
- ValidatedForm
-} from "@carbon/form";
-import { getLogger } from "@carbon/logger";
-import type { JSONContent } from "@carbon/react";
-import {
- Button,
- cn,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuIcon,
- DropdownMenuItem,
- DropdownMenuTrigger,
- HStack,
- IconButton,
- Kbd,
- Label,
- ToggleGroup,
- ToggleGroupItem,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- toast,
- useDebounce,
- useDisclosure,
- useKeyboardShortcuts,
- usePrettifyShortcut,
- VStack
-} from "@carbon/react";
-import { Editor } from "@carbon/react/Editor";
-import { Trans, useLingui } from "@lingui/react/macro";
-import type { DragControls } from "framer-motion";
-import { Reorder, useDragControls } from "framer-motion";
-import { nanoid } from "nanoid";
-import type { ReactNode } from "react";
-import { useEffect, useMemo, useRef, useState } from "react";
-import { flushSync } from "react-dom";
-import {
- LuCirclePlus,
- LuEllipsisVertical,
- LuGripVertical,
- LuMaximize2,
- LuMinimize2,
- LuPencil,
- LuTrash
-} from "react-icons/lu";
-import { useFetcher, useParams } from "react-router";
-import type { z } from "zod";
-import { Empty } from "~/components";
-import { UnitOfMeasure } from "~/components/Form";
-import { ProcedureStepTypeIcon } from "~/components/Icons";
-import { ConfirmDelete } from "~/components/Modals";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
-import { qualityDocumentStepValidator } from "~/modules/quality/quality.models";
-import { procedureStepType } from "~/modules/shared";
-import { getPrivateUrl, path } from "~/utils/path";
-import type { QualityDocument, QualityDocumentStep } from "../../types";
-
-const logger = getLogger("erp", "qualitydocumentexplorer");
-
-export default function QualityDocumentExplorer() {
- const prettifyShortcut = usePrettifyShortcut();
- const { id } = useParams();
- if (!id) throw new Error("Could not find id");
- const documentData = useRouteData<{
- document: QualityDocument;
- versions: QualityDocument[];
- }>(path.to.qualityDocument(id));
- const permissions = usePermissions();
- const sortOrderFetcher = useFetcher<{
- success: boolean;
- }>();
-
- const stepDisclosure = useDisclosure();
- const deleteStepDisclosure = useDisclosure();
-
- const [selectedStep, setSelectedStep] = useState<QualityDocumentStep | null>(
- null
- );
-
- const steps = useMemo(
- () => documentData?.document.qualityDocumentStep ?? [],
- [documentData]
- );
-
- const maxSortOrder =
- steps.reduce((acc, attr) => Math.max(acc, attr.sortOrder), 0) ?? 0;
-
- const qualityDocumentStepInitialValues = {
- id: selectedStep?.id,
- qualityDocumentId: id,
- name: selectedStep?.name ?? "",
- description: selectedStep?.description ?? {},
- type: selectedStep?.type ?? "Task",
- sortOrder: selectedStep?.sortOrder ?? maxSortOrder + 1,
- unitOfMeasureCode: selectedStep?.unitOfMeasureCode ?? "",
- minValue: selectedStep ? (selectedStep?.minValue ?? undefined) : 0,
- maxValue: selectedStep ? (selectedStep?.maxValue ?? undefined) : 0,
- listValues: selectedStep?.listValues ?? []
- };
-
- const isDisabled = documentData?.document?.status !== "Draft";
-
- const [sortOrder, setSortOrder] = useState<string[]>(
- Array.isArray(steps)
- ? steps.sort((a, b) => a.sortOrder - b.sortOrder).map((attr) => attr.id)
- : []
- );
-
- useEffect(() => {
- if (Array.isArray(steps)) {
- const sorted = [...steps]
- .sort((a, b) => a.sortOrder - b.sortOrder)
- .map((attr) => attr.id);
- setSortOrder(sorted);
- }
- }, [steps]);
-
- const onReorder = (newOrder: string[]) => {
- if (isDisabled) return;
-
- const updates: Record<string, number> = {};
- newOrder.forEach((id, index) => {
- updates[id] = index + 1;
- });
- setSortOrder(newOrder);
- updateSortOrder(updates);
- };
-
- const updateSortOrder = useDebounce(
- (updates: Record<string, number>) => {
- let formData = new FormData();
- formData.append("updates", JSON.stringify(updates));
- sortOrderFetcher.submit(formData, {
- method: "post",
- action: path.to.qualityDocumentStepOrder(id)
- });
- },
- 2500,
- true
- );
-
- const onDeleteStep = (step: QualityDocumentStep) => {
- if (isDisabled) return;
- setSelectedStep(step);
- deleteStepDisclosure.onOpen();
- };
-
- const onDeleteCancel = () => {
- setSelectedStep(null);
- deleteStepDisclosure.onClose();
- };
-
- const onEditAttribute = (attribute: QualityDocumentStep) => {
- if (isDisabled) return;
- flushSync(() => {
- setSelectedStep(attribute);
- });
- stepDisclosure.onOpen();
- };
-
- const newStepRef = useRef<HTMLButtonElement>(null);
- useKeyboardShortcuts({
- "Command+Shift+a": (event: KeyboardEvent) => {
- event.stopPropagation();
- if (!isDisabled) {
- newStepRef.current?.click();
- }
- }
- });
-
- const stepMap = useMemo(
- () =>
- steps.reduce<Record<string, QualityDocumentStep>>(
- (acc, attr) => ({ ...acc, [attr.id]: attr }),
- {}
- ) ?? {},
- [steps]
- );
- return (
- <>
- <VStack className="w-full h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] justify-between">
- <VStack
- className="w-full flex-1 overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
- spacing={0}
- >
- {steps && steps.length > 0 ? (
- <Reorder.Group
- axis="y"
- values={sortOrder}
- onReorder={onReorder}
- className="w-full"
- disabled={isDisabled}
- >
- {sortOrder.map((sortId) => (
- <DraggableStepItem
- key={sortId}
- stepId={sortId}
- isDisabled={isDisabled}
- >
- {(dragControls) => (
- <QualityDocumentStepItem
- isDisabled={isDisabled}
- attribute={stepMap[sortId]}
- onDelete={onDeleteStep}
- onEdit={onEditAttribute}
- dragControls={dragControls}
- />
- )}
- </DraggableStepItem>
- ))}
- </Reorder.Group>
- ) : (
- <Empty>
- {permissions.can("update", "quality") && (
- <Button
- isDisabled={isDisabled}
- leftIcon={<LuCirclePlus />}
- variant="secondary"
- onClick={() => {
- flushSync(() => {
- setSelectedStep(null);
- });
- stepDisclosure.onOpen();
- }}
- >
- <Trans>Add Step</Trans>
- </Button>
- )}
- </Empty>
- )}
- </VStack>
- <div className="w-full flex-none border-t border-border p-4">
- <Tooltip>
- <TooltipTrigger className="w-full">
- <Button
- ref={newStepRef}
- className="w-full"
- isDisabled={isDisabled || !permissions.can("update", "quality")}
- leftIcon={<LuCirclePlus />}
- variant="secondary"
- onClick={() => {
- flushSync(() => {
- setSelectedStep(null);
- });
- stepDisclosure.onOpen();
- }}
- >
- <Trans>Add Step</Trans>
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <HStack>
- <span>
- <Trans>Add Step</Trans>
- </span>
- <Kbd>{prettifyShortcut("Command+Shift+a")}</Kbd>
- </HStack>
- </TooltipContent>
- </Tooltip>
- </div>
- </VStack>
- {stepDisclosure.isOpen && (
- <QualityDocumentStepForm
- // @ts-ignore
- initialValues={qualityDocumentStepInitialValues}
- isDisabled={isDisabled}
- onClose={stepDisclosure.onClose}
- />
- )}
- {deleteStepDisclosure.isOpen && selectedStep && (
- <DeleteQualityDocumentStep
- attribute={selectedStep}
- onCancel={onDeleteCancel}
- />
- )}
- </>
- );
-}
-
-function DraggableStepItem({
- stepId,
- isDisabled,
- children
-}: {
- stepId: string;
- isDisabled: boolean;
- children: (dragControls: DragControls) => ReactNode;
-}) {
- const dragControls = useDragControls();
- return (
- <Reorder.Item
- key={stepId}
- value={stepId}
- dragListener={false}
- dragControls={dragControls}
- >
- {children(dragControls)}
- </Reorder.Item>
- );
-}
-
-type QualityDocumentStepProps = {
- attribute: QualityDocumentStep;
- isDisabled: boolean;
- onEdit: (attribute: QualityDocumentStep) => void;
- onDelete: (attribute: QualityDocumentStep) => void;
- dragControls?: DragControls;
-};
-
-function QualityDocumentStepItem({
- attribute,
- isDisabled,
- onEdit,
- onDelete,
- dragControls
-}: QualityDocumentStepProps) {
- const { t } = useLingui();
- const { id } = useParams();
- if (!id) throw new Error("Could not find id");
- const permissions = usePermissions();
- if (!attribute || !attribute.id || !attribute.name) return null;
-
- return (
- <HStack
- className={cn(
- "group w-full p-2 items-center hover:bg-accent/30 relative border-b bg-card"
- )}
- >
- <IconButton
- aria-label={t`Drag handle`}
- icon={<LuGripVertical />}
- variant="ghost"
- disabled={isDisabled}
- className="cursor-grab active:cursor-grabbing"
- onPointerDown={(e) => {
- if (!isDisabled && dragControls) dragControls.start(e);
- }}
- style={{ touchAction: "none" }}
- />
- <VStack spacing={0} className="flex-grow">
- <HStack>
- <Tooltip>
- <TooltipTrigger>
- <ProcedureStepTypeIcon
- type={attribute.type}
- className="flex-shrink-0"
- />
- </TooltipTrigger>
- <TooltipContent side="top">
- <p className="text-foreground text-sm">{attribute.type}</p>
- </TooltipContent>
- </Tooltip>
- <VStack spacing={0} className="flex-grow">
- <HStack>
- <p className="text-foreground text-sm">{attribute.name}</p>
- </HStack>
- {(attribute.minValue !== null || attribute.maxValue !== null) && (
- <p className="text-muted-foreground text-xs">
- {attribute.minValue !== null && attribute.maxValue !== null
- ? `Must be between ${attribute.minValue} and ${attribute.maxValue}`
- : attribute.minValue !== null
- ? `Must be > ${attribute.minValue}`
- : attribute.maxValue !== null
- ? `Must be < ${attribute.maxValue}`
- : null}
- </p>
- )}
- </VStack>
- </HStack>
- </VStack>
- {!isDisabled && (
- <div className="absolute right-2">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- aria-label={t`More`}
- className="opacity-0 group-hover:opacity-100 group-active:opacity-100 data-[state=open]:opacity-100"
- icon={<LuEllipsisVertical />}
- variant="solid"
- onClick={(e) => e.stopPropagation()}
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- onEdit(attribute);
- }}
- >
- <DropdownMenuIcon icon={<LuPencil />} />
- <Trans>Edit Step</Trans>
- </DropdownMenuItem>
- <DropdownMenuItem
- destructive
- disabled={!permissions.can("update", "quality")}
- onClick={(e) => {
- e.stopPropagation();
- onDelete(attribute);
- }}
- >
- <DropdownMenuIcon icon={<LuTrash />} />
- <Trans>Delete Step</Trans>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- )}
- </HStack>
- );
-}
-
-function DeleteQualityDocumentStep({
- attribute,
- onCancel
-}: {
- attribute: QualityDocumentStep;
- onCancel: () => void;
-}) {
- const { id } = useParams();
- if (!id) throw new Error("id not found");
- if (!attribute.id) return null;
-
- return (
- <ConfirmDelete
- action={path.to.deleteQualityDocumentStep(id, attribute.id)}
- name={attribute.name ?? "this attribute"}
- text={`Are you sure you want to delete the attribute: ${attribute.name}? This cannot be undone.`}
- onCancel={onCancel}
- onSubmit={onCancel}
- />
- );
-}
-
-function QualityDocumentStepForm({
- initialValues,
- isDisabled,
- onClose
-}: {
- initialValues: z.infer<typeof qualityDocumentStepValidator>;
- isDisabled: boolean;
- onClose: () => void;
-}) {
- const { t } = useLingui();
- const { id: qualityDocumentId } = useParams();
- if (!qualityDocumentId) throw new Error("id not found");
-
- const [type, setType] = useState<QualityDocumentStep["type"]>(
- initialValues.type
- );
-
- const [numericControls, setNumericControls] = useState<string[]>(() => {
- const controls = [];
- if (initialValues.type === "Measurement") {
- if (initialValues.minValue !== null) {
- controls.push("min");
- }
- if (initialValues.maxValue !== null) {
- controls.push("max");
- }
- }
- return controls;
- });
-
- // Fix for JSON parsing error - safely parse description or use empty object
- const [description, setDescription] = useState<JSONContent>(() => {
- try {
- // Handle both string and object cases
- if (typeof initialValues.description === "string") {
- return JSON.parse(initialValues.description || "{}") as JSONContent;
- } else if (
- initialValues.description &&
- typeof initialValues.description === "object"
- ) {
- return initialValues.description as JSONContent;
- }
- return {} as JSONContent;
- } catch (e) {
- logger.error("Error parsing description", { error: e });
- return {} as JSONContent;
- }
- });
-
- const { carbon } = useCarbon();
- const {
- company: { id: companyId }
- } = useUser();
-
- const fetcher = useFetcher<{
- success: boolean;
- }>();
-
- useEffect(() => {
- if (fetcher.data?.success) {
- onClose();
- }
- }, [fetcher.data?.success, onClose]);
-
- const typeOptions = useMemo(
- () =>
- procedureStepType.map((type) => ({
- label: (
- <HStack>
- <ProcedureStepTypeIcon type={type} className="mr-2" />
- {type}
- </HStack>
- ),
- value: type
- })),
- []
- );
-
- const isEditing = !!initialValues.id;
-
- const onUploadImage = async (file: File) => {
- const fileType = file.name.split(".").pop();
- const fileName = `${companyId}/parts/${nanoid()}.${fileType}`;
-
- const result = await carbon?.storage.from("private").upload(fileName, file);
-
- if (result?.error) {
- toast.error(t`Failed to upload image`);
- throw new Error(result.error.message);
- }
-
- if (!result?.data) {
- throw new Error("Failed to upload image");
- }
-
- return getPrivateUrl(result.data.path);
- };
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) {
- onClose();
- }
- }}
- >
- <DrawerContent position="left">
- <ValidatedForm
- method="post"
- action={
- isEditing
- ? path.to.qualityDocumentStep(
- qualityDocumentId,
- initialValues.id!
- )
- : path.to.newQualityDocumentStep(qualityDocumentId)
- }
- defaultValues={initialValues}
- validator={qualityDocumentStepValidator}
- fetcher={fetcher}
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>{isEditing ? t`Edit Step` : t`Add Step`}</DrawerTitle>
- </DrawerHeader>
- <DrawerBody>
- <Hidden name="qualityDocumentId" />
- <Hidden name="sortOrder" />
- <Hidden name="id" />
- <Hidden name="description" value={JSON.stringify(description)} />
- <VStack spacing={4}>
- <SelectControlled
- name="type"
- label={t`Type`}
- options={typeOptions}
- value={type}
- onChange={(option) => {
- if (option) {
- setType(option.value as QualityDocumentStep["type"]);
- }
- }}
- />
- <Input name="name" label={t`Name`} />
- <VStack spacing={2} className="w-full">
- <Label>
- <Trans>Description</Trans>
- </Label>
- <Editor
- initialValue={description}
- onUpload={onUploadImage}
- onChange={(value) => {
- setDescription(value);
- }}
- className="[&_.is-empty]:text-muted-foreground min-h-[120px] p-4 rounded-lg border w-full"
- />
- </VStack>
- {type === "Measurement" && (
- <>
- <UnitOfMeasure
- name="unitOfMeasureCode"
- label={t`Unit of Measure`}
- />
-
- <ToggleGroup
- type="multiple"
- value={numericControls}
- onValueChange={setNumericControls}
- className="justify-start"
- >
- <ToggleGroupItem value="min">
- <LuMinimize2 className="mr-2" /> Minimum
- </ToggleGroupItem>
- <ToggleGroupItem value="max">
- <LuMaximize2 className="mr-2" /> Maximum
- </ToggleGroupItem>
- </ToggleGroup>
-
- {numericControls.includes("min") && (
- <Number
- name="minValue"
- label={t`Minimum`}
- formatOptions={{
- minimumFractionDigits: 0,
- maximumFractionDigits: 10
- }}
- />
- )}
- {numericControls.includes("max") && (
- <Number
- name="maxValue"
- label={t`Maximum`}
- formatOptions={{
- minimumFractionDigits: 0,
- maximumFractionDigits: 10
- }}
- />
- )}
- </>
- )}
- {type === "List" && (
- <ArrayInput name="listValues" label={t`List Options`} />
- )}
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <Button variant="secondary" onClick={onClose}>
- <Trans>Cancel</Trans>
- </Button>
- <Submit isDisabled={isDisabled}>
- <Trans>Save</Trans>
- </Submit>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-}
diff --git a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentHeader.tsx b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentHeader.tsx
index 6dd9328d02..4ff72cdfa6 100644
--- a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentHeader.tsx
+++ b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentHeader.tsx
@@ -23,7 +23,6 @@ import {
LuCheckCheck,
LuClipboardCheck,
LuEllipsisVertical,
- LuPanelLeft,
LuPanelRight,
LuTrash,
LuX
@@ -57,7 +56,7 @@ const QualityDocumentHeader = () => {
const { t } = useLingui();
const permissions = usePermissions();
- const { toggleExplorer, toggleProperties } = usePanels();
+ const { toggleProperties } = usePanels();
// Live title from the editor's locked title block, so the header updates as
// the user types (before the loader revalidates).
const liveTitle = useDocumentStore((s) => s.liveTitle);
@@ -121,12 +120,6 @@ const QualityDocumentHeader = () => {
<div className="flex flex-shrink-0 items-center justify-between gap-x-4 px-4 py-2 bg-card border-b border-border h-[var(--header-height)] overflow-x-auto scrollbar-hide">
<VStack spacing={0} className="flex-grow">
<HStack>
- <IconButton
- aria-label={t`Toggle Explorer`}
- icon={<LuPanelLeft />}
- onClick={toggleExplorer}
- variant="ghost"
- />
<Heading size="h4" className="flex items-center gap-2">
<span>{displayName}</span>
<Badge variant="outline">V{routeData?.document?.version}</Badge>
diff --git a/apps/erp/app/routes/x+/quality-document+/$id.steps.$stepId.tsx b/apps/erp/app/routes/x+/quality-document+/$id.steps.$stepId.tsx
deleted file mode 100644
index 1f8efc617d..0000000000
--- a/apps/erp/app/routes/x+/quality-document+/$id.steps.$stepId.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { assertIsPost, error, notFound } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validator } from "@carbon/form";
-import type { ActionFunctionArgs } from "react-router";
-import { data } from "react-router";
-import { qualityDocumentStepValidator } from "~/modules/quality/quality.models";
-import { upsertQualityDocumentStep } from "~/modules/quality/quality.service";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "quality"
- });
-
- const { stepId } = params;
- if (!stepId) throw notFound("step id is not found");
-
- const validation = await validator(qualityDocumentStepValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return data(
- { success: false },
- await flash(request, error(validation.error, "Failed to update step"))
- );
- }
-
- const update = await upsertQualityDocumentStep(client, {
- id: stepId,
- ...validation.data,
- updatedBy: userId
- });
- if (update.error) {
- return data(
- { success: false },
- await flash(
- request,
- error(update.error, "Failed to update procedure step")
- )
- );
- }
-
- return { success: true };
-}
diff --git a/apps/erp/app/routes/x+/quality-document+/$id.steps.delete.$stepId.tsx b/apps/erp/app/routes/x+/quality-document+/$id.steps.delete.$stepId.tsx
deleted file mode 100644
index 0618282664..0000000000
--- a/apps/erp/app/routes/x+/quality-document+/$id.steps.delete.$stepId.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import type { ActionFunctionArgs } from "react-router";
-import { data } from "react-router";
-import { deleteQualityDocumentStep } from "~/modules/quality/quality.service";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- delete: "quality"
- });
-
- const { stepId } = params;
-
- if (!stepId) throw new Error("stepId is not found");
-
- const deleteStep = await deleteQualityDocumentStep(client, stepId, companyId);
- if (deleteStep.error) {
- return data(
- {
- success: false
- },
- await flash(request, error(deleteStep.error, "Failed to delete step"))
- );
- }
-
- return data(
- {
- success: true
- },
- await flash(request, success("Successfully deleted step"))
- );
-}
diff --git a/apps/erp/app/routes/x+/quality-document+/$id.steps.new.tsx b/apps/erp/app/routes/x+/quality-document+/$id.steps.new.tsx
deleted file mode 100644
index f5bbc5ebbc..0000000000
--- a/apps/erp/app/routes/x+/quality-document+/$id.steps.new.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { assertIsPost, error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validator } from "@carbon/form";
-import type { ActionFunctionArgs } from "react-router";
-import { data } from "react-router";
-import { qualityDocumentStepValidator } from "~/modules/quality/quality.models";
-import { upsertQualityDocumentStep } from "~/modules/quality/quality.service";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- create: "quality"
- });
-
- const { id: qualityDocumentId } = params;
- if (!qualityDocumentId) throw new Error("id is not found");
-
- const validation = await validator(qualityDocumentStepValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return data(
- { success: false },
- await flash(request, error(validation.error, "Failed to create step"))
- );
- }
-
- // biome-ignore lint/correctness/noUnusedVariables: suppressed due to migration
- const { id, ...rest } = validation.data;
-
- const create = await upsertQualityDocumentStep(client, {
- ...rest,
- companyId,
- createdBy: userId
- });
- if (create.error) {
- return data(
- {
- success: false
- },
- await flash(
- request,
- error(create.error, "Failed to insert quality document step")
- )
- );
- }
-
- return { success: true };
-}
diff --git a/apps/erp/app/routes/x+/quality-document+/$id.steps.order.tsx b/apps/erp/app/routes/x+/quality-document+/$id.steps.order.tsx
deleted file mode 100644
index 2763ca766d..0000000000
--- a/apps/erp/app/routes/x+/quality-document+/$id.steps.order.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { assertIsPost, error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import type { ActionFunctionArgs } from "react-router";
-import { data } from "react-router";
-
-import { updateQualityDocumentStepOrder } from "~/modules/quality";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "quality"
- });
-
- const updateMap = (await request.formData()).get("updates") as string;
- if (!updateMap) {
- return data(
- {},
- await flash(request, error(null, "Failed to receive a new sort order"))
- );
- }
-
- const updates = Object.entries(JSON.parse(updateMap)).map(
- ([id, sortOrderString]) => ({
- id,
- sortOrder: Number(sortOrderString),
- updatedBy: userId
- })
- );
-
- const updateSortOrders = await updateQualityDocumentStepOrder(
- client,
- updates
- );
- if (updateSortOrders.some((update) => update.error))
- return data(
- {},
- await flash(
- request,
- error(updateSortOrders, "Failed to update sort order")
- )
- );
-
- return null;
-}
diff --git a/apps/erp/app/routes/x+/quality-document+/$id.tsx b/apps/erp/app/routes/x+/quality-document+/$id.tsx
index ab0b8a1bcf..0f89114063 100644
--- a/apps/erp/app/routes/x+/quality-document+/$id.tsx
+++ b/apps/erp/app/routes/x+/quality-document+/$id.tsx
@@ -18,7 +18,6 @@ import {
qualityDocumentApprovalValidator
} from "~/modules/quality";
import QualityDocumentEditor from "~/modules/quality/ui/Documents/QualityDocumentEditor";
-import QualityDocumentExplorer from "~/modules/quality/ui/Documents/QualityDocumentExplorer";
import QualityDocumentHeader from "~/modules/quality/ui/Documents/QualityDocumentHeader";
import QualityDocumentProperties from "~/modules/quality/ui/Documents/QualityDocumentProperties";
import {
@@ -269,11 +268,6 @@ export default function QualityDocumentRoute() {
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-hidden w-full">
<div className="flex flex-grow overflow-hidden">
<ResizablePanels
- explorer={
- <QualityDocumentExplorer
- key={`explorer-${id}-${document.version}`}
- />
- }
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<QualityDocumentEditor />
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 9fd5e30f6a..1a2e255e11 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -803,8 +803,6 @@ export const path = {
generatePath(`${x}/purchasing-rfq/${id}/${lineId}/delete`),
deleteQualityDocument: (id: string) =>
generatePath(`${x}/quality-document/delete/${id}`),
- deleteQualityDocumentStep: (id: string, stepId: string) =>
- generatePath(`${x}/quality-document/${id}/steps/delete/${stepId}`),
deleteQuote: (id: string) => generatePath(`${x}/quote/${id}/delete`),
deleteQuoteLine: (id: string, lineId: string) =>
generatePath(`${x}/quote/${id}/${lineId}/delete`),
@@ -1588,8 +1586,6 @@ export const path = {
newPurchasingRFQLine: (id: string) =>
generatePath(`${x}/purchasing-rfq/${id}/new`),
newQualityDocument: `${x}/quality/documents/new`,
- newQualityDocumentStep: (id: string) =>
- generatePath(`${x}/quality-document/${id}/steps/new`),
newQuote: `${x}/quote/new`,
newQuoteLine: (id: string) => generatePath(`${x}/quote/${id}/new`),
newQuoteLineCost: (id: string, lineId: string) =>
@@ -1848,10 +1844,6 @@ export const path = {
qualityActions: `${x}/quality/actions`,
qualityDocument: (id: string) =>
generatePath(`${x}/quality-document/${id}`),
- qualityDocumentStep: (id: string, attributeId: string) =>
- generatePath(`${x}/quality-document/${id}/steps/${attributeId}`),
- qualityDocumentStepOrder: (id: string) =>
- generatePath(`${x}/quality-document/${id}/steps/order`),
qualityDocuments: `${x}/quality/documents`,
qualitySettings: `${x}/settings/quality`,
quote: (id: string) => generatePath(`${x}/quote/${id}`),
diff --git a/docs/content/docs/reference/inspections.mdx b/docs/content/docs/reference/inspections.mdx
index 5369ad83cd..d7a7164e9f 100644
--- a/docs/content/docs/reference/inspections.mdx
+++ b/docs/content/docs/reference/inspections.mdx
@@ -87,7 +87,7 @@ Sampling decides *how many* to inspect. An **inspection template** decides *what
<Field name="Inspection">A nested inspection reference.</Field>
</FieldTable>
-The step validator (`qualityDocumentStepValidator`, `quality.models.ts:591`) enforces the type-specific rules: a **Measurement** step must have a unit of measure, a **List** step must have at least one non-empty option, and when both `minValue` and `maxValue` are set the max must be greater than or equal to the min. This same step model backs versioned quality documents (SOPs and work instructions), so an inspection template and a procedure share their building blocks.
+The step validator (`qualityDocumentStepValidator`, `quality.models.ts:591`) enforces the type-specific rules: a **Measurement** step must have a unit of measure, a **List** step must have at least one non-empty option, and when both `minValue` and `maxValue` are set the max must be greater than or equal to the min.
## FAI, inspection documents, and balloons
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index a80701d66d..ad125010ff 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Versandmethode löschen"
msgid "Delete step"
msgstr "Schritt löschen"
-msgid "Delete Step"
-msgstr "Schritt löschen"
-
msgid "Delete Stock Transfer"
msgstr "Bestandsübertragung löschen"
@@ -6101,9 +6098,6 @@ msgstr "Versandmethode bearbeiten"
msgid "Edit Size"
msgstr "Größe bearbeiten"
-msgid "Edit Step"
-msgstr "Schritt bearbeiten"
-
msgid "Edit Stock Transfer"
msgstr "Lagertransfer bearbeiten"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index fcdb598c51..d12148643d 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Delete Shipping Method"
msgid "Delete step"
msgstr "Delete step"
-msgid "Delete Step"
-msgstr "Delete Step"
-
msgid "Delete Stock Transfer"
msgstr "Delete Stock Transfer"
@@ -6101,9 +6098,6 @@ msgstr "Edit Shipping Method"
msgid "Edit Size"
msgstr "Edit Size"
-msgid "Edit Step"
-msgstr "Edit Step"
-
msgid "Edit Stock Transfer"
msgstr "Edit Stock Transfer"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index c3b804f996..103766e912 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Eliminar Método de Envío"
msgid "Delete step"
msgstr "Eliminar paso"
-msgid "Delete Step"
-msgstr "Eliminar Paso"
-
msgid "Delete Stock Transfer"
msgstr "Eliminar Transferencia de Inventario"
@@ -6101,9 +6098,6 @@ msgstr "Editar Método de Envío"
msgid "Edit Size"
msgstr "Editar Tamaño"
-msgid "Edit Step"
-msgstr "Editar Paso"
-
msgid "Edit Stock Transfer"
msgstr "Editar Transferencia de Inventario"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 2a7386481a..a847d2ba8b 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Supprimer le mode d'expédition"
msgid "Delete step"
msgstr "Supprimer l'étape"
-msgid "Delete Step"
-msgstr "Supprimer l'étape"
-
msgid "Delete Stock Transfer"
msgstr "Supprimer le transfert de stock"
@@ -6101,9 +6098,6 @@ msgstr "Modifier le mode d'expédition"
msgid "Edit Size"
msgstr "Modifier la taille"
-msgid "Edit Step"
-msgstr "Modifier l'étape"
-
msgid "Edit Stock Transfer"
msgstr "Modifier le transfert de stock"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 9b2d62186a..b5575c9903 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -5242,9 +5242,6 @@ msgstr "शिपिंग विधि हटाएं"
msgid "Delete step"
msgstr "चरण हटाएं"
-msgid "Delete Step"
-msgstr "चरण हटाएँ"
-
msgid "Delete Stock Transfer"
msgstr "स्टॉक ट्रांसफर हटाएं"
@@ -6101,9 +6098,6 @@ msgstr "शिपिंग विधि संपादित करें"
msgid "Edit Size"
msgstr "आकार संपादित करें"
-msgid "Edit Step"
-msgstr "चरण संपादित करें"
-
msgid "Edit Stock Transfer"
msgstr "स्टॉक ट्रांसफर संपादित करें"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 3ba498c30f..aef94a73d3 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Elimina Metodo di Spedizione"
msgid "Delete step"
msgstr "Elimina passaggio"
-msgid "Delete Step"
-msgstr "Elimina Passaggio"
-
msgid "Delete Stock Transfer"
msgstr "Elimina Trasferimento Magazzino"
@@ -6101,9 +6098,6 @@ msgstr "Modifica Metodo di Spedizione"
msgid "Edit Size"
msgstr "Modifica Dimensione"
-msgid "Edit Step"
-msgstr "Modifica Passaggio"
-
msgid "Edit Stock Transfer"
msgstr "Modifica Trasferimento Magazzino"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index ee97831e8b..eaf875a1e5 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -5242,9 +5242,6 @@ msgstr "出荷方法を削除"
msgid "Delete step"
msgstr "ステップを削除"
-msgid "Delete Step"
-msgstr "ステップを削除"
-
msgid "Delete Stock Transfer"
msgstr "在庫移動を削除"
@@ -6101,9 +6098,6 @@ msgstr "出荷方法を編集"
msgid "Edit Size"
msgstr "サイズを編集"
-msgid "Edit Step"
-msgstr "ステップを編集"
-
msgid "Edit Stock Transfer"
msgstr "在庫移動を編集"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index de43103f50..c11d9bc7b9 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -5242,9 +5242,6 @@ msgstr "배송 방법 삭제"
msgid "Delete step"
msgstr "단계 삭제"
-msgid "Delete Step"
-msgstr "단계 삭제"
-
msgid "Delete Stock Transfer"
msgstr "재고 이동 삭제"
@@ -6101,9 +6098,6 @@ msgstr "배송 방법 편집"
msgid "Edit Size"
msgstr "크기 편집"
-msgid "Edit Step"
-msgstr "단계 편집"
-
msgid "Edit Stock Transfer"
msgstr "재고 이송 편집"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 89992a29b2..02a73d197b 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Usuń sposób wysyłki"
msgid "Delete step"
msgstr "Usuń krok"
-msgid "Delete Step"
-msgstr "Usuń krok"
-
msgid "Delete Stock Transfer"
msgstr "Usuń transfer magazynowy"
@@ -6101,9 +6098,6 @@ msgstr "Edytuj sposób wysyłki"
msgid "Edit Size"
msgstr "Edytuj rozmiar"
-msgid "Edit Step"
-msgstr "Edytuj krok"
-
msgid "Edit Stock Transfer"
msgstr "Edytuj Transfer Zapasów"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 50240c4bb3..e6d53fcd62 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Excluir Método de envio"
msgid "Delete step"
msgstr "Excluir etapa"
-msgid "Delete Step"
-msgstr "Excluir Etapa"
-
msgid "Delete Stock Transfer"
msgstr "Excluir Transferência de estoque"
@@ -6101,9 +6098,6 @@ msgstr "Editar Método de Envio"
msgid "Edit Size"
msgstr "Editar Tamanho"
-msgid "Edit Step"
-msgstr "Editar Etapa"
-
msgid "Edit Stock Transfer"
msgstr "Editar Transferência de Estoque"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 43199a95c6..3932eea98f 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Удалить способ доставки"
msgid "Delete step"
msgstr "Удалить шаг"
-msgid "Delete Step"
-msgstr "Удалить шаг"
-
msgid "Delete Stock Transfer"
msgstr "Удалить передачу запасов"
@@ -6101,9 +6098,6 @@ msgstr "Изменить Способ доставки"
msgid "Edit Size"
msgstr "Изменить Размер"
-msgid "Edit Step"
-msgstr "Изменить Шаг"
-
msgid "Edit Stock Transfer"
msgstr "Изменить Перемещение запаса"
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 107df343fc..059c56fd03 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -5242,9 +5242,6 @@ msgstr "Sevkiyat Yöntemini Sil"
msgid "Delete step"
msgstr "Adımı sil"
-msgid "Delete Step"
-msgstr "Adımı Sil"
-
msgid "Delete Stock Transfer"
msgstr "Stok Transferini Sil"
@@ -6101,9 +6098,6 @@ msgstr "Sevkiyat Yöntemi Düzenle"
msgid "Edit Size"
msgstr "Boyut Düzenle"
-msgid "Edit Step"
-msgstr "Adımı Düzenle"
-
msgid "Edit Stock Transfer"
msgstr "Stok Transfer Düzenle"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 84d7eccb71..c9db36bb0e 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -5242,9 +5242,6 @@ msgstr "删除发货方式"
msgid "Delete step"
msgstr "删除步骤"
-msgid "Delete Step"
-msgstr "删除步骤"
-
msgid "Delete Stock Transfer"
msgstr "删除库存转移"
@@ -6101,9 +6098,6 @@ msgstr "编辑 发货方式"
msgid "Edit Size"
msgstr "编辑尺寸"
-msgid "Edit Step"
-msgstr "编辑步骤"
-
msgid "Edit Stock Transfer"
msgstr "编辑库存转移"