Fixed disappearing cards on production board.
This commit is contained in:
@@ -2,25 +2,30 @@ import React from "react";
|
|||||||
import { Card, Row, Col } from "antd";
|
import { Card, Row, Col } from "antd";
|
||||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||||
import ProductionAlert from "../production-list-columns/production-list-columns.alert.component";
|
import ProductionAlert from "../production-list-columns/production-list-columns.alert.component";
|
||||||
|
import { EyeFilled } from "@ant-design/icons";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
export default function ProductionBoardCard(card) {
|
export default function ProductionBoardCard(card) {
|
||||||
console.log("card", card);
|
// console.log("card", card);
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
className="react-kanban-card"
|
className='react-kanban-card'
|
||||||
style={{ margin: ".2rem 0rem" }}
|
style={{ margin: ".2rem 0rem" }}
|
||||||
actions={
|
actions={[
|
||||||
<div>
|
<ProductionAlert record={card} key='alert' />,
|
||||||
<ProductionAlert record={card} />
|
<Link to={`/manage/jobs/${card.id}`}>
|
||||||
</div>
|
<EyeFilled key='setting' />
|
||||||
}
|
</Link>,
|
||||||
size="small"
|
]}
|
||||||
|
size='small'
|
||||||
title={`${card.ro_number || card.est_number} - ${card.ownr_ln} - ${
|
title={`${card.ro_number || card.est_number} - ${card.ownr_ln} - ${
|
||||||
card.v_model_yr
|
card.v_model_yr
|
||||||
} ${card.v_make_desc.substring(0, 4) || ""} ${card.v_model_desc || ""}`}
|
} ${card.v_make_desc.substring(0, 4) || ""} ${card.v_model_desc || ""}`}>
|
||||||
>
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={12}></Col>
|
<Col span={12}>
|
||||||
|
<div>{`B: ${card.labhrs || "?"}`}</div>
|
||||||
|
<div>{`R: ${card.labhrs || "?"}`}</div>
|
||||||
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<DateTimeFormatter>{card.scheduled_completion}</DateTimeFormatter>
|
<DateTimeFormatter>{card.scheduled_completion}</DateTimeFormatter>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import { useApolloClient } from "@apollo/react-hooks";
|
import { useApolloClient } from "@apollo/react-hooks";
|
||||||
import Board, { moveCard } from "@lourenci/react-kanban";
|
import Board, { moveCard } from "@lourenci/react-kanban";
|
||||||
import "@lourenci/react-kanban/dist/styles.css";
|
import "@lourenci/react-kanban/dist/styles.css";
|
||||||
import { Card, notification } from "antd";
|
import { notification } from "antd";
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
|
||||||
import { createBoardData } from "./production-board-kanban.utils.js";
|
|
||||||
import { generate_UPDATE_JOB_KANBAN } from "../../graphql/jobs.queries";
|
import { generate_UPDATE_JOB_KANBAN } from "../../graphql/jobs.queries";
|
||||||
import { useTranslation } from "react-i18next";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import ProductionBoardCard from "../production-board-kanban-card/production-board-kanban-card.component";
|
import ProductionBoardCard from "../production-board-kanban-card/production-board-kanban-card.component";
|
||||||
|
import { createBoardData } from "./production-board-kanban.utils.js";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -25,25 +24,45 @@ export function ProductionBoardKanbanComponent({ data, bodyshop }) {
|
|||||||
setBoardLanes(createBoardData(bodyshop.md_ro_statuses.open_statuses, data));
|
setBoardLanes(createBoardData(bodyshop.md_ro_statuses.open_statuses, data));
|
||||||
}, [data, setBoardLanes, bodyshop.md_ro_statuses.open_statuses]);
|
}, [data, setBoardLanes, bodyshop.md_ro_statuses.open_statuses]);
|
||||||
|
|
||||||
|
const findById = (id) => {
|
||||||
|
return id;
|
||||||
|
//return (data && data.find((x) => x.id === id).ro_number) || null;
|
||||||
|
};
|
||||||
|
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
|
|
||||||
const handleDragEnd = async (card, source, destination) => {
|
const handleDragEnd = async (card, source, destination) => {
|
||||||
setBoardLanes(moveCard(boardLanes, source, destination));
|
setBoardLanes(moveCard(boardLanes, source, destination));
|
||||||
|
|
||||||
|
const sameColumnTransfer = source.fromColumnId === destination.toColumnId;
|
||||||
|
|
||||||
const sourceColumn = boardLanes.columns.find(
|
const sourceColumn = boardLanes.columns.find(
|
||||||
(x) => x.id === source.fromColumnId
|
(x) => x.id === source.fromColumnId
|
||||||
);
|
);
|
||||||
const destinationColumn = boardLanes.columns.find(
|
const destinationColumn = boardLanes.columns.find(
|
||||||
(x) => x.id === destination.toColumnId
|
(x) => x.id === destination.toColumnId
|
||||||
);
|
);
|
||||||
|
|
||||||
const movedCardWillBeFirst = destination.toPosition === 0;
|
const movedCardWillBeFirst = destination.toPosition === 0;
|
||||||
|
|
||||||
const movedCardWillBeLast =
|
const movedCardWillBeLast =
|
||||||
destinationColumn.cards.length - destination.toPosition <= 1;
|
destinationColumn.cards.length - destination.toPosition < 1;
|
||||||
|
|
||||||
const lastCardInDestinationColumn =
|
const lastCardInDestinationColumn =
|
||||||
destinationColumn.cards[destinationColumn.cards.length - 1];
|
destinationColumn.cards[destinationColumn.cards.length - 1];
|
||||||
|
|
||||||
const oldChildCard = sourceColumn.cards[source.fromPosition + 1];
|
const oldChildCard = sourceColumn.cards[source.fromPosition + 1];
|
||||||
|
|
||||||
const newChildCard = movedCardWillBeLast
|
const newChildCard = movedCardWillBeLast
|
||||||
? null
|
? null
|
||||||
: destinationColumn.cards[destination.toPosition];
|
: destinationColumn.cards[
|
||||||
|
sameColumnTransfer
|
||||||
|
? source.fromPosition - destination.toPosition > 0
|
||||||
|
? destination.toPosition
|
||||||
|
: destination.toPosition + 1
|
||||||
|
: destination.toPosition
|
||||||
|
];
|
||||||
|
|
||||||
const oldChildCardNewParent = oldChildCard ? card.kanbanparent : null;
|
const oldChildCardNewParent = oldChildCard ? card.kanbanparent : null;
|
||||||
|
|
||||||
let movedCardNewKanbanParent;
|
let movedCardNewKanbanParent;
|
||||||
@@ -59,9 +78,7 @@ export function ProductionBoardKanbanComponent({ data, bodyshop }) {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error("==>!!!!!!Couldn't find a parent.!!!!<==");
|
throw new Error("==>!!!!!!Couldn't find a parent.!!!!<==");
|
||||||
}
|
}
|
||||||
|
|
||||||
const newChildCardNewParent = newChildCard ? card.id : null;
|
const newChildCardNewParent = newChildCard ? card.id : null;
|
||||||
|
|
||||||
const update = await client.mutate({
|
const update = await client.mutate({
|
||||||
mutation: generate_UPDATE_JOB_KANBAN(
|
mutation: generate_UPDATE_JOB_KANBAN(
|
||||||
oldChildCard ? oldChildCard.id : null,
|
oldChildCard ? oldChildCard.id : null,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const sortByParentId = (arr) => {
|
|||||||
var parentId = "-1";
|
var parentId = "-1";
|
||||||
var sortedList = [];
|
var sortedList = [];
|
||||||
var byParentsIdsList = _.groupBy(arr, "kanbanparent"); // Create a new array with objects indexed by parentId
|
var byParentsIdsList = _.groupBy(arr, "kanbanparent"); // Create a new array with objects indexed by parentId
|
||||||
console.log("sortByParentId -> byParentsIdsList", byParentsIdsList);
|
//console.log("sortByParentId -> byParentsIdsList", byParentsIdsList);
|
||||||
|
|
||||||
while (byParentsIdsList[parentId]) {
|
while (byParentsIdsList[parentId]) {
|
||||||
sortedList.push(byParentsIdsList[parentId][0]);
|
sortedList.push(byParentsIdsList[parentId][0]);
|
||||||
@@ -45,6 +45,7 @@ export const createBoardData = (AllStatuses, Jobs) => {
|
|||||||
boardLanes.columns.find(
|
boardLanes.columns.find(
|
||||||
(l) => l.id === statusGroupKey
|
(l) => l.id === statusGroupKey
|
||||||
).cards = sortByParentId(DataGroupedByStatus[statusGroupKey]);
|
).cards = sortByParentId(DataGroupedByStatus[statusGroupKey]);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
return boardLanes;
|
return boardLanes;
|
||||||
|
|||||||
Reference in New Issue
Block a user