refactor timeline store for code splitting (#5926)
This commit is contained in:
parent
b4bbe3a8ba
commit
538e78f135
13 changed files with 56 additions and 50 deletions
|
|
@ -3,6 +3,7 @@ import { createContext, useContext } from "react";
|
|||
export enum ETimeLineTypeType {
|
||||
ISSUE = "ISSUE",
|
||||
MODULE = "MODULE",
|
||||
PROJECT = "PROJECT",
|
||||
}
|
||||
|
||||
export const TimeLineTypeContext = createContext<ETimeLineTypeType | undefined>(undefined);
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ export const handleOrderChange = (
|
|||
// return if dropped outside the list
|
||||
if (sourceBlockIndex === -1 || destinationBlockIndex === -1 || sourceBlockIndex === destinationBlockIndex) return;
|
||||
|
||||
let updatedSortOrder = getBlockById(blockIds[sourceBlockIndex])?.sort_order;
|
||||
let updatedSortOrder = getBlockById(blockIds[sourceBlockIndex])?.sort_order ?? 0;
|
||||
|
||||
// update the sort order to the lowest if dropped at the top
|
||||
if (destinationBlockIndex === 0) updatedSortOrder = getBlockById(blockIds[0])?.sort_order - 1000;
|
||||
if (destinationBlockIndex === 0) updatedSortOrder = (getBlockById(blockIds[0])?.sort_order ?? 0) - 1000;
|
||||
// update the sort order to the highest if dropped at the bottom
|
||||
else if (destinationBlockIndex === blockIds.length)
|
||||
updatedSortOrder = getBlockById(blockIds[blockIds.length - 1])?.sort_order + 1000;
|
||||
updatedSortOrder = (getBlockById(blockIds[blockIds.length - 1])?.sort_order ?? 0) + 1000;
|
||||
// update the sort order to the average of the two adjacent blocks if dropped in between
|
||||
else {
|
||||
const destinationSortingOrder = getBlockById(blockIds[destinationBlockIndex])?.sort_order;
|
||||
const relativeDestinationSortingOrder = getBlockById(blockIds[destinationBlockIndex - 1])?.sort_order;
|
||||
const destinationSortingOrder = getBlockById(blockIds[destinationBlockIndex])?.sort_order ?? 0;
|
||||
const relativeDestinationSortingOrder = getBlockById(blockIds[destinationBlockIndex - 1])?.sort_order ?? 0;
|
||||
|
||||
updatedSortOrder = (destinationSortingOrder + relativeDestinationSortingOrder) / 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export interface IGanttBlock {
|
|||
marginLeft: number;
|
||||
width: number;
|
||||
};
|
||||
sort_order: number;
|
||||
sort_order: number | undefined;
|
||||
start_date: string | undefined;
|
||||
target_date: string | undefined;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue