@progress/kendo-angular-gantt 0.3.0-dev.202201131518 → 1.0.1-dev.202201201207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cdn/js/kendo-angular-gantt.js +2 -2
  2. package/dist/cdn/main.js +1 -23
  3. package/dist/es/editing/dependencies-table.component.js +1 -1
  4. package/dist/es/editing/edit-dialog.component.js +3 -3
  5. package/dist/es/editing/edit.service.js +4 -2
  6. package/dist/es/editing/task-fields.component.js +1 -1
  7. package/dist/es/gantt.component.js +191 -24
  8. package/dist/es/index.js +1 -0
  9. package/dist/es/models/events/task-delete-event.interface.js +4 -0
  10. package/dist/es/navigation/navigation-models.js +4 -0
  11. package/dist/es/navigation/navigation.service.js +390 -0
  12. package/dist/es/navigation/utils.js +77 -0
  13. package/dist/es/package-metadata.js +1 -1
  14. package/dist/es/rendering/gantt-milestone-task.component.js +7 -4
  15. package/dist/es/rendering/gantt-summary-task.component.js +22 -4
  16. package/dist/es/rendering/gantt-task-base.js +57 -6
  17. package/dist/es/rendering/gantt-task.component.js +9 -6
  18. package/dist/es/rendering/gantt-tasks-table-body.component.js +9 -5
  19. package/dist/es/timeline/gantt-timeline.component.js +10 -6
  20. package/dist/es/toolbar/toolbar.component.js +12 -13
  21. package/dist/es/toolbar/view-selector.component.js +1 -1
  22. package/dist/es/utils.js +14 -4
  23. package/dist/es2015/editing/dependencies-table.component.js +1 -1
  24. package/dist/es2015/editing/edit-dialog.component.d.ts +1 -1
  25. package/dist/es2015/editing/edit-dialog.component.js +12 -4
  26. package/dist/es2015/editing/edit.service.d.ts +2 -3
  27. package/dist/es2015/editing/edit.service.js +4 -2
  28. package/dist/es2015/editing/task-fields.component.js +1 -1
  29. package/dist/es2015/editing/utils.d.ts +2 -2
  30. package/dist/es2015/gantt.component.d.ts +75 -16
  31. package/dist/es2015/gantt.component.js +177 -26
  32. package/dist/es2015/index.d.ts +1 -0
  33. package/dist/es2015/index.js +1 -0
  34. package/dist/es2015/index.metadata.json +1 -1
  35. package/dist/es2015/models/events/task-click-event.interface.d.ts +3 -3
  36. package/dist/es2015/models/events/task-delete-event.interface.d.ts +21 -0
  37. package/dist/es2015/models/events/task-delete-event.interface.js +4 -0
  38. package/dist/es2015/models/events/task-edit-event.interface.d.ts +27 -10
  39. package/dist/es2015/models/models.d.ts +2 -0
  40. package/dist/es2015/navigation/navigation-models.d.ts +34 -0
  41. package/dist/es2015/navigation/navigation-models.js +4 -0
  42. package/dist/es2015/navigation/navigation.service.d.ts +126 -0
  43. package/dist/es2015/navigation/navigation.service.js +355 -0
  44. package/dist/es2015/navigation/utils.d.ts +26 -0
  45. package/dist/es2015/navigation/utils.js +69 -0
  46. package/dist/es2015/package-metadata.js +1 -1
  47. package/dist/es2015/rendering/gantt-milestone-task.component.d.ts +2 -1
  48. package/dist/es2015/rendering/gantt-milestone-task.component.js +18 -4
  49. package/dist/es2015/rendering/gantt-summary-task.component.d.ts +4 -1
  50. package/dist/es2015/rendering/gantt-summary-task.component.js +30 -4
  51. package/dist/es2015/rendering/gantt-task-base.d.ts +10 -2
  52. package/dist/es2015/rendering/gantt-task-base.js +48 -6
  53. package/dist/es2015/rendering/gantt-task.component.d.ts +3 -2
  54. package/dist/es2015/rendering/gantt-task.component.js +31 -9
  55. package/dist/es2015/rendering/gantt-tasks-table-body.component.d.ts +5 -3
  56. package/dist/es2015/rendering/gantt-tasks-table-body.component.js +23 -12
  57. package/dist/es2015/scrolling/scroll-sync.service.d.ts +1 -1
  58. package/dist/es2015/timeline/gantt-timeline.component.d.ts +5 -3
  59. package/dist/es2015/timeline/gantt-timeline.component.js +15 -6
  60. package/dist/es2015/toolbar/toolbar.component.d.ts +4 -5
  61. package/dist/es2015/toolbar/toolbar.component.js +12 -13
  62. package/dist/es2015/toolbar/view-selector.component.js +3 -1
  63. package/dist/es2015/utils.d.ts +10 -3
  64. package/dist/es2015/utils.js +14 -4
  65. package/dist/fesm2015/index.js +2314 -1613
  66. package/dist/fesm5/index.js +1724 -1015
  67. package/dist/npm/editing/dependencies-table.component.js +1 -1
  68. package/dist/npm/editing/edit-dialog.component.js +3 -3
  69. package/dist/npm/editing/edit.service.js +4 -2
  70. package/dist/npm/editing/task-fields.component.js +1 -1
  71. package/dist/npm/gantt.component.js +191 -24
  72. package/dist/npm/index.js +2 -0
  73. package/dist/npm/models/events/task-delete-event.interface.js +6 -0
  74. package/dist/npm/navigation/navigation-models.js +6 -0
  75. package/dist/npm/navigation/navigation.service.js +392 -0
  76. package/dist/npm/navigation/utils.js +79 -0
  77. package/dist/npm/package-metadata.js +1 -1
  78. package/dist/npm/rendering/gantt-milestone-task.component.js +7 -4
  79. package/dist/npm/rendering/gantt-summary-task.component.js +22 -4
  80. package/dist/npm/rendering/gantt-task-base.js +57 -6
  81. package/dist/npm/rendering/gantt-task.component.js +9 -6
  82. package/dist/npm/rendering/gantt-tasks-table-body.component.js +9 -5
  83. package/dist/npm/timeline/gantt-timeline.component.js +10 -6
  84. package/dist/npm/toolbar/toolbar.component.js +10 -11
  85. package/dist/npm/toolbar/view-selector.component.js +1 -1
  86. package/dist/npm/utils.js +14 -4
  87. package/dist/systemjs/kendo-angular-gantt.js +1 -1
  88. package/package.json +22 -21
  89. package/schematics/ngAdd/index.js +4 -4
@@ -10,7 +10,7 @@ export interface TaskClickEvent {
10
10
  /**
11
11
  * The DOM event that triggered the `taskClick` event.
12
12
  */
13
- originalEvent: PointerEvent;
13
+ originalEvent: PointerEvent | KeyboardEvent;
14
14
  /**
15
15
  * The data item associated with the clicked task.
16
16
  */
@@ -20,9 +20,9 @@ export interface TaskClickEvent {
20
20
  */
21
21
  sender: GanttComponent;
22
22
  /**
23
- * The row index for the clicked task.
23
+ * The order index of the clicked task, defined by the number of rendered tasks in the Timeline.
24
24
  */
25
- rowIndex: number;
25
+ index: number;
26
26
  /**
27
27
  * The type of the event that triggered the `taskClick` event.
28
28
  */
@@ -0,0 +1,21 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { GanttComponent } from '../../gantt.component';
6
+ import { TaskEditItem } from './task-edit-event.interface';
7
+ /**
8
+ * The event data of the [`taskDelete`]({% slug api_gantt_ganttcomponent %}#toc-taskdelete) event.
9
+ */
10
+ export interface TaskDeleteEvent {
11
+ /**
12
+ * The item associated with the delete request.
13
+ * The parent item is accessible through the `parent` property,
14
+ * and allows traversing all ancestors that need to be updated.
15
+ */
16
+ item: TaskEditItem;
17
+ /**
18
+ * The GanttComponent instance.
19
+ */
20
+ sender: GanttComponent;
21
+ }
@@ -0,0 +1,4 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
@@ -32,10 +32,35 @@ export interface TaskEditEvent {
32
32
  * The parent item is accessible through the `parent` property,
33
33
  * and allows traversing all ancestors that need to be updated.
34
34
  */
35
- export declare type TaskEditItem = {
35
+ export interface TaskEditItem {
36
+ /**
37
+ * The original data item for this entry.
38
+ */
36
39
  dataItem: any;
40
+ /**
41
+ * Holds the parent data item and data about its parent.
42
+ * If the current data item is at root level, this prop will be set to `null`.
43
+ */
37
44
  parent?: TaskEditItem;
38
- };
45
+ }
46
+ /**
47
+ * The `EditEventDependencies` object associated with the edited task.
48
+ * The created, updated and deleted items are accessible through their respective properties.
49
+ */
50
+ export interface EditEventDependencies {
51
+ /**
52
+ * Lists the newly created dependencies.
53
+ */
54
+ createdItems: any[];
55
+ /**
56
+ * Lists the updated dependencies.
57
+ */
58
+ updatedItems: any[];
59
+ /**
60
+ * Lists the deleted dependencies.
61
+ */
62
+ deletedItems: any[];
63
+ }
39
64
  /**
40
65
  * @hidden
41
66
  */
@@ -49,11 +74,3 @@ export interface EditEvent {
49
74
  dependencies: EditEventDependencies;
50
75
  editResultType: EditResultType;
51
76
  }
52
- /**
53
- * @hidden
54
- */
55
- export interface EditEventDependencies {
56
- createdItems: any[];
57
- updatedItems: any[];
58
- deletedItems: any[];
59
- }
@@ -31,8 +31,10 @@ export { TaskClickEvent } from './events/task-click-event.interface';
31
31
  export { TaskAddEvent, GanttAddTaskActionItem } from './events/task-add-event.interface';
32
32
  export { TaskEditEvent } from './events/task-edit-event.interface';
33
33
  export { TaskEditItem } from './events/task-edit-event.interface';
34
+ export { EditEventDependencies } from './events/task-edit-event.interface';
34
35
  export { DependencyAddEvent } from './events/dependency-add-event.interface';
35
36
  export { DragScrollSettings } from '../scrolling/drag-scroll-settings';
37
+ export { TaskDeleteEvent } from './events/task-delete-event.interface';
36
38
  export { ColumnLockedChangeEvent } from './events/column-locked-change-event.interface';
37
39
  export { ColumnReorderEvent } from './events/column-reorder-event.interface';
38
40
  export { ColumnResizeEvent } from './events/column-resize-event.interface';
@@ -0,0 +1,34 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { GanttComponent } from '../gantt.component';
6
+ /**
7
+ * @hidden
8
+ */
9
+ export interface NavigationMetadata {
10
+ gantt: GanttComponent;
11
+ host: HTMLElement;
12
+ treeListElement: HTMLElement;
13
+ timelineElement: HTMLElement;
14
+ }
15
+ /**
16
+ * @hidden
17
+ */
18
+ export interface TableCellCoords {
19
+ rowIndex: number;
20
+ colIndex: number;
21
+ }
22
+ /**
23
+ * @hidden
24
+ */
25
+ export interface TaskActivityStatus {
26
+ /**
27
+ * Represents the timeline task index of the task element which should have tabindex="0".
28
+ */
29
+ activeIndex: number;
30
+ /**
31
+ * Specifies if the active task should be focused.
32
+ */
33
+ isFocused: boolean;
34
+ }
@@ -0,0 +1,4 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
@@ -0,0 +1,126 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { NgZone, OnDestroy, Renderer2 } from '@angular/core';
6
+ import { Subject } from 'rxjs';
7
+ import { ScrollSyncService } from '../scrolling/scroll-sync.service';
8
+ import { NavigationMetadata, TaskActivityStatus } from './navigation-models';
9
+ /**
10
+ * @hidden
11
+ */
12
+ export declare class NavigationService implements OnDestroy {
13
+ private zone;
14
+ private renderer;
15
+ private scrollSyncService;
16
+ /**
17
+ * Notifies when the tasks' focused and interactive (tabindex) state has changed.
18
+ *
19
+ * All tasks are rendered with tabindex="-1".
20
+ * When one is clicked, or when some navigation key keyboard key is pressed, it should be focused, assigned the focus class, and its tabindex updated to 0.
21
+ * All other tasks should get -1 tabindex and have the focus class removed from them.
22
+ */
23
+ readonly taskStatusChanges: Subject<TaskActivityStatus>;
24
+ /**
25
+ * Specifies whether navigation is enabled.
26
+ */
27
+ readonly enabled: boolean;
28
+ /**
29
+ * Used to retrieve read-only data about the currently active task.
30
+ */
31
+ readonly activeTask: TaskActivityStatus;
32
+ /**
33
+ * Persists the expected TreeList focused cell coords.
34
+ * When the tasks in the Timeline are navigated through, the expected TreeList focus target should also change,
35
+ * in order to allow back-tabbing from the Timeline to the same row in the TreeList.
36
+ */
37
+ private activeTreeListCell;
38
+ /**
39
+ * Persists the expected Timeline focused task index.
40
+ * When the cells in the TreeList are navigated through, the expected Timeline focus target should also change,
41
+ * in order to allow tabbing from the TreeList to the same row in the Timeline.
42
+ */
43
+ private activeTimelineIndex;
44
+ /**
45
+ * Keeps track of whether the Timeline part is focused.
46
+ * Used when the index of the task elements change (tasks are changed, pushed to, spliced from, etc.)
47
+ * and their status should be updated accordingly.
48
+ */
49
+ private isTimelineFocused;
50
+ /**
51
+ * The TreeList row index takes into account the header and filter rows.
52
+ * Used when translating Timeline task indices to TreeList row indices.
53
+ */
54
+ private readonly treeListHeaderRowsCount;
55
+ /**
56
+ * Keeps track of which part has last been focused.
57
+ * Used when calling `gantt.focus()` to determine which part of the component should receive focus.
58
+ */
59
+ private treeListLastActive;
60
+ /**
61
+ * Keeps track of which part has last been focused.
62
+ * Used when calling `gantt.focus()` to determine which part of the component should receive focus.
63
+ */
64
+ private timelineLastActive;
65
+ private gantt;
66
+ private host;
67
+ private treeListElement;
68
+ private timelineElement;
69
+ private _enabled;
70
+ private _activeTimelineIndex;
71
+ private _activeTreeListCell;
72
+ private eventListenerDisposers;
73
+ constructor(zone: NgZone, renderer: Renderer2, scrollSyncService: ScrollSyncService);
74
+ initialize({ gantt, host, treeListElement, timelineElement }: NavigationMetadata): void;
75
+ ngOnDestroy(): void;
76
+ /**
77
+ * Focuses either the last active TreeList cell, or the last active Timeline task,
78
+ * dependening on which of the two last held focus.
79
+ *
80
+ * Focuses the first TreeList cell by default.
81
+ */
82
+ focusLastActiveItem(): void;
83
+ /**
84
+ * Focuses the targeted TreeList cell regardless of the last peresisted target.
85
+ */
86
+ focusCell(rowIndex: number, colIndex: number): void;
87
+ /**
88
+ * Focuses the targeted Timeline task regardless of the last peresisted target.
89
+ */
90
+ focusTask(index: number): void;
91
+ /**
92
+ * Updates the focus target flags and notifies the active task to update its focused state.
93
+ */
94
+ handleTimelineFocusIn({ target }: FocusEvent): void;
95
+ /**
96
+ * Updates the timeline focus state flag and notifies the active task to update its focused state.
97
+ */
98
+ handleTimelineFocusOut({ relatedTarget }: FocusEvent): void;
99
+ /**
100
+ * Updates the focus target flags and corrects the TreeList focus target if needed.
101
+ * As the TreeList will keep its last focused cell with tabindex="0",
102
+ * this methods forcefully focuses the correct cell,
103
+ * when navigating in the Timeline has updated the expected TreeList focus target.
104
+ */
105
+ handleTreeListFocusIn(event: FocusEvent): void;
106
+ handleKeydown(event: KeyboardEvent): void;
107
+ /**
108
+ * Filters for task mousedown in the Timeline.
109
+ */
110
+ private handleTimelineMousedown;
111
+ /**
112
+ * Scrolls horizontally to the beginning of the target task if the beginning of its content is not in the viewport.
113
+ */
114
+ private scrollHorizontallyToTask;
115
+ /**
116
+ * Focus the TreeList on TreeList mousedown.
117
+ * A nasty hack to trick `handleTreeListFocusIn` into regarding the previous focus target as again the TreeList.
118
+ * Otherwise cell clicks are wrongly overwritten in `handleTreeListFocusIn` and the click focus target is not respected.
119
+ */
120
+ private focusTreeList;
121
+ /**
122
+ * Fires the `taskStatusChanges` event with active and focused status retrieved from
123
+ * `this.activeTimelineIndex` and `this.isTimelineFocused`.
124
+ */
125
+ private notifyTaskStatusChange;
126
+ }
@@ -0,0 +1,355 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as tslib_1 from "tslib";
6
+ import { Injectable, NgZone, Renderer2 } from '@angular/core';
7
+ import { Keys, hasObservers } from '@progress/kendo-angular-common';
8
+ import { Subject } from 'rxjs';
9
+ import { ScrollSyncService } from '../scrolling/scroll-sync.service';
10
+ import { fitToRange, getClosestTaskIndex, isClearButton, isPresent, isTask, isToolbar } from '../utils';
11
+ import { getIndexFromViewDigitKeyCode, isArrowUpDownKey, isExpandCollapseKey, isNavigationKey, isViewDigitKey } from './utils';
12
+ /**
13
+ * @hidden
14
+ */
15
+ let NavigationService = class NavigationService {
16
+ constructor(zone, renderer, scrollSyncService) {
17
+ this.zone = zone;
18
+ this.renderer = renderer;
19
+ this.scrollSyncService = scrollSyncService;
20
+ /**
21
+ * Notifies when the tasks' focused and interactive (tabindex) state has changed.
22
+ *
23
+ * All tasks are rendered with tabindex="-1".
24
+ * When one is clicked, or when some navigation key keyboard key is pressed, it should be focused, assigned the focus class, and its tabindex updated to 0.
25
+ * All other tasks should get -1 tabindex and have the focus class removed from them.
26
+ */
27
+ this.taskStatusChanges = new Subject();
28
+ /**
29
+ * Keeps track of whether the Timeline part is focused.
30
+ * Used when the index of the task elements change (tasks are changed, pushed to, spliced from, etc.)
31
+ * and their status should be updated accordingly.
32
+ */
33
+ this.isTimelineFocused = false;
34
+ /**
35
+ * Keeps track of which part has last been focused.
36
+ * Used when calling `gantt.focus()` to determine which part of the component should receive focus.
37
+ */
38
+ this.treeListLastActive = false;
39
+ /**
40
+ * Keeps track of which part has last been focused.
41
+ * Used when calling `gantt.focus()` to determine which part of the component should receive focus.
42
+ */
43
+ this.timelineLastActive = false;
44
+ this._enabled = false;
45
+ this._activeTimelineIndex = 0;
46
+ this._activeTreeListCell = { rowIndex: 0, colIndex: 0 };
47
+ }
48
+ /**
49
+ * Specifies whether navigation is enabled.
50
+ */
51
+ get enabled() {
52
+ return this._enabled;
53
+ }
54
+ /**
55
+ * Used to retrieve read-only data about the currently active task.
56
+ */
57
+ get activeTask() {
58
+ return {
59
+ activeIndex: this.activeTimelineIndex,
60
+ isFocused: this.isTimelineFocused
61
+ };
62
+ }
63
+ /**
64
+ * Persists the expected TreeList focused cell coords.
65
+ * When the tasks in the Timeline are navigated through, the expected TreeList focus target should also change,
66
+ * in order to allow back-tabbing from the Timeline to the same row in the TreeList.
67
+ */
68
+ set activeTreeListCell(cell) {
69
+ this._activeTreeListCell = cell;
70
+ }
71
+ get activeTreeListCell() {
72
+ const firstAvailableIndex = 0;
73
+ const lastAvailableRowIndex = this.treeListHeaderRowsCount + this.gantt.treeList.view.data.length - 1;
74
+ const rowIndex = fitToRange(this._activeTreeListCell.rowIndex, firstAvailableIndex, lastAvailableRowIndex);
75
+ const lastAvailableColIndex = this.gantt.columns.length;
76
+ const colIndex = fitToRange(this._activeTreeListCell.colIndex, firstAvailableIndex, lastAvailableColIndex);
77
+ return { rowIndex, colIndex };
78
+ }
79
+ /**
80
+ * Persists the expected Timeline focused task index.
81
+ * When the cells in the TreeList are navigated through, the expected Timeline focus target should also change,
82
+ * in order to allow tabbing from the TreeList to the same row in the Timeline.
83
+ */
84
+ set activeTimelineIndex(index) {
85
+ this._activeTimelineIndex = index;
86
+ }
87
+ get activeTimelineIndex() {
88
+ const firstAvailableIndex = 0;
89
+ const lastAvailableIndex = this.gantt.treeList.view.data.length - 1;
90
+ return fitToRange(this._activeTimelineIndex, firstAvailableIndex, lastAvailableIndex);
91
+ }
92
+ /**
93
+ * The TreeList row index takes into account the header and filter rows.
94
+ * Used when translating Timeline task indices to TreeList row indices.
95
+ */
96
+ get treeListHeaderRowsCount() {
97
+ // captures nested group header rows + filter row if we start supporting it at some point
98
+ return this.treeListElement.querySelectorAll('.k-grid-header tr').length;
99
+ }
100
+ initialize({ gantt, host, treeListElement, timelineElement }) {
101
+ // no private property setters in TypeScript, so use a getter and a poorly named private prop for this value
102
+ this._enabled = true;
103
+ this.gantt = gantt;
104
+ this.host = host;
105
+ this.treeListElement = treeListElement;
106
+ this.timelineElement = timelineElement;
107
+ // TODO: fix in the splitter package and remove
108
+ // move the splitbar HTML element between the two panes to keep the visial tabbing order in tact
109
+ const splitbar = this.host.querySelector('.k-splitbar');
110
+ if (isPresent(splitbar) && isPresent(splitbar.previousElementSibling) && isPresent(splitbar.after)) {
111
+ splitbar.after(splitbar.previousElementSibling);
112
+ }
113
+ this.zone.runOutsideAngular(() => {
114
+ this.eventListenerDisposers = [
115
+ this.renderer.listen(this.host, 'keydown', this.handleKeydown.bind(this)),
116
+ this.renderer.listen(this.treeListElement, 'mousedown', this.focusTreeList.bind(this)),
117
+ this.renderer.listen(this.treeListElement, 'focusin', this.handleTreeListFocusIn.bind(this)),
118
+ this.renderer.listen(this.timelineElement, 'mousedown', this.handleTimelineMousedown.bind(this)),
119
+ this.renderer.listen(this.timelineElement, 'focusin', this.handleTimelineFocusIn.bind(this)),
120
+ this.renderer.listen(this.timelineElement, 'focusout', this.handleTimelineFocusOut.bind(this))
121
+ ];
122
+ });
123
+ }
124
+ ngOnDestroy() {
125
+ if (isPresent(this.eventListenerDisposers)) {
126
+ this.eventListenerDisposers.forEach(removeListener => removeListener());
127
+ this.eventListenerDisposers = null;
128
+ }
129
+ this.gantt = null;
130
+ this.host = null;
131
+ this.treeListElement = null;
132
+ this.timelineElement = null;
133
+ }
134
+ /**
135
+ * Focuses either the last active TreeList cell, or the last active Timeline task,
136
+ * dependening on which of the two last held focus.
137
+ *
138
+ * Focuses the first TreeList cell by default.
139
+ */
140
+ focusLastActiveItem() {
141
+ if (this.gantt.data.length === 0 || (!this.treeListLastActive && !this.timelineLastActive)) {
142
+ this.focusCell(0, 0);
143
+ }
144
+ else if (this.treeListLastActive) {
145
+ const { rowIndex, colIndex } = this.activeTreeListCell;
146
+ this.gantt.treeList.focusCell(rowIndex, colIndex);
147
+ }
148
+ else if (this.timelineLastActive) {
149
+ this.focusTask(this.activeTimelineIndex);
150
+ }
151
+ }
152
+ /**
153
+ * Focuses the targeted TreeList cell regardless of the last peresisted target.
154
+ */
155
+ focusCell(rowIndex, colIndex) {
156
+ this.activeTreeListCell = { rowIndex, colIndex };
157
+ this.activeTimelineIndex = rowIndex - this.treeListHeaderRowsCount;
158
+ this.gantt.treeList.focusCell(this.activeTreeListCell.rowIndex, this.activeTreeListCell.colIndex);
159
+ }
160
+ /**
161
+ * Focuses the targeted Timeline task regardless of the last peresisted target.
162
+ */
163
+ focusTask(index) {
164
+ this.activeTimelineIndex = index;
165
+ this.isTimelineFocused = true;
166
+ this.activeTreeListCell = {
167
+ rowIndex: index + this.treeListHeaderRowsCount,
168
+ colIndex: this.activeTreeListCell.colIndex
169
+ };
170
+ this.notifyTaskStatusChange();
171
+ }
172
+ /**
173
+ * Updates the focus target flags and notifies the active task to update its focused state.
174
+ */
175
+ handleTimelineFocusIn({ target }) {
176
+ this.treeListLastActive = false;
177
+ this.timelineLastActive = true;
178
+ this.isTimelineFocused = true;
179
+ if (isTask(target, this.timelineElement)) {
180
+ this.notifyTaskStatusChange();
181
+ }
182
+ }
183
+ /**
184
+ * Updates the timeline focus state flag and notifies the active task to update its focused state.
185
+ */
186
+ handleTimelineFocusOut({ relatedTarget }) {
187
+ this.isTimelineFocused = this.timelineElement.contains(relatedTarget);
188
+ // update the task element only if the new focus target is not in the Timeline - focus change between tasks is handled in the focusin handler
189
+ if (!isTask(relatedTarget, this.timelineElement)) {
190
+ this.notifyTaskStatusChange();
191
+ }
192
+ }
193
+ /**
194
+ * Updates the focus target flags and corrects the TreeList focus target if needed.
195
+ * As the TreeList will keep its last focused cell with tabindex="0",
196
+ * this methods forcefully focuses the correct cell,
197
+ * when navigating in the Timeline has updated the expected TreeList focus target.
198
+ */
199
+ handleTreeListFocusIn(event) {
200
+ this.treeListLastActive = true;
201
+ this.timelineLastActive = false;
202
+ // if the previous focus target was in the TreeList, rely on its component navigation and just record the focused item index
203
+ if (this.treeListElement.contains(event.relatedTarget)) {
204
+ const { colIndex, rowIndex } = this.gantt.treeList.activeCell;
205
+ this.activeTreeListCell = { colIndex, rowIndex };
206
+ }
207
+ else {
208
+ // if the previous focus target was outside the TreeList, ensure the expected focus coords are used
209
+ const { rowIndex, colIndex } = this.activeTreeListCell;
210
+ this.gantt.treeList.focusCell(rowIndex, colIndex); // activates the target cell even if it has tabindex="-1"
211
+ }
212
+ this.activeTimelineIndex = this.gantt.treeList.activeCell.dataRowIndex;
213
+ this.notifyTaskStatusChange();
214
+ if (this.gantt.treeList.activeCell.dataRowIndex >= 0) {
215
+ this.scrollHorizontallyToTask(this.activeTimelineIndex);
216
+ this.scrollSyncService.syncScrollTop('treelist', 'timeline');
217
+ }
218
+ }
219
+ handleKeydown(event) {
220
+ const { keyCode, target, altKey } = event;
221
+ const isTimelineActive = this.timelineElement.contains(target);
222
+ if (isTimelineActive) {
223
+ if (isArrowUpDownKey(keyCode)) {
224
+ const direction = keyCode === Keys.ArrowUp ? -1 : 1;
225
+ this.activeTimelineIndex = this.activeTimelineIndex + direction;
226
+ this.activeTreeListCell = {
227
+ rowIndex: this.activeTimelineIndex + this.treeListHeaderRowsCount,
228
+ colIndex: this.activeTreeListCell.colIndex
229
+ };
230
+ }
231
+ else if (keyCode === Keys.Home) {
232
+ this.activeTimelineIndex = 0;
233
+ this.activeTreeListCell = {
234
+ rowIndex: this.activeTimelineIndex + this.treeListHeaderRowsCount,
235
+ colIndex: this.activeTreeListCell.colIndex
236
+ };
237
+ }
238
+ else if (keyCode === Keys.End) {
239
+ const lastAvailableIndex = this.gantt.treeList.view.data.length - 1;
240
+ this.activeTimelineIndex = lastAvailableIndex;
241
+ this.activeTreeListCell = {
242
+ rowIndex: this.activeTimelineIndex + this.treeListHeaderRowsCount,
243
+ colIndex: this.activeTreeListCell.colIndex
244
+ };
245
+ }
246
+ if (isNavigationKey(keyCode)) {
247
+ this.scrollHorizontallyToTask(this.activeTimelineIndex);
248
+ this.scrollSyncService.syncScrollTop('timeline', 'treelist');
249
+ this.notifyTaskStatusChange();
250
+ event.preventDefault();
251
+ }
252
+ if (keyCode === Keys.Space && hasObservers(this.gantt.selectionChange)) {
253
+ const task = this.gantt.renderedTreeListItems[this.activeTimelineIndex];
254
+ const selectionAction = this.gantt.getSelectionAction(event, task);
255
+ if (isPresent(task) && !this.gantt.isSameSelection(selectionAction, task)) {
256
+ this.zone.run(() => this.gantt.notifySelectionChange(task, selectionAction));
257
+ }
258
+ event.preventDefault();
259
+ }
260
+ if (keyCode === Keys.Enter && hasObservers(this.gantt.taskClick)) {
261
+ const task = this.gantt.renderedTreeListItems[this.activeTimelineIndex];
262
+ if (isPresent(task)) {
263
+ this.zone.run(() => this.gantt.notifyTaskClick(event, task, this.activeTimelineIndex));
264
+ }
265
+ event.preventDefault();
266
+ }
267
+ if (isExpandCollapseKey(keyCode, altKey)) {
268
+ const task = this.gantt.renderedTreeListItems[this.activeTimelineIndex];
269
+ if (isPresent(task) && this.gantt.hasChildren(task)) {
270
+ const shouldExpand = keyCode === Keys.ArrowRight;
271
+ const isExpanded = this.gantt.isExpanded(task);
272
+ const sameState = shouldExpand === isExpanded;
273
+ if (!sameState) {
274
+ this.zone.run(() => {
275
+ const expandEvent = { dataItem: task };
276
+ // order is not arbitrary
277
+ // the TreeList emits the individual events first, then the combined `expandStateChange` event
278
+ const individualEmitter = shouldExpand ? this.gantt.rowExpand : this.gantt.rowCollapse;
279
+ individualEmitter.emit(expandEvent);
280
+ this.gantt.expandStateChange.emit(Object.assign({}, expandEvent, { expand: shouldExpand }));
281
+ this.gantt.updateView();
282
+ this.scrollHorizontallyToTask(this.activeTimelineIndex);
283
+ });
284
+ }
285
+ }
286
+ event.preventDefault();
287
+ }
288
+ }
289
+ const isTreeListActive = this.treeListElement.contains(target);
290
+ if (keyCode === Keys.Delete && (isTimelineActive || isTreeListActive) && hasObservers(this.gantt.taskDelete)) {
291
+ const taskIndex = isTreeListActive ?
292
+ this.gantt.treeList.activeCell.dataRowIndex :
293
+ this.activeTimelineIndex;
294
+ const task = this.gantt.renderedTreeListItems[taskIndex];
295
+ if (isPresent(task)) {
296
+ this.zone.run(() => this.gantt.notifyTaskDelete(task));
297
+ }
298
+ }
299
+ if (isViewDigitKey(keyCode) && !isToolbar(target, this.host) && !this.gantt.isInEditMode) {
300
+ const targetViewIndex = getIndexFromViewDigitKeyCode(keyCode);
301
+ const availableViews = this.gantt.views.toArray();
302
+ const targetView = availableViews[targetViewIndex];
303
+ if (isPresent(targetView) && targetView.type !== this.gantt.activeView) {
304
+ this.zone.run(() => this.gantt.changeActiveView(targetView.type));
305
+ }
306
+ }
307
+ }
308
+ /**
309
+ * Filters for task mousedown in the Timeline.
310
+ */
311
+ handleTimelineMousedown({ target }) {
312
+ if (isTask(target, this.host) && !isClearButton(target, this.host)) {
313
+ const taskIndex = getClosestTaskIndex(target, this.host);
314
+ this.focusTask(taskIndex);
315
+ }
316
+ }
317
+ /**
318
+ * Scrolls horizontally to the beginning of the target task if the beginning of its content is not in the viewport.
319
+ */
320
+ scrollHorizontallyToTask(index) {
321
+ const task = this.timelineElement.querySelectorAll('.k-task-wrap').item(index);
322
+ if (!isPresent(task)) {
323
+ return;
324
+ }
325
+ // scroll horizontally to the item if less than 200px from the beginning of its content are visible
326
+ const targetVisibleWidth = 200;
327
+ const isScrollBeforeTask = (this.timelineElement.clientWidth + this.timelineElement.scrollLeft) < (task.offsetLeft + targetVisibleWidth);
328
+ const isScrollAfterTask = this.timelineElement.scrollLeft > task.offsetLeft;
329
+ if (isScrollBeforeTask || isScrollAfterTask) {
330
+ this.timelineElement.scrollLeft = task.offsetLeft;
331
+ }
332
+ }
333
+ /**
334
+ * Focus the TreeList on TreeList mousedown.
335
+ * A nasty hack to trick `handleTreeListFocusIn` into regarding the previous focus target as again the TreeList.
336
+ * Otherwise cell clicks are wrongly overwritten in `handleTreeListFocusIn` and the click focus target is not respected.
337
+ */
338
+ focusTreeList() {
339
+ this.gantt.treeList.focus();
340
+ }
341
+ /**
342
+ * Fires the `taskStatusChanges` event with active and focused status retrieved from
343
+ * `this.activeTimelineIndex` and `this.isTimelineFocused`.
344
+ */
345
+ notifyTaskStatusChange() {
346
+ this.taskStatusChanges.next(this.activeTask);
347
+ }
348
+ };
349
+ NavigationService = tslib_1.__decorate([
350
+ Injectable(),
351
+ tslib_1.__metadata("design:paramtypes", [NgZone,
352
+ Renderer2,
353
+ ScrollSyncService])
354
+ ], NavigationService);
355
+ export { NavigationService };
@@ -0,0 +1,26 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * @hidden
7
+ */
8
+ export declare const isArrowUpDownKey: (keyCode: number) => boolean;
9
+ /**
10
+ * @hidden
11
+ */
12
+ export declare const isNavigationKey: (keyCode: number) => boolean;
13
+ /**
14
+ * @hidden
15
+ */
16
+ export declare const isExpandCollapseKey: (keyCode: number, altKey: boolean) => boolean;
17
+ /**
18
+ * @hidden
19
+ */
20
+ export declare const isViewDigitKey: (keyCode: number) => boolean;
21
+ /**
22
+ * @hidden
23
+ *
24
+ * Returns the corresponding view index for the pressed digit key (Digit 1 => 0, Digit 2 => 1, etc.).
25
+ */
26
+ export declare const getIndexFromViewDigitKeyCode: (keyCode: number) => number;