fix: cycle and module reordering in the gantt chart (#3570)

* fix: cycle and module reordering in the gantt chart

* chore: hide duration from sidebar if no dates are assigned

* chore: updated date helper functions to accept undefined params

* chore: update cycle sidebar condition
This commit is contained in:
Aaryan Khandelwal 2024-02-08 13:30:16 +05:30 committed by GitHub
parent c1c0297b6d
commit 9545dc77d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 75 additions and 324 deletions

View file

@ -13,37 +13,32 @@ export const ModulesListGanttChartView: React.FC = observer(() => {
const router = useRouter();
const { workspaceSlug } = router.query;
// store
const { projectModuleIds, moduleMap } = useModule();
const { currentProjectDetails } = useProject();
const { projectModuleIds, moduleMap, updateModuleDetails } = useModule();
const handleModuleUpdate = (module: IModule, payload: IBlockUpdateData) => {
if (!workspaceSlug) return;
// FIXME
//updateModuleGanttStructure(workspaceSlug.toString(), module.project, module, payload);
const handleModuleUpdate = async (module: IModule, data: IBlockUpdateData) => {
if (!workspaceSlug || !module) return;
const payload: any = { ...data };
if (data.sort_order) payload.sort_order = data.sort_order.newSortOrder;
await updateModuleDetails(workspaceSlug.toString(), module.project, module.id, payload);
};
const blockFormat = (blocks: string[]) =>
blocks && blocks.length > 0
? blocks
.filter((blockId) => {
const block = moduleMap[blockId];
return block.start_date && block.target_date && new Date(block.start_date) <= new Date(block.target_date);
})
.map((blockId) => {
const block = moduleMap[blockId];
return {
data: block,
id: block.id,
sort_order: block.sort_order,
start_date: new Date(block.start_date ?? ""),
target_date: new Date(block.target_date ?? ""),
};
})
: [];
blocks?.map((blockId) => {
const block = moduleMap[blockId];
return {
data: block,
id: block.id,
sort_order: block.sort_order,
start_date: block.start_date ? new Date(block.start_date) : null,
target_date: block.target_date ? new Date(block.target_date) : null,
};
});
const isAllowed = currentProjectDetails?.member_role === 20 || currentProjectDetails?.member_role === 15;
const modules = projectModuleIds;
return (
<div className="h-full w-full overflow-y-auto">
<GanttChartRoot
@ -57,6 +52,7 @@ export const ModulesListGanttChartView: React.FC = observer(() => {
enableBlockRightResize={isAllowed}
enableBlockMove={isAllowed}
enableReorder={isAllowed}
showAllBlocks
/>
</div>
);