[WEB-4531]chore: refactor for timeline chart (#7440)

This commit is contained in:
Vamsi Krishna 2025-07-21 19:22:58 +05:30 committed by GitHub
parent cc673a17a0
commit 4c3af7f8a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 43 additions and 23 deletions

View file

@ -3,7 +3,13 @@ import set from "lodash/set";
import { action, makeObservable, observable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
// components
import type { ChartDataType, IBlockUpdateDependencyData, IGanttBlock, TGanttViews } from "@plane/types";
import type {
ChartDataType,
IBlockUpdateDependencyData,
IGanttBlock,
TGanttViews,
EGanttBlockType,
} from "@plane/types";
import { renderFormattedPayloadDate } from "@plane/utils";
import { currentViewDataWithView } from "@/components/gantt-chart/data";
import {
@ -177,7 +183,7 @@ export class BaseTimeLineStore implements IBaseTimelineStore {
* @param getDataById
* @returns
*/
updateBlocks(getDataById: (id: string) => BlockData | undefined | null) {
updateBlocks(getDataById: (id: string) => BlockData | undefined | null, type?: EGanttBlockType, index?: number) {
if (!this.blockIds || !Array.isArray(this.blockIds) || this.isDragging) return true;
const updatedBlockMaps: { path: string[]; value: any }[] = [];
@ -195,7 +201,11 @@ export class BaseTimeLineStore implements IBaseTimelineStore {
sort_order: blockData?.sort_order ?? undefined,
start_date: blockData?.start_date ?? undefined,
target_date: blockData?.target_date ?? undefined,
project_id: blockData?.project_id ?? undefined,
meta: {
type,
index,
project_id: blockData?.project_id,
},
};
if (this.currentViewData && (this.currentViewData?.data?.startDate || this.currentViewData?.data?.dayWidth)) {
block.position = getItemPositionWidth(this.currentViewData, block);
@ -285,7 +295,7 @@ export class BaseTimeLineStore implements IBaseTimelineStore {
if (!currBlock?.position || !this.currentViewData) return [];
const updatePayload: IBlockUpdateDependencyData = { id };
const updatePayload: IBlockUpdateDependencyData = { id, meta: currBlock.meta };
// If shouldUpdateHalfBlock or the start date is available then update start date
if (shouldUpdateHalfBlock || currBlock.start_date) {