From 7d9c433d8a69c1aa4d42fd3022c808bab4ccb64d Mon Sep 17 00:00:00 2001 From: LIANG OU Date: Tue, 26 Nov 2024 14:11:15 +0800 Subject: [PATCH 1/3] feat: add dependency link point click event --- .../vtable-gantt/src/event/event-manager.ts | 20 ++++++++++--------- .../vtable-gantt/src/ts-types/EVENT_TYPE.ts | 8 +++++++- packages/vtable-gantt/src/ts-types/events.ts | 8 ++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/vtable-gantt/src/event/event-manager.ts b/packages/vtable-gantt/src/event/event-manager.ts index 0fd516318..a25fe35ae 100644 --- a/packages/vtable-gantt/src/event/event-manager.ts +++ b/packages/vtable-gantt/src/event/event-manager.ts @@ -346,16 +346,18 @@ function bindTableGroupListener(event: EventManager) { stateManager.hideTaskBarSelectedBorder(); scene._gantt.stateManager.selectedDenpendencyLink.link = depedencyLink; stateManager.showDependencyLinkSelectedLine(); - } else if (isClickLeftLinkPoint && event.poniterState === 'draging') { - if (stateManager.isCreatingDependencyLine()) { - const link = stateManager.endCreateDependencyLine(e.offset.y); - if (gantt.hasListeners(GANTT_EVENT_TYPE.CREATE_DEPENDENCY_LINK)) { - gantt.fireListeners(GANTT_EVENT_TYPE.CREATE_DEPENDENCY_LINK, { - event: e.nativeEvent, - link - }); - } + } else if ((isClickLeftLinkPoint || isClickRightLinkPoint) && event.poniterState === 'down') { + if (gantt.hasListeners(GANTT_EVENT_TYPE.CLICK_DEPENDENCY_LINK_POINT)) { + const taskIndex = getTaskIndexByY(e.offset.y, gantt); + const record = gantt.getRecordByIndex(taskIndex); + gantt.fireListeners(GANTT_EVENT_TYPE.CLICK_DEPENDENCY_LINK_POINT, { + event: e.nativeEvent, + index: taskIndex, + point: isClickLeftLinkPoint ? 'start' : 'end', + record + }); } + stateManager.hideTaskBarSelectedBorder(); } else if (isClickRightLinkPoint && event.poniterState === 'draging') { if (stateManager.isCreatingDependencyLine()) { const link = stateManager.endCreateDependencyLine(e.offset.y); diff --git a/packages/vtable-gantt/src/ts-types/EVENT_TYPE.ts b/packages/vtable-gantt/src/ts-types/EVENT_TYPE.ts index ccf7c39a9..20b9f96a4 100644 --- a/packages/vtable-gantt/src/ts-types/EVENT_TYPE.ts +++ b/packages/vtable-gantt/src/ts-types/EVENT_TYPE.ts @@ -28,6 +28,11 @@ export interface EVENT_TYPES { * 创建任务依赖关系 */ CREATE_DEPENDENCY_LINK: 'create_dependency_link'; + + /** + * 点击依赖关系连接点 + */ + CLICK_DEPENDENCY_LINK_POINT: 'click_dependency_link_point'; } /** * Table event types @@ -39,5 +44,6 @@ export const GANTT_EVENT_TYPE: EVENT_TYPES = { MOUSEENTER_TASK_BAR: 'mouseenter_task_bar', MOUSELEAVE_TASK_BAR: 'mouseleave_task_bar', CREATE_TASK_SCHEDULE: 'create_task_schedule', - CREATE_DEPENDENCY_LINK: 'create_dependency_link' + CREATE_DEPENDENCY_LINK: 'create_dependency_link', + CLICK_DEPENDENCY_LINK_POINT: 'click_dependency_link_point' } as EVENT_TYPES; diff --git a/packages/vtable-gantt/src/ts-types/events.ts b/packages/vtable-gantt/src/ts-types/events.ts index 4e1c3f4bd..3c9b59bda 100644 --- a/packages/vtable-gantt/src/ts-types/events.ts +++ b/packages/vtable-gantt/src/ts-types/events.ts @@ -61,6 +61,14 @@ export interface TableEventHandlersEventArgumentMap { /** 依赖信息 */ link: ITaskLink; }; + click_dependency_link_point: { + event: Event; + /** 点击的是起始点还是结束点 */ + point: 'start' | 'end'; + /** 第几条数据 */ + index: number; + record: any; + }; } export interface TableEventHandlersReturnMap { From 9c86e080150b2573af643622bf6e5ed786157d9b Mon Sep 17 00:00:00 2001 From: LIANG OU Date: Tue, 26 Nov 2024 19:10:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E8=BF=9E=E6=8E=A5=E7=82=B9=E4=BA=8B=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/assets/api/en/GanttAPI.md | 17 +++++++++++++++++ docs/assets/api/zh/GanttAPI.md | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/docs/assets/api/en/GanttAPI.md b/docs/assets/api/en/GanttAPI.md index 3d201e6b6..233695a55 100644 --- a/docs/assets/api/en/GanttAPI.md +++ b/docs/assets/api/en/GanttAPI.md @@ -249,3 +249,20 @@ Event return parameters: link: ITaskLink; }; ``` + +### CLICK_DEPENDENCY_LINK_POINT + +Events that click dependency line point +Event return parameters: + +``` +{ + event: Event; + /** click start or end link point */ + point: 'start' | 'end'; + /** the data order */ + index: number; + /** the data info */ + record: any; + }; +``` diff --git a/docs/assets/api/zh/GanttAPI.md b/docs/assets/api/zh/GanttAPI.md index fe19235ac..5b1ee373c 100644 --- a/docs/assets/api/zh/GanttAPI.md +++ b/docs/assets/api/zh/GanttAPI.md @@ -250,3 +250,20 @@ MOUSEENTER_TASK_BAR link: ITaskLink; }; ``` + +### CLICK_DEPENDENCY_LINK_POINT + +点击依赖关系点的事件 +事件回传参数: + +``` +{ + event: Event; + /** 点击的是起始点还是结束点 */ + point: 'start' | 'end'; + /** 第几条数据 */ + index: number; + /** 点击连接点的数据信息 */ + record: any; + }; +``` From 0dd22981ee8004ee5bebfa10fff20b7fc88db1f7 Mon Sep 17 00:00:00 2001 From: ouliang Date: Wed, 27 Nov 2024 16:37:17 +0800 Subject: [PATCH 3/3] fix: add deleted code by mistake --- packages/vtable-gantt/src/event/event-manager.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/vtable-gantt/src/event/event-manager.ts b/packages/vtable-gantt/src/event/event-manager.ts index a25fe35ae..e47ce2890 100644 --- a/packages/vtable-gantt/src/event/event-manager.ts +++ b/packages/vtable-gantt/src/event/event-manager.ts @@ -358,6 +358,16 @@ function bindTableGroupListener(event: EventManager) { }); } stateManager.hideTaskBarSelectedBorder(); + } else if (isClickLeftLinkPoint && event.poniterState === 'draging') { + if (stateManager.isCreatingDependencyLine()) { + const link = stateManager.endCreateDependencyLine(e.offset.y); + if (gantt.hasListeners(GANTT_EVENT_TYPE.CREATE_DEPENDENCY_LINK)) { + gantt.fireListeners(GANTT_EVENT_TYPE.CREATE_DEPENDENCY_LINK, { + event: e.nativeEvent, + link + }); + } + } } else if (isClickRightLinkPoint && event.poniterState === 'draging') { if (stateManager.isCreatingDependencyLine()) { const link = stateManager.endCreateDependencyLine(e.offset.y);