[WEB-5390] refactor: gantt layout support in base layouts (#8089)
This commit is contained in:
parent
a04d3b5c29
commit
cbfdcd5638
20 changed files with 442 additions and 41 deletions
|
|
@ -52,7 +52,7 @@ export interface IRenderProps<T extends IBaseLayoutsBaseItem> extends IItemRende
|
|||
|
||||
// Layout Configuration
|
||||
|
||||
export type TBaseLayoutType = "list" | "kanban";
|
||||
export type TBaseLayoutType = "list" | "kanban" | "gantt";
|
||||
|
||||
export interface IBaseLayoutConfig {
|
||||
key: TBaseLayoutType;
|
||||
|
|
|
|||
6
packages/types/src/base-layouts/gantt/core.ts
Normal file
6
packages/types/src/base-layouts/gantt/core.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export const CORE_GANTT_TIMELINE_TYPE = {
|
||||
ISSUE: "ISSUE",
|
||||
MODULE: "MODULE",
|
||||
PROJECT: "PROJECT",
|
||||
GROUPED: "GROUPED",
|
||||
} as const;
|
||||
1
packages/types/src/base-layouts/gantt/extended.ts
Normal file
1
packages/types/src/base-layouts/gantt/extended.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export const EXTENDED_GANTT_TIMELINE_TYPE = {} as const;
|
||||
78
packages/types/src/base-layouts/gantt/index.ts
Normal file
78
packages/types/src/base-layouts/gantt/index.ts
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import type { ReactNode } from "react";
|
||||
import type { IBaseLayoutsBaseItem, IBaseLayoutsBaseProps } from "../base";
|
||||
import { CORE_GANTT_TIMELINE_TYPE } from "./core";
|
||||
import { EXTENDED_GANTT_TIMELINE_TYPE } from "./extended";
|
||||
|
||||
// Gantt-specific item with date fields
|
||||
export interface IBaseLayoutsGanttItem extends IBaseLayoutsBaseItem {
|
||||
start_date?: string | null;
|
||||
target_date?: string | null;
|
||||
}
|
||||
|
||||
// Block update data (for drag/resize operations)
|
||||
export type TGanttBlockUpdateData = {
|
||||
start_date?: string;
|
||||
target_date?: string;
|
||||
sort_order?: {
|
||||
destinationIndex: number;
|
||||
newSortOrder: number;
|
||||
};
|
||||
};
|
||||
|
||||
// Date update handler for bulk date changes (e.g., dependency updates)
|
||||
export type TGanttDateUpdate = {
|
||||
id: string;
|
||||
start_date?: string;
|
||||
target_date?: string;
|
||||
};
|
||||
|
||||
// Render props specific to Gantt
|
||||
export interface IGanttRenderProps<T extends IBaseLayoutsGanttItem> {
|
||||
renderBlock: (item: T) => ReactNode;
|
||||
renderSidebar?: (item: T) => ReactNode;
|
||||
}
|
||||
|
||||
// Gantt-specific capabilities
|
||||
export interface IGanttCapabilities {
|
||||
enableBlockLeftResize?: boolean | ((itemId: string) => boolean);
|
||||
enableBlockRightResize?: boolean | ((itemId: string) => boolean);
|
||||
enableBlockMove?: boolean | ((itemId: string) => boolean);
|
||||
enableReorder?: boolean | ((itemId: string) => boolean);
|
||||
enableAddBlock?: boolean | ((itemId: string) => boolean);
|
||||
enableSelection?: boolean | ((itemId: string) => boolean);
|
||||
enableDependency?: boolean | ((itemId: string) => boolean);
|
||||
}
|
||||
|
||||
// Gantt display options
|
||||
export type TGanttDisplayOptions = {
|
||||
showAllBlocks?: boolean; // Show blocks even without dates
|
||||
showToday?: boolean; // Highlight today on timeline
|
||||
border?: boolean;
|
||||
title?: string;
|
||||
loaderTitle?: string;
|
||||
quickAdd?: ReactNode;
|
||||
timelineType?: TTimelineType; // Type of timeline to use for store
|
||||
};
|
||||
|
||||
// Main Gantt Layout Props
|
||||
export interface IBaseLayoutsGanttProps<T extends IBaseLayoutsGanttItem>
|
||||
extends Omit<IBaseLayoutsBaseProps<T>, "renderItem" | "enableDragDrop" | "onDrop" | "canDrag">,
|
||||
IGanttRenderProps<T>,
|
||||
IGanttCapabilities,
|
||||
TGanttDisplayOptions {
|
||||
// Handler for block updates (position, dates, order)
|
||||
onBlockUpdate?: (item: T, payload: TGanttBlockUpdateData) => void | Promise<void>;
|
||||
|
||||
// Handler for bulk date updates (dependencies, etc.)
|
||||
onDateUpdate?: (updates: TGanttDateUpdate[]) => void | Promise<void>;
|
||||
}
|
||||
|
||||
export const GANTT_TIMELINE_TYPE = {
|
||||
...CORE_GANTT_TIMELINE_TYPE,
|
||||
...EXTENDED_GANTT_TIMELINE_TYPE,
|
||||
} as const;
|
||||
|
||||
export type TTimelineTypeCore = (typeof CORE_GANTT_TIMELINE_TYPE)[keyof typeof CORE_GANTT_TIMELINE_TYPE];
|
||||
export type TTimelineType =
|
||||
| TTimelineTypeCore
|
||||
| (typeof EXTENDED_GANTT_TIMELINE_TYPE)[keyof typeof EXTENDED_GANTT_TIMELINE_TYPE];
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
export * from "./base";
|
||||
export * from "./list";
|
||||
export * from "./kanban";
|
||||
export * from "./gantt";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue