2024-06-04 05:42:24 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-02-12 09:38:17 +00:00
|
|
|
// components
|
2024-06-04 05:42:24 +00:00
|
|
|
import { MultipleSelectGroupAction } from "@/components/core";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { IBlockUpdateData, IGanttBlock } from "@/components/gantt-chart";
|
2024-06-04 05:42:24 +00:00
|
|
|
// helpers
|
|
|
|
import { cn } from "@/helpers/common.helper";
|
|
|
|
// hooks
|
|
|
|
import { TSelectionHelper } from "@/hooks/use-multiple-select";
|
2024-02-12 09:38:17 +00:00
|
|
|
// constants
|
2024-06-04 05:42:24 +00:00
|
|
|
import { GANTT_SELECT_GROUP, HEADER_HEIGHT, SIDEBAR_WIDTH } from "../constants";
|
2024-02-12 09:38:17 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
blocks: IGanttBlock[] | null;
|
|
|
|
blockUpdateHandler: (block: any, payload: IBlockUpdateData) => void;
|
|
|
|
enableReorder: boolean;
|
2024-06-04 05:42:24 +00:00
|
|
|
enableSelection: boolean;
|
2024-02-12 09:38:17 +00:00
|
|
|
sidebarToRender: (props: any) => React.ReactNode;
|
|
|
|
title: string;
|
2024-02-14 12:45:13 +00:00
|
|
|
quickAdd?: React.JSX.Element | undefined;
|
2024-06-04 05:42:24 +00:00
|
|
|
selectionHelpers: TSelectionHelper;
|
2024-02-12 09:38:17 +00:00
|
|
|
};
|
|
|
|
|
2024-06-04 05:42:24 +00:00
|
|
|
export const GanttChartSidebar: React.FC<Props> = observer((props) => {
|
|
|
|
const {
|
|
|
|
blocks,
|
|
|
|
blockUpdateHandler,
|
|
|
|
enableReorder,
|
|
|
|
enableSelection,
|
|
|
|
sidebarToRender,
|
|
|
|
title,
|
|
|
|
quickAdd,
|
|
|
|
selectionHelpers,
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const isGroupSelectionEmpty = selectionHelpers.isGroupSelected(GANTT_SELECT_GROUP) === "empty";
|
2024-02-12 09:38:17 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
// DO NOT REMOVE THE ID
|
|
|
|
id="gantt-sidebar"
|
2024-02-14 12:45:13 +00:00
|
|
|
className="sticky left-0 z-10 min-h-full h-max flex-shrink-0 border-r-[0.5px] border-custom-border-200 bg-custom-background-100"
|
2024-02-12 09:38:17 +00:00
|
|
|
style={{
|
|
|
|
width: `${SIDEBAR_WIDTH}px`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
2024-06-04 05:42:24 +00:00
|
|
|
className="group/list-header box-border flex-shrink-0 flex items-end justify-between gap-2 border-b-[0.5px] border-custom-border-200 pb-2 pl-2 pr-4 text-sm font-medium text-custom-text-300 sticky top-0 z-10 bg-custom-background-100"
|
2024-02-12 09:38:17 +00:00
|
|
|
style={{
|
|
|
|
height: `${HEADER_HEIGHT}px`,
|
|
|
|
}}
|
|
|
|
>
|
2024-06-04 05:42:24 +00:00
|
|
|
<div
|
|
|
|
className={cn("flex items-center gap-2", {
|
|
|
|
"pl-2": !enableSelection,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{enableSelection && (
|
|
|
|
<div className="flex-shrink-0 flex items-center w-3.5">
|
|
|
|
<MultipleSelectGroupAction
|
|
|
|
className={cn(
|
|
|
|
"size-3.5 opacity-0 pointer-events-none group-hover/list-header:opacity-100 group-hover/list-header:pointer-events-auto !outline-none",
|
|
|
|
{
|
|
|
|
"opacity-100 pointer-events-auto": !isGroupSelectionEmpty,
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
groupID={GANTT_SELECT_GROUP}
|
|
|
|
selectionHelpers={selectionHelpers}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<h6>{title}</h6>
|
|
|
|
</div>
|
2024-02-12 09:38:17 +00:00
|
|
|
<h6>Duration</h6>
|
|
|
|
</div>
|
|
|
|
|
2024-05-08 08:08:58 +00:00
|
|
|
<div className="min-h-full h-max bg-custom-background-100 overflow-hidden">
|
2024-06-04 05:42:24 +00:00
|
|
|
{sidebarToRender?.({ title, blockUpdateHandler, blocks, enableReorder, enableSelection, selectionHelpers })}
|
2024-02-12 09:38:17 +00:00
|
|
|
</div>
|
2024-02-14 12:45:13 +00:00
|
|
|
{quickAdd ? quickAdd : null}
|
2024-02-12 09:38:17 +00:00
|
|
|
</div>
|
|
|
|
);
|
2024-06-04 05:42:24 +00:00
|
|
|
});
|