Skip to content

Commit d68822e

Browse files
committed
task updates
1 parent deb0631 commit d68822e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lowcoder-comp-gant-chart/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@types/react": "18",
88
"@types/react-dom": "18",
99
"gantt-task-react": "^0.3.9",
10+
"lodash": "^4.17.21",
1011
"lowcoder-cli": "^0.0.30",
1112
"lowcoder-sdk": "^2.4.3",
1213
"react": "18",
@@ -33,5 +34,8 @@
3334
"start": "vite",
3435
"build": "lowcoder-cli build",
3536
"build_publish": "lowcoder-cli build --publish"
37+
},
38+
"devDependencies": {
39+
"@types/lodash": "^4.17.7"
3640
}
3741
}

lowcoder-comp-gant-chart/src/GanttChartComp.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
// useMergeCompStyles,
2626
} from "lowcoder-sdk";
2727
import { i18nObjs, trans } from "./i18n/comps";
28+
import _ from 'lodash'
2829

2930
export enum DEP_TYPE {
3031
CONTRAST_TEXT = 'contrastText',
@@ -416,8 +417,8 @@ const filterTaskFields = (task: Task & { barChildren: Omit<OptionPropertyParam,
416417
let GanttOption = new MultiCompBuilder(
417418
{
418419
title: StringControl,
419-
start: jsonControl((data: any) => new Date(data)),
420-
end: jsonControl((data: any) => new Date(data)),
420+
start: jsonControl((data: any) => data ? new Date(data) : new Date()),
421+
end: jsonControl((data: any) => data ? new Date(data) : new Date()),
421422
label: StringControl,
422423
id: StringControl,
423424
project: StringControl,
@@ -555,6 +556,16 @@ let GanttChartCompBase = (function () {
555556
},
556557
});
557558

559+
useEffect(() => {
560+
if (tasks.length === 0) {
561+
if (props.data.length > 0) {
562+
setTasks(props.data);
563+
}
564+
} else if (!_.isEqual(props.data, tasks)) {
565+
setTasks(props.data)
566+
}
567+
}, [props.data])
568+
558569
useEffect(() => {
559570
props.ganttTasks.onChange(updatedGanttTasks);
560571
}, [updatedGanttTasks]);
@@ -633,7 +644,7 @@ let GanttChartCompBase = (function () {
633644
<div className="Wrapper" ref={conRef}>
634645
{tasks.length > 0 ? (
635646
<Gantt
636-
tasks={tasks}
647+
tasks={tasks.map(task=>({...task,name:task.title}))}
637648
viewMode={activeViewMode}
638649
onDateChange={handleTaskChange}
639650
onDelete={handleTaskDelete}

0 commit comments

Comments
 (0)