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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: steps drag handler when editing
Sidwebworks94e9b6169ad4
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsxindex 7b944e5de1..34105dee7f 100644--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx@@ -38,9 +38,16 @@ import {import { Editor } from "@carbon/react/Editor";import { formatRelativeTime } from "@carbon/utils";import { getLocalTimeZone, today } from "@internationalized/date";-import { AnimatePresence, LayoutGroup, motion, Reorder } from "framer-motion";+import type { DragControls } from "framer-motion";+import {+ AnimatePresence,+ LayoutGroup,+ motion,+ Reorder,+ useDragControls+} from "framer-motion";import { nanoid } from "nanoid";-import type { Dispatch, SetStateAction } from "react";+import type { Dispatch, ReactNode, SetStateAction } from "react";import { useEffect, useMemo, useRef, useState } from "react";import { flushSync } from "react-dom";import {@@ -1945,25 +1952,28 @@ function AttributesForm({if (!step) return null;const index = sortOrder.indexOf(stepId);return (- <Reorder.Item+ <DraggableStepItemkey={stepId}- value={stepId}- dragListener={!isDisabled}+ stepId={stepId}+ isDisabled={isDisabled}>- <AttributesListItem- attribute={step}- operationId={operationId}- typeOptions={typeOptions}- isDisabled={isDisabled}- className={- index === sortOrder.length - 1 ? "border-none" : ""- }- configurable={configurable}- rulesByField={rulesByField}- onConfigure={onConfigure}- itemMentions={itemMentions}- />- </Reorder.Item>+ {(dragControls) => (+ <AttributesListItem+ attribute={step}+ operationId={operationId}+ typeOptions={typeOptions}+ isDisabled={isDisabled}+ dragControls={dragControls}+ className={+ index === sortOrder.length - 1 ? "border-none" : ""+ }+ configurable={configurable}+ rulesByField={rulesByField}+ onConfigure={onConfigure}+ itemMentions={itemMentions}+ />+ )}+ </DraggableStepItem>);})}</Reorder.Group>@@ -1978,6 +1988,28 @@ function AttributesForm({);}+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>+ );+}+function AttributesListItem({attribute,operationId,@@ -1987,6 +2019,7 @@ function AttributesListItem({rulesByField,onConfigure,isDisabled = false,+ dragControls,itemMentions}: {attribute: OperationStep;@@ -1997,6 +2030,7 @@ function AttributesListItem({rulesByField: Map<string, ConfigurationRule>;onConfigure?: (c: Configuration) => void;isDisabled?: boolean;+ dragControls?: DragControls;itemMentions: { id: string; label: string }[];}) {const {@@ -2247,7 +2281,11 @@ function AttributesListItem({icon={<LuGripVertical />}variant="ghost"disabled={isDisabled}- className="cursor-grab"+ className="cursor-grab active:cursor-grabbing"+ onPointerDown={(e) => {+ if (!isDisabled && dragControls) dragControls.start(e);+ }}+ style={{ touchAction: "none" }}/><HStack spacing={4} className="flex-1"><div className="bg-muted border rounded-full flex items-center justify-center p-2">diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsxindex ae2610a87f..f9f02809a8 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx@@ -55,9 +55,16 @@ import {} from "@carbon/utils";import { getLocalTimeZone, today } from "@internationalized/date";import { useNumberFormatter } from "@react-aria/i18n";-import { AnimatePresence, LayoutGroup, motion, Reorder } from "framer-motion";+import type { DragControls } from "framer-motion";+import {+ AnimatePresence,+ LayoutGroup,+ motion,+ Reorder,+ useDragControls+} from "framer-motion";import { nanoid } from "nanoid";-import type { Dispatch, SetStateAction } from "react";+import type { Dispatch, ReactNode, SetStateAction } from "react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { flushSync } from "react-dom";import {@@ -1296,22 +1303,25 @@ function StepsForm({if (!step) return null;const index = sortOrder.indexOf(stepId);return (- <Reorder.Item+ <DraggableStepItemkey={stepId}- value={stepId}- dragListener={!isDisabled}+ stepId={stepId}+ isDisabled={isDisabled}>- <StepsListItem- attribute={step}- operationId={operationId}- typeOptions={typeOptions}- isDisabled={isDisabled}- itemMentions={itemMentions}- className={- index === sortOrder.length - 1 ? "border-none" : ""- }- />- </Reorder.Item>+ {(dragControls) => (+ <StepsListItem+ attribute={step}+ operationId={operationId}+ typeOptions={typeOptions}+ isDisabled={isDisabled}+ dragControls={dragControls}+ itemMentions={itemMentions}+ className={+ index === sortOrder.length - 1 ? "border-none" : ""+ }+ />+ )}+ </DraggableStepItem>);})}</Reorder.Group>@@ -1321,11 +1331,34 @@ function StepsForm({);}+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>+ );+}+function StepsListItem({attribute,operationId,typeOptions,isDisabled = false,+ dragControls,itemMentions,className}: {@@ -1333,6 +1366,7 @@ function StepsListItem({operationId: string;typeOptions: { label: JSX.Element; value: string }[];isDisabled?: boolean;+ dragControls?: DragControls;itemMentions: { id: string; label: string }[];className?: string;}) {@@ -1536,7 +1570,11 @@ function StepsListItem({icon={<LuGripVertical />}variant="ghost"disabled={isDisabled}- className="cursor-grab"+ className="cursor-grab active:cursor-grabbing"+ onPointerDown={(e) => {+ if (!isDisabled && dragControls) dragControls.start(e);+ }}+ style={{ touchAction: "none" }}/><HStack spacing={4} className="flex-1"><div className="bg-muted border rounded-full flex items-center justify-center p-2">diff --git a/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx b/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsxindex 9f51deb83d..763fbf955a 100644--- a/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx+++ b/apps/erp/app/modules/production/ui/Procedures/ProcedureExplorer.tsx@@ -45,8 +45,10 @@ import {VStack} from "@carbon/react";import { Editor } from "@carbon/react/Editor";-import { Reorder } from "framer-motion";+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 {@@ -269,19 +271,21 @@ export default function ProcedureExplorer() {disabled={isDisabled}>{sortOrder.map((sortId) => (- <Reorder.Item+ <DraggableStepItemkey={sortId}- value={sortId}- dragListener={!isDisabled}+ stepId={sortId}+ isDisabled={isDisabled}>- <ProcedureStepItem- key={sortId}- isDisabled={isDisabled}- attribute={attributeMap[sortId]}- onDelete={onDeleteAttribute}- onEdit={onEditAttribute}- />- </Reorder.Item>+ {(dragControls) => (+ <ProcedureStepItem+ isDisabled={isDisabled}+ attribute={attributeMap[sortId]}+ onDelete={onDeleteAttribute}+ onEdit={onEditAttribute}+ dragControls={dragControls}+ />+ )}+ </DraggableStepItem>))}</Reorder.Group>) : (@@ -437,18 +441,42 @@ export default function ProcedureExplorer() {);}+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 ProcedureStepProps = {attribute: ProcedureStep;isDisabled: boolean;onEdit: (attribute: ProcedureStep) => void;onDelete: (attribute: ProcedureStep) => void;+ dragControls?: DragControls;};function ProcedureStepItem({attribute,isDisabled,onEdit,- onDelete+ onDelete,+ dragControls}: ProcedureStepProps) {const { id } = useParams();if (!id) throw new Error("Could not find id");@@ -466,7 +494,11 @@ function ProcedureStepItem({icon={<LuGripVertical />}variant="ghost"disabled={isDisabled}- className="cursor-grab"+ className="cursor-grab active:cursor-grabbing"+ onPointerDown={(e) => {+ if (!isDisabled && dragControls) dragControls.start(e);+ }}+ style={{ touchAction: "none" }}/><VStack spacing={0} className="flex-grow"><HStack>diff --git a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsxindex be97bc4f6f..73ddca67e2 100644--- a/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx+++ b/apps/erp/app/modules/quality/ui/Documents/QualityDocumentExplorer.tsx@@ -41,8 +41,10 @@ import {VStack} from "@carbon/react";import { Editor } from "@carbon/react/Editor";-import { Reorder } from "framer-motion";+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 {@@ -201,19 +203,21 @@ export default function QualityDocumentExplorer() {disabled={isDisabled}>{sortOrder.map((sortId) => (- <Reorder.Item+ <DraggableStepItemkey={sortId}- value={sortId}- dragListener={!isDisabled}+ stepId={sortId}+ isDisabled={isDisabled}>- <QualityDocumentStepItem- key={sortId}- isDisabled={isDisabled}- attribute={stepMap[sortId]}- onDelete={onDeleteStep}- onEdit={onEditAttribute}- />- </Reorder.Item>+ {(dragControls) => (+ <QualityDocumentStepItem+ isDisabled={isDisabled}+ attribute={stepMap[sortId]}+ onDelete={onDeleteStep}+ onEdit={onEditAttribute}+ dragControls={dragControls}+ />+ )}+ </DraggableStepItem>))}</Reorder.Group>) : (@@ -282,18 +286,42 @@ export default function QualityDocumentExplorer() {);}+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+ onDelete,+ dragControls}: QualityDocumentStepProps) {const { id } = useParams();if (!id) throw new Error("Could not find id");@@ -311,7 +339,11 @@ function QualityDocumentStepItem({icon={<LuGripVertical />}variant="ghost"disabled={isDisabled}- className="cursor-grab"+ className="cursor-grab active:cursor-grabbing"+ onPointerDown={(e) => {+ if (!isDisabled && dragControls) dragControls.start(e);+ }}+ style={{ touchAction: "none" }}/><VStack spacing={0} className="flex-grow"><HStack>diff --git a/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx b/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsxindex 3aa974622e..b84c52829f 100644--- a/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx+++ b/apps/erp/app/modules/resources/ui/Training/TrainingExplorer.tsx@@ -39,7 +39,9 @@ import {usePrettifyShortcut,VStack} from "@carbon/react";-import { Reorder } from "framer-motion";+import type { DragControls } from "framer-motion";+import { Reorder, useDragControls } from "framer-motion";+import type { ReactNode } from "react";import { useEffect, useMemo, useRef, useState } from "react";import { flushSync } from "react-dom";import {@@ -204,19 +206,21 @@ export default function TrainingExplorer() {disabled={isDisabled}>{sortOrder.map((sortId) => (- <Reorder.Item+ <DraggableStepItemkey={sortId}- value={sortId}- dragListener={!isDisabled}+ stepId={sortId}+ isDisabled={isDisabled}>- <TrainingQuestionItem- key={sortId}- isDisabled={isDisabled}- question={questionMap[sortId]}- onDelete={onDeleteQuestion}- onEdit={onEditQuestion}- />- </Reorder.Item>+ {(dragControls) => (+ <TrainingQuestionItem+ isDisabled={isDisabled}+ question={questionMap[sortId]}+ onDelete={onDeleteQuestion}+ onEdit={onEditQuestion}+ dragControls={dragControls}+ />+ )}+ </DraggableStepItem>))}</Reorder.Group>) : (@@ -310,18 +314,42 @@ function TrainingQuestionTypeIcon({}}+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 TrainingQuestionProps = {question: TrainingQuestion;isDisabled: boolean;onEdit: (question: TrainingQuestion) => void;onDelete: (question: TrainingQuestion) => void;+ dragControls?: DragControls;};function TrainingQuestionItem({question,isDisabled,onEdit,- onDelete+ onDelete,+ dragControls}: TrainingQuestionProps) {const { id } = useParams();if (!id) throw new Error("Could not find id");@@ -340,7 +368,11 @@ function TrainingQuestionItem({icon={<LuGripVertical />}variant="ghost"disabled={isDisabled}- className="cursor-grab"+ className="cursor-grab active:cursor-grabbing"+ onPointerDown={(e) => {+ if (!isDisabled && dragControls) dragControls.start(e);+ }}+ style={{ touchAction: "none" }}/>)}<VStack spacing={0} className="flex-grow">diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsxindex 2568f4c70c..a718e00351 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx@@ -37,9 +37,16 @@ import {import { Editor } from "@carbon/react/Editor";import { formatRelativeTime } from "@carbon/utils";import { getLocalTimeZone, today } from "@internationalized/date";-import { AnimatePresence, LayoutGroup, motion, Reorder } from "framer-motion";+import type { DragControls } from "framer-motion";+import {+ AnimatePresence,+ LayoutGroup,+ motion,+ Reorder,+ useDragControls+} from "framer-motion";import { nanoid } from "nanoid";-import type { Dispatch, SetStateAction } from "react";+import type { Dispatch, ReactNode, SetStateAction } from "react";import { useEffect, useMemo, useRef, useState } from "react";import {LuActivity,@@ -1107,22 +1114,25 @@ function AttributesForm({if (!step) return null;const index = sortOrder.indexOf(stepId);return (- <Reorder.Item+ <DraggableStepItemkey={stepId}- value={stepId}- dragListener={!isDisabled}+ stepId={stepId}+ isDisabled={isDisabled}>- <AttributesListItem- attribute={step}- operationId={operationId}- typeOptions={typeOptions}- isDisabled={isDisabled}- itemMentions={itemMentions}- className={- index === sortOrder.length - 1 ? "border-none" : ""- }- />- </Reorder.Item>+ {(dragControls) => (+ <AttributesListItem+ attribute={step}+ operationId={operationId}+ typeOptions={typeOptions}+ isDisabled={isDisabled}+ dragControls={dragControls}+ itemMentions={itemMentions}+ className={+ index === sortOrder.length - 1 ? "border-none" : ""+ }+ />+ )}+ </DraggableStepItem>);})}</Reorder.Group>@@ -1132,11 +1142,34 @@ function AttributesForm({);}+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>+ );+}+function AttributesListItem({attribute,operationId,typeOptions,isDisabled = false,+ dragControls,itemMentions,className}: {@@ -1144,6 +1177,7 @@ function AttributesListItem({operationId: string;typeOptions: { label: JSX.Element; value: string }[];isDisabled?: boolean;+ dragControls?: DragControls;itemMentions: { id: string; label: string }[];className?: string;}) {@@ -1341,7 +1375,11 @@ function AttributesListItem({icon={<LuGripVertical />}variant="ghost"disabled={isDisabled}- className="cursor-grab"+ className="cursor-grab active:cursor-grabbing"+ onPointerDown={(e) => {+ if (!isDisabled && dragControls) dragControls.start(e);+ }}+ style={{ touchAction: "none" }}/><HStack spacing={4} className="flex-1"><div className="bg-muted border rounded-full flex items-center justify-center p-2">