Added filtering and search to kanban board. BOD-176
This commit is contained in:
@@ -39,7 +39,8 @@ const sortByParentId = (arr) => {
|
||||
return sortedList;
|
||||
};
|
||||
|
||||
export const createBoardData = (AllStatuses, Jobs) => {
|
||||
export const createBoardData = (AllStatuses, Jobs, filter) => {
|
||||
const { search, employeeId } = filter;
|
||||
console.log("==========GENERATING BOARD DATA=============");
|
||||
const boardLanes = {
|
||||
columns: AllStatuses.map((s) => {
|
||||
@@ -50,7 +51,28 @@ export const createBoardData = (AllStatuses, Jobs) => {
|
||||
};
|
||||
}),
|
||||
};
|
||||
const DataGroupedByStatus = _.groupBy(Jobs, (d) => d.status);
|
||||
|
||||
const filteredJobs =
|
||||
(search === "" || !search) && !employeeId
|
||||
? Jobs
|
||||
: Jobs.filter((j) => {
|
||||
let include = false;
|
||||
if (search && search !== "") {
|
||||
include = CheckSearch(search, j);
|
||||
}
|
||||
|
||||
if (!!employeeId) {
|
||||
include =
|
||||
include &&
|
||||
(j.employee_body === employeeId ||
|
||||
j.employee_prep === employeeId ||
|
||||
j.employee_refinish === employeeId);
|
||||
}
|
||||
|
||||
return include;
|
||||
});
|
||||
|
||||
const DataGroupedByStatus = _.groupBy(filteredJobs, (d) => d.status);
|
||||
|
||||
Object.keys(DataGroupedByStatus).map((statusGroupKey) => {
|
||||
boardLanes.columns.find(
|
||||
@@ -62,6 +84,24 @@ export const createBoardData = (AllStatuses, Jobs) => {
|
||||
return boardLanes;
|
||||
};
|
||||
|
||||
const CheckSearch = (search, job) => {
|
||||
console.log("job", job, search);
|
||||
return (
|
||||
(job.ro_number || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.est_number || "")
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase()) ||
|
||||
(job.ownr_fn || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.ownr_ln || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.status || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.v_make_desc || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.v_model_desc || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.clm_no || "").toLowerCase().includes(search.toLowerCase()) ||
|
||||
(job.plate_no || "").toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
};
|
||||
|
||||
// export const updateBoardOnMove = (board, card, source, destination) => {
|
||||
// //Slice from source
|
||||
|
||||
|
||||
Reference in New Issue
Block a user