Refactor production board with new component BOD-71

This commit is contained in:
Patrick Fic
2020-06-17 16:29:35 -07:00
parent 053e69a624
commit 5cf3b26bb3
21 changed files with 318 additions and 121 deletions

View File

@@ -12,25 +12,29 @@ const sortByParentId = (arr) => {
// return accumulator;
// }, []);
var parentId = null;
var parentId = "-1";
var sortedList = [];
var byParentsIdsList = _.groupBy(arr, "kanbanparent"); // Create a new array with objects indexed by parentId
console.log("sortByParentId -> byParentsIdsList", byParentsIdsList);
while (byParentsIdsList[parentId]) {
sortedList.push(byParentsIdsList[parentId][0]);
parentId = byParentsIdsList[parentId][0].id;
}
if (byParentsIdsList["null"])
byParentsIdsList["null"].map((i) => sortedList.push(i));
return sortedList;
};
export const createBoardData = (AllStatuses, Jobs) => {
console.log("==========GENERATING BOARD DATA=============");
const boardLanes = {
lanes: AllStatuses.map((s) => {
columns: AllStatuses.map((s) => {
return {
id: s,
title: s,
//label: "0",
cards: [],
};
}),
@@ -38,10 +42,29 @@ export const createBoardData = (AllStatuses, Jobs) => {
const DataGroupedByStatus = _.groupBy(Jobs, (d) => d.status);
Object.keys(DataGroupedByStatus).map((statusGroupKey) => {
boardLanes.lanes.find(
boardLanes.columns.find(
(l) => l.id === statusGroupKey
).cards = sortByParentId(DataGroupedByStatus[statusGroupKey]);
});
return boardLanes;
};
// export const updateBoardOnMove = (board, card, source, destination) => {
// //Slice from source
// const sourceCardList = board.columns.find((x) => x.id === source.fromColumnId)
// .cards;
// sourceCardList.slice(source.fromPosition, 0);
// //Splice into destination.
// const destCardList = board.columns.find(
// (x) => x.id === destination.toColumnId
// ).cards;
// console.log("updateBoardOnMove -> destCardList", destCardList);
// destCardList.splice(destination.toPosition, 0, card);
// console.log("updateBoardOnMove -> destCardList", destCardList);
// console.log("board", board);
// return board;
// };