- Checkpoint, this thing is fast has heck.

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-06-30 21:19:04 -04:00
parent 2f493c63f8
commit 4db2b73397
5 changed files with 167 additions and 116 deletions

View File

@@ -1,13 +1,12 @@
import { SyncOutlined, UnorderedListOutlined } from "@ant-design/icons";
import { useApolloClient } from "@apollo/client";
import Board from "../../components/trello-board/index";
import { Button, Grid, notification, Skeleton, Space, Statistic } from "antd";
import { Button, notification, Skeleton, Space, Statistic } from "antd";
import { PageHeader } from "@ant-design/pro-layout";
import React, { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import styled from "styled-components";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { generate_UPDATE_JOB_KANBAN } from "../../graphql/jobs.queries";
import { insertAuditTrail } from "../../redux/application/application.actions";
@@ -20,7 +19,7 @@ import ProductionBoardCard from "../production-board-kanban-card/production-boar
import ProductionListDetailComponent from "../production-list-detail/production-list-detail.component";
import CardColorLegend from "../production-board-kanban-card/production-board-kanban-card-color-legend.component";
import "./production-board-kanban.styles.scss";
import { createBoardData, createFakeBoardData } from "./production-board-kanban.utils.js";
import { createFakeBoardData, createBoardData } from "./production-board-kanban.utils.js";
import ProductionBoardKanbanSettings from "./production-board-kanban.settings.component.jsx";
const mapStateToProps = createStructuredSelector({
@@ -54,6 +53,7 @@ export function ProductionBoardKanbanComponent({
const [isMoving, setIsMoving] = useState(false);
const orientation = associationSettings?.kanban_settings?.orientation ? "vertical" : "horizontal";
const { t } = useTranslation();
useEffect(() => {
@@ -63,7 +63,7 @@ export function ProductionBoardKanbanComponent({
}, [associationSettings]);
useEffect(() => {
const boardData = createFakeBoardData(
const boardData = createBoardData(
[...bodyshop.md_ro_statuses.production_statuses, ...(bodyshop.md_ro_statuses.additional_board_statuses || [])],
data,
filter
@@ -113,89 +113,88 @@ export function ProductionBoardKanbanComponent({
};
// TODO, refine and use action
const onDragEnd = async (...args) => {
console.dir(args);
const onDragEnd = async ({ type, source, destination, draggableId, ...args }) => {
// //cardId, sourceLaneId, targetLaneId, position, cardDetails
// logImEXEvent("kanban_drag_end");
logImEXEvent("kanban_drag_end");
// Early Gate
if (!type || type !== "lane" || !source || !destination) return;
setIsMoving(true);
const targetLane = boardLanes.lanes.find((lane) => lane.id === destination.droppableId);
const sourceLane = boardLanes.lanes.find((lane) => lane.id === source.droppableId);
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 movedCardIsFirstNewCard = movedCardWillBeFirst && movedCardWillBeLast;
const lastCardInTargetLane = targetLane.cards[targetLane.cards.length - 1];
const oldChildCard = sourceLane.cards[destination.index + 1];
//
// // Early Gate
// if (!type || type !== "lane" || !source || !destination) return;
const newChildCard = movedCardWillBeLast
? null
: targetLane.cards[
sameColumnTransfer
? destination.index - destination.index > 0
? destination.index
: destination.index + 1
: destination.index
];
const oldChildCardNewParent = oldChildCard ? sourceCard.metadata.kanbanparent : null;
//
// setIsMoving(true);
//
// const sameColumnTransfer = source.droppableId === destination.droppableId;
// const targetLane = boardLanes.lanes[Number.parseInt(destination.droppableId)];
// const sourceLane = boardLanes.lanes[Number.parseInt(source.droppableId)];
// const sourceCard = getCardByID(boardLanes, draggableId);
//
// const movedCardWillBeFirst = destination.index === 0;
// const movedCardWillBeLast = destination.index > targetLane.cards.length - 1;
// const movedCardIsFirstNewCard = movedCardWillBeFirst && movedCardWillBeLast;
//
// const lastCardInTargetLane = targetLane.cards[targetLane.cards.length - 1];
//
// const oldChildCard = sourceLane.cards[destination.index + 1];
//
// //
// const newChildCard = movedCardWillBeLast
// ? null
// : targetLane.cards[
// sameColumnTransfer
// ? destination.index - destination.index > 0
// ? destination.index
// : destination.index + 1
// : destination.index
// ];
//
// const oldChildCardNewParent = oldChildCard ? sourceCard.metadata.kanbanparent : null;
//
// let movedCardNewKanbanParent;
// if (movedCardWillBeFirst) {
// movedCardNewKanbanParent = "-1";
// } else if (movedCardWillBeLast) {
// movedCardNewKanbanParent = lastCardInTargetLane.id;
// } else if (!!newChildCard) {
// movedCardNewKanbanParent = newChildCard.metadata.kanbanparent;
// } else {
// console.log("==> !!!!!!Couldn't find a parent.!!!! <==");
// }
// const newChildCardNewParent = newChildCard ? draggableId : null;
// try {
// const update = await client.mutate({
// mutation: generate_UPDATE_JOB_KANBAN(
// oldChildCard ? oldChildCard.id : null,
// oldChildCardNewParent,
// draggableId,
// movedCardNewKanbanParent,
// targetLane.id,
// newChildCard ? newChildCard.id : null,
// newChildCardNewParent
// )
// });
//
// insertAuditTrail({
// jobid: draggableId,
// operation: AuditTrailMapping.jobstatuschange(targetLane.id),
// type: "jobstatuschange"
// });
//
// if (update.errors) {
// notification["error"]({
// message: t("production.errors.boardupdate", {
// message: JSON.stringify(update.errors)
// })
// });
// }
// } catch (error) {
// notification["error"]({
// message: t("production.errors.boardupdate", {
// message: error.message
// })
// });
// } finally {
// setIsMoving(false);
// }
// };
let movedCardNewKanbanParent;
if (movedCardWillBeFirst) {
movedCardNewKanbanParent = "-1";
} else if (movedCardWillBeLast) {
movedCardNewKanbanParent = lastCardInTargetLane.id;
} else if (!!newChildCard) {
movedCardNewKanbanParent = newChildCard.metadata.kanbanparent;
} else {
console.log("==> !!!!!!Couldn't find a parent.!!!! <==");
}
const newChildCardNewParent = newChildCard ? draggableId : null;
try {
const update = await client.mutate({
mutation: generate_UPDATE_JOB_KANBAN(
oldChildCard ? oldChildCard.id : null,
oldChildCardNewParent,
draggableId,
movedCardNewKanbanParent,
targetLane.id,
newChildCard ? newChildCard.id : null,
newChildCardNewParent
)
});
insertAuditTrail({
jobid: draggableId,
operation: AuditTrailMapping.jobstatuschange(targetLane.id),
type: "jobstatuschange"
});
if (update.errors) {
notification["error"]({
message: t("production.errors.boardupdate", {
message: JSON.stringify(update.errors)
})
});
}
} catch (error) {
notification["error"]({
message: t("production.errors.boardupdate", {
message: error.message
})
});
} finally {
setIsMoving(false);
}
};
const totalHrs = useMemo(
() =>

View File

@@ -118,7 +118,6 @@
}
.react-trello-column-header {
padding-bottom: 10px;
font-weight: bold;
}