- Touch point for working kanbanparents

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-07-18 15:45:11 -04:00
parent 0d0791cc41
commit 118f14ed4c
2 changed files with 73 additions and 92 deletions

View File

@@ -100,23 +100,28 @@ function ProductionBoardKanbanComponent({ data, bodyshop, refetch, insertAuditTr
const targetLane = boardLanes.lanes.find((lane) => lane.id === destination.droppableId);
const sourceLane = boardLanes.lanes.find((lane) => lane.id === source.droppableId);
if (!targetLane || !sourceLane) {
setIsMoving(false);
console.error("Invalid source or destination lane");
return;
}
const sameColumnTransfer = source.droppableId === destination.droppableId;
const sourceCard = getCardByID(boardLanes, draggableId);
const movedCardWillBeFirst = destination.index === 0;
const movedCardWillBeLast = destination.index > targetLane.cards.length - 1;
const movedCardWillBeLast = destination.index >= targetLane.cards.length - 1;
const lastCardInTargetLane = targetLane.cards[targetLane.cards.length - 1];
const oldChildCard = sourceLane.cards[destination.index + 1];
const oldChildCard = sourceLane.cards[source.index + 1];
const newChildCard = movedCardWillBeLast
? null
: targetLane.cards[
sameColumnTransfer
? destination.index - destination.index > 0
? destination.index
: destination.index + 1
? source.index < destination.index
? destination.index + 1
: destination.index
: destination.index
];
@@ -127,12 +132,25 @@ function ProductionBoardKanbanComponent({ data, bodyshop, refetch, insertAuditTr
movedCardNewKanbanParent = "-1";
} else if (movedCardWillBeLast) {
movedCardNewKanbanParent = lastCardInTargetLane.id;
} else if (!!newChildCard) {
} else if (newChildCard) {
movedCardNewKanbanParent = newChildCard.metadata.kanbanparent;
} else {
console.log("==> !!!!!!Couldn't find a parent.!!!! <==");
console.error("==> !!!!!!Couldn't find a parent.!!!! <==");
}
const newChildCardNewParent = newChildCard ? draggableId : null;
console.log({
oldChildCard,
newChildCard,
oldChildCardNewParent,
newChildCardNewParent,
movedCardNewKanbanParent,
sameColumnTransfer,
movedCardWillBeFirst,
movedCardWillBeLast
});
try {
const update = await client.mutate({
mutation: generate_UPDATE_JOB_KANBAN(