Skip to content

Commit 202b6c0

Browse files
authored
Merge pull request #3279 from VisActor/3268-feature-gantt-deleteLinkLine
3268 feature gantt delete link line
2 parents 64a5e1d + 30dc30e commit 202b6c0

19 files changed

+228
-50
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "feat: add keyboardOptions and add delete_dependency_link contextmenu_dependency_link event #3268\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vtable"
7+
}
8+
],
9+
"packageName": "@visactor/vtable",
10+
"email": "[email protected]"
11+
}

docs/assets/api/en/GanttAPI.md

+25
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,28 @@ Event return parameters:
322322
record: any;
323323
};
324324
```
325+
326+
### CONTEXTMENU_DEPENDENCY_LINK
327+
328+
Events that right-click dependency line
329+
Event return parameters:
330+
331+
```
332+
{
333+
federatedEvent: FederatedPointerEvent;
334+
event: Event;
335+
/** dependency link */
336+
link: ITaskLink;
337+
};
338+
```
339+
### DELETE_DEPENDENCY_LINK
340+
341+
Events that delete dependency line
342+
Event return parameters:
343+
```
344+
{
345+
event: Event;
346+
/** dependency link */
347+
link: ITaskLink;
348+
};
349+
```

docs/assets/api/zh/GanttAPI.md

+25
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,28 @@ export interface EVENT_TYPES {
322322
record: any;
323323
};
324324
```
325+
326+
### CONTEXTMENU_DEPENDENCY_LINK
327+
328+
右键点击依赖关系的事件
329+
事件回传参数:
330+
331+
```
332+
{
333+
federatedEvent: FederatedPointerEvent;
334+
event: Event;
335+
/** 依赖信息 */
336+
link: ITaskLink;
337+
};
338+
```
339+
340+
### DELETE_DEPENDENCY_LINK
341+
删除了任务依赖关系
342+
事件回传参数:
343+
```
344+
{
345+
event: Event;
346+
/** 依赖信息 */
347+
link: ITaskLink;
348+
};
349+
```

docs/assets/guide/en/gantt/introduction.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ links:[
116116
}
117117
]
118118
```
119-
120-
The value of `linkedFromTaskKey` is the unique identifier field in records. The field name of the unique identifier field defaults to `id`. If you need to modify it, you can modify it through the `taskKeyField` configuration item.
121-
122-
Through the `dependency.linkLineStyle` configuration item set link line style, you can customize the style of the dependencies between tasks. Through the `dependency.linkLineSelectedStyle` configuration item, you can customize the style of the dependencies between tasks when they are selected. In addition, you can dynamically create association lines. Through the `dependency.linkCreatable` configuration item, you can set whether association lines can be created.
119+
The values of `linkedFromTaskKey` and `linkedToTaskKey` need to correspond to the unique identifier field in the `records`, with the default field name being `id`. If you need to modify it, you can do so through the `taskKeyField` configuration item.
123120

124121
### Interaction
125122

@@ -201,10 +198,23 @@ In the vtable-gantt component, the main supported configurations include:
201198

202199
3. Dependency Line `dependency`
203200

204-
1. Dependencies: Through the links configuration item, you can set dependencies between tasks.
205-
2. Link line style: You can set the link line style, including color, width, dashed line style, etc., through the linkLineStyle configuration item.
206-
3. Link creation: Through the linkCreatable configuration item, you can set whether to allow the creation of link lines.
207-
4. The operation style of the association line creation process: Through the linkSelectedLineStyle linkCreatingPointStyle linkCreatingLineStyle configuration items, you can set the style of the association line selection process, including color, width, dashed line style, etc.
201+
Introduction to related configuration items for task dependencies:
202+
203+
- `dependency.links`:You can set the dependencies between tasks through the `dependency.links` configuration item.
204+
205+
- `taskKeyField`:You can set the field name of the unique identifier field for dependencies through the `taskKeyField` configuration item.
206+
207+
- `dependency.linkLineStyle`:You can configure the style of dependency lines, including color, width, dashed style, etc., through `dependency.linkLineStyle`.
208+
209+
- `dependency.linkLineSelectedStyle`:You can customize the style of dependencies when selected between tasks.
210+
211+
- `dependency.linkCreatable`:You can set whether association lines can be created through the `dependency.linkCreatable` configuration item.
212+
213+
- `dependency.linkSelectable`:You can set whether association lines can be selected through the `dependency.linkSelectable` configuration item.
214+
215+
- `dependency.linkDeletable`:You can set whether association lines can be deleted through the `dependency.linkDeletable` configuration item. If you want to delete association lines through the right-click menu, you can listen to the `CONTEXTMENU_DEPENDENCY_LINK` event to actively call the deleteLink interface to delete. If you configure shortcut keys `keyboardOptions.deleteLinkOnDel` or `keyboardOptions.deleteLinkOnBack` to delete association lines by pressing the 'del' or 'back' key on the keyboard.
216+
217+
- Operation style during the creation of association lines: You can set the style of the association line selection process, including color, width, dashed style, etc., through the `linkSelectedLineStyle` `linkCreatePointStyle` `linkCreatingPointStyle` `linkCreatingLineStyle` configuration items.
208218

209219
4. Date Header Configuration `timelineHeader`
210220
1. Custom Rendering: You can customize the rendering of date headers through the `customLayout` configuration item.

docs/assets/guide/zh/gantt/introduction.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ links:[
117117
]
118118
```
119119

120-
`linkedFromTaskKey` 的值是 records 中的唯一标识字段,唯一表示字段的字段名默认为`id`,如果需要修改可以通过`taskKeyField`配置项来修改。
121-
122-
样式可以通过 `dependency.linkLineStyle` 配置项,可以自定义任务之间的依赖关系的样式。通过 `dependency.linkLineSelectedStyle` 配置项,可以自定义任务之间的依赖关系选中时的样式。另外可以动态创建关联线,通过 `dependency.linkCreatable` 配置项,可以设置是否可以创建关联线。
120+
其中`linkedFromTaskKey``linkedToTaskKey` 的值需要对应 records 中的唯一标识字段,唯一标识的字段名默认为`id`,如果需要修改可以通过`taskKeyField`配置项来修改。
123121

124122
### 交互
125123

@@ -202,10 +200,23 @@ VTableGantt 内部借助这个表格实例 tableInstance 实现的能力有:
202200

203201
3. 依赖关联线 `dependency`
204202

205-
1. 依赖关系:通过 `links` 配置项,可以设置任务之间的依赖关系。
206-
2. 关联线的样式: 通过 `linkLineStyle` 配置项,可以设置关联线的样式,包括颜色、宽度、虚线样式等。
207-
3. 关联线创建: 通过 `linkCreatable` 配置项,可以设置是否允许创建关联线。
208-
4. 关联线创建过程的操作样式: 通过 `linkSelectedLineStyle` `linkCreatingPointStyle` `linkCreatingLineStyle` 配置项,可以设置关联线选中过程的样式,包括颜色、宽度、虚线样式等。
203+
任务依赖关系的相关配置项介绍:
204+
205+
- `dependency.links`:可以通过 `dependency.links` 配置项,设置任务之间的依赖关系。
206+
207+
- `taskKeyField`:可以通过 `taskKeyField` 配置项,设置依赖关系唯一标识字段的字段名。
208+
209+
- `dependency.linkLineStyle`:可以通过 `dependency.linkLineStyle` 配置依赖线样式,包括颜色、宽度、虚线样式等。
210+
211+
- `dependency.linkLineSelectedStyle`:可以自定义任务之间的依赖关系选中时的样式。
212+
213+
- `dependency.linkCreatable`:通过 `dependency.linkCreatable` 配置项,可以设置是否可以创建关联线。
214+
215+
- `dependency.linkSelectable`:通过 `dependency.linkSelectable` 配置项,可以设置是否可以选中关联线。
216+
217+
- `dependency.linkDeletable`:通过 `dependency.linkDeletable` 配置项,可以设置是否可以删除关联线,如果想要通过鼠标右键删除关联线,可以监听`CONTEXTMENU_DEPENDENCY_LINK`事件,来主动调用接口 deleteLink 来删除。如果配置快捷键`keyboardOptions.deleteLinkOnDel`或者`keyboardOptions.deleteLinkOnBack`来通过按下键盘'del'或者'back'键来删除关联线。
218+
219+
- 关联线创建过程的操作样式: 通过 `linkSelectedLineStyle` `linkCreatePointStyle` `linkCreatingPointStyle` `linkCreatingLineStyle` 配置项,可以设置关联线选中过程的样式,包括颜色、宽度、虚线样式等。
209220

210221
4. 日期表头配置 timelineHeader
211222
1. 自定义渲染: 通过 customLayout 配置项,可以自定义日期表头的渲染方式。

docs/assets/option/en/column/base-column-type.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Header cell icon configuration. Available configuration types are:
7171
string | ColumnIconOption | (string | ColumnIconOption)[];
7272
```
7373

74-
For the specific configuration of ColumnIconOption, refer to the [definition](/zh/option.html#ListTable-columns-text.icon.ColumnIconOption定义:)
74+
For the specific configuration of ColumnIconOption, refer to the [definition](./ListTable-columns-text#icon.ColumnIconOption)
7575

7676
${prefix} icon(string|Object|Array|Funciton)
7777

docs/assets/option/en/common/gantt/dependency-line.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ Specific definition:
44

55
```
66
{
7-
links: ITaskLink[];
8-
linkLineStyle?: ILineStyle;
9-
linkCreatable?: boolean;
10-
linkSelectable?: boolean;
11-
linkSelectedLineStyle?: ITaskLinkSelectedStyle;
12-
/** Create an operation point for the association line */
13-
linkCreatePointStyle?: IPointStyle;
14-
/** Create the operating point response status effect of the association line */
15-
linkCreatingPointStyle?: IPointStyle;
16-
/** Create an operation line style for the association line */
17-
linkCreatingLineStyle?: ILineStyle;
7+
links: ITaskLink[];
8+
linkLineStyle?: ILineStyle;
9+
linkCreatable?: boolean;
10+
linkSelectable?: boolean;
11+
linkDeletable?: boolean;
12+
linkSelectedLineStyle?: ITaskLinkSelectedStyle;
13+
/** Create an operation point for the association line */
14+
linkCreatePointStyle?: IPointStyle;
15+
/** Create the operating point response status effect of the association line */
16+
linkCreatingPointStyle?: IPointStyle;
17+
/** Create an operation line style for the association line */
18+
linkCreatingLineStyle?: ILineStyle;
1819
}
1920
```
2021

docs/assets/option/en/common/row-series-number.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Table header cell icon configuration. The configurable types are:
4040
string | ColumnIconOption | (string | ColumnIconOption)[];
4141
```
4242

43-
For detailed configuration of ColumnIconOption, please refer to [Definition](/zh/option.html#ListTable-columns-text.icon.ColumnIconOptionDefinition:)
43+
For detailed configuration of ColumnIconOption, please refer to [Definition](./ListTable-columns-text#icon.ColumnIconOption)
4444

4545
${prefix} icon(string|Object|Array|Funciton)
4646

docs/assets/option/zh/column/base-column-type.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ${prefix} headerIcon(string|Object|Array)
7171
string | ColumnIconOption | (string | ColumnIconOption)[];
7272
```
7373

74-
ColumnIconOption 具体配置可参考[定义](/zh/option.html#ListTable-columns-text.icon.ColumnIconOption定义:)
74+
ColumnIconOption 具体配置可参考[定义](./ListTable-columns-text#icon.ColumnIconOption)
7575

7676
${prefix} icon(string|Object|Array|Funciton)
7777

docs/assets/option/zh/common/gantt/dependency-line.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
linkLineStyle?: ILineStyle;
99
linkCreatable?: boolean;
1010
linkSelectable?: boolean;
11+
linkDeletable?: boolean;
1112
linkSelectedLineStyle?: ITaskLinkSelectedStyle;
1213
/** 创建关联线的操作点 */
1314
linkCreatePointStyle?: IPointStyle;

docs/assets/option/zh/common/row-series-number.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ${prefix} headerIcon(string|Object|Array)
4040
string | ColumnIconOption | (string | ColumnIconOption)[];
4141
```
4242

43-
ColumnIconOption 具体配置可参考[定义](/zh/option.html#ListTable-columns-text.icon.ColumnIconOption定义:)
43+
ColumnIconOption 具体配置可参考[定义](./ListTable-columns-text#icon.ColumnIconOption)
4444

4545
${prefix} icon(string|Object|Array|Funciton)
4646

packages/vtable-gantt/examples/gantt/gantt-dependency.ts

+11
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ export function createTable() {
174174
minTableWidth: 100,
175175
maxTableWidth: 600
176176
},
177+
keyboardOptions: {
178+
deleteLinkOnDel: true,
179+
deleteLinkOnBack: true
180+
},
177181
dependency: {
182+
linkDeletable: true,
178183
links: [
179184
{
180185
type: DependencyType.FinishToStart,
@@ -393,7 +398,13 @@ export function createTable() {
393398
ganttInstance.taskListTableInstance?.on('scroll', e => {
394399
console.log('listTable scroll', e);
395400
});
401+
ganttInstance.on('contextmenu_dependency_link', e => {
402+
console.log('contextmenu_dependency_link', e);
403+
});
396404

405+
ganttInstance.on('delete_dependency_link', e => {
406+
console.log('delete_dependency_link', e);
407+
});
397408
// bindDebugTool(ganttInstance.scenegraph.stage as any, {
398409
// customGrapicKeys: ['role', '_updateTag']
399410
// });

packages/vtable-gantt/src/Gantt.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import type {
2525
IPointStyle,
2626
TaskBarInteractionArgumentType,
2727
IEventOptions,
28-
IMilestoneStyle
28+
IMilestoneStyle,
29+
IKeyboardOptions
2930
} from './ts-types';
3031
import { TasksShowMode } from './ts-types';
3132
import type { ListTableConstructorOptions } from '@visactor/vtable';
@@ -181,13 +182,15 @@ export class Gantt extends EventTarget {
181182
dependencyLinks?: ITaskLink[];
182183
dependencyLinkCreatable: boolean;
183184
dependencyLinkSelectable: boolean;
185+
dependencyLinkDeletable: boolean;
184186
dependencyLinkLineStyle: ILineStyle;
185187
dependencyLinkSelectedLineStyle: ITaskLinkSelectedStyle;
186188
dependencyLinkLineCreatePointStyle: IPointStyle;
187189
dependencyLinkLineCreatingPointStyle: IPointStyle;
188190
dependencyLinkLineCreatingStyle?: ILineStyle;
189191
underlayBackgroundColor: string;
190192
eventOptions: IEventOptions;
193+
keyboardOptions: IKeyboardOptions;
191194
} = {} as any;
192195
/** 左侧任务表格的整体宽度 比表格实例taskListTableInstance的tableNoFrameWidth会多出左侧frame边框的宽度 */
193196
taskTableWidth: number;
@@ -1055,17 +1058,19 @@ export class Gantt extends EventTarget {
10551058
this.scenegraph.updateNextFrame();
10561059
}
10571060
deleteLink(link: ITaskLink) {
1058-
const index = this.parsedOptions.dependencyLinks.findIndex(
1059-
item =>
1060-
item.type === link.type &&
1061-
item.linkedFromTaskKey === link.linkedFromTaskKey &&
1062-
item.linkedToTaskKey === link.linkedToTaskKey
1063-
);
1064-
if (index !== -1) {
1065-
const link = this.parsedOptions.dependencyLinks[index];
1066-
this.parsedOptions.dependencyLinks.splice(index, 1);
1067-
this.scenegraph.dependencyLink.deleteLink(link);
1068-
this.scenegraph.updateNextFrame();
1061+
if (this.parsedOptions.dependencyLinkDeletable) {
1062+
const index = this.parsedOptions.dependencyLinks.findIndex(
1063+
item =>
1064+
item.type === link.type &&
1065+
item.linkedFromTaskKey === link.linkedFromTaskKey &&
1066+
item.linkedToTaskKey === link.linkedToTaskKey
1067+
);
1068+
if (index !== -1) {
1069+
const link = this.parsedOptions.dependencyLinks[index];
1070+
this.parsedOptions.dependencyLinks.splice(index, 1);
1071+
this.scenegraph.dependencyLink.deleteLink(link);
1072+
this.scenegraph.updateNextFrame();
1073+
}
10691074
}
10701075
}
10711076
get scrollTop(): number {

0 commit comments

Comments
 (0)