additional cleanup of kanban utils.

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-08 17:32:20 -05:00
parent 0c7b5087f1
commit c6012f7335

View File

@@ -1,10 +1,10 @@
import _ from "lodash/"; import {groupBy} from "lodash";
const sortByParentId = (arr) => { const sortByParentId = (arr) => {
// return arr.reduce((accumulator, currentValue) => { // return arr.reduce((accumulator, currentValue) => {
// //Find the parent item. // //Find the parent item.
// let item = accumulator.find((x) => x.id === currentValue.kanbanparent); // let item = accumulator.find((x) => x.id === currentValue.kanbanparent);
// //Get index of praent item // //Get index of parent item
// let index = accumulator.indexOf(item); // let index = accumulator.indexOf(item);
// index = index !== -1 ? index + 1 : 0; // index = index !== -1 ? index + 1 : 0;
@@ -12,9 +12,9 @@ const sortByParentId = (arr) => {
// return accumulator; // return accumulator;
// }, []); // }, []);
var parentId = "-1"; let parentId = "-1";
var sortedList = []; const sortedList = [];
var byParentsIdsList = _.groupBy(arr, "kanbanparent"); // Create a new array with objects indexed by parentId const 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]) {
@@ -40,8 +40,7 @@ const sortByParentId = (arr) => {
}; };
export const createBoardData = (AllStatuses, Jobs, filter) => { export const createBoardData = (AllStatuses, Jobs, filter) => {
const { search, employeeId } = filter; const {search, employeeId} = filter;
console.log("==========GENERATING BOARD DATA=============");
const boardLanes = { const boardLanes = {
columns: AllStatuses.map((s) => { columns: AllStatuses.map((s) => {
return { return {
@@ -73,7 +72,7 @@ export const createBoardData = (AllStatuses, Jobs, filter) => {
return include; return include;
}); });
const DataGroupedByStatus = _.groupBy(filteredJobs, (d) => d.status); const DataGroupedByStatus = groupBy(filteredJobs, (d) => d.status);
Object.keys(DataGroupedByStatus).map((statusGroupKey) => { Object.keys(DataGroupedByStatus).map((statusGroupKey) => {
try { try {