@progress/kendo-angular-gantt 0.2.1-dev.202112101349 → 0.3.0-dev.202201190830

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 (171) hide show
  1. package/dist/cdn/js/kendo-angular-gantt.js +2 -2
  2. package/dist/cdn/main.js +4 -4
  3. package/dist/es/common/touch-enabled.js +9 -0
  4. package/dist/es/dependencies/utils.js +40 -5
  5. package/dist/es/dragging/dependency-drag-create.directive.js +347 -0
  6. package/dist/es/dragging/drag-validation-tooltip.component.js +27 -0
  7. package/dist/es/editing/add-task.component.js +94 -0
  8. package/dist/es/editing/dependencies-table.component.js +131 -0
  9. package/dist/es/editing/edit-dialog.component.js +39 -8
  10. package/dist/es/editing/edit.service.js +92 -8
  11. package/dist/es/editing/task-fields.component.js +43 -0
  12. package/dist/es/editing/{util.js → utils.js} +0 -0
  13. package/dist/es/gantt.component.js +408 -56
  14. package/dist/es/gantt.module.js +37 -9
  15. package/dist/es/index.js +9 -0
  16. package/dist/es/localization/gantt-localization.service.js +26 -0
  17. package/dist/es/localization/messages.js +45 -1
  18. package/dist/es/main.js +1 -0
  19. package/dist/es/models/dependency-type.enum.js +16 -0
  20. package/dist/es/models/events/{add-event.interface.js → dependency-add-event.interface.js} +0 -0
  21. package/dist/es/models/events/{edit-event.interface.js → task-add-event.interface.js} +0 -0
  22. package/dist/es/models/events/{remove-event.interface.js → task-delete-event.interface.js} +0 -0
  23. package/dist/es/models/models.js +1 -0
  24. package/dist/es/models/{toolbar-position.js → toolbar-settings.js} +0 -0
  25. package/dist/{es2015/models/events/add-event.interface.js → es/models/view-item.interface.js} +0 -0
  26. package/dist/{es2015/models/events/edit-event.interface.js → es/navigation/navigation-models.js} +0 -0
  27. package/dist/es/navigation/navigation.service.js +390 -0
  28. package/dist/es/navigation/utils.js +77 -0
  29. package/dist/es/package-metadata.js +1 -1
  30. package/dist/es/rendering/gantt-milestone-task.component.js +12 -6
  31. package/dist/es/rendering/gantt-summary-task.component.js +27 -6
  32. package/dist/es/rendering/gantt-task-base.js +84 -22
  33. package/dist/es/rendering/gantt-task.component.js +13 -8
  34. package/dist/es/rendering/gantt-tasks-table-body.component.js +13 -5
  35. package/dist/es/scrolling/drag-scroll-settings.js +20 -0
  36. package/dist/es/scrolling/timeline-scroll.directive.js +89 -0
  37. package/dist/es/scrolling/timeline-scroll.service.js +39 -0
  38. package/dist/es/scrolling/utils.js +80 -0
  39. package/dist/es/timeline/gantt-timeline.component.js +50 -4
  40. package/dist/es/toolbar/toolbar.component.js +20 -13
  41. package/dist/es/toolbar/view-selector.component.js +1 -1
  42. package/dist/es/utils.js +153 -12
  43. package/dist/es2015/common/touch-enabled.d.ts +9 -0
  44. package/dist/es2015/common/touch-enabled.js +9 -0
  45. package/dist/es2015/dependencies/utils.d.ts +15 -0
  46. package/dist/es2015/dependencies/utils.js +40 -5
  47. package/dist/es2015/dragging/dependency-drag-create.directive.d.ts +72 -0
  48. package/dist/es2015/dragging/dependency-drag-create.directive.js +324 -0
  49. package/dist/es2015/dragging/drag-validation-tooltip.component.d.ts +29 -0
  50. package/dist/es2015/dragging/drag-validation-tooltip.component.js +76 -0
  51. package/dist/es2015/editing/add-task.component.d.ts +45 -0
  52. package/dist/es2015/editing/add-task.component.js +102 -0
  53. package/dist/es2015/editing/dependencies-table.component.d.ts +39 -0
  54. package/dist/es2015/editing/dependencies-table.component.js +160 -0
  55. package/dist/es2015/editing/edit-dialog.component.d.ts +11 -4
  56. package/dist/es2015/editing/edit-dialog.component.js +66 -36
  57. package/dist/es2015/editing/edit.service.d.ts +24 -4
  58. package/dist/es2015/editing/edit.service.js +81 -11
  59. package/dist/es2015/editing/task-fields.component.d.ts +22 -0
  60. package/dist/es2015/editing/task-fields.component.js +67 -0
  61. package/dist/es2015/editing/{util.d.ts → utils.d.ts} +2 -2
  62. package/dist/es2015/editing/{util.js → utils.js} +0 -0
  63. package/dist/es2015/gantt.component.d.ts +134 -31
  64. package/dist/es2015/gantt.component.js +419 -61
  65. package/dist/es2015/gantt.module.js +37 -9
  66. package/dist/es2015/index.d.ts +9 -0
  67. package/dist/es2015/index.js +9 -0
  68. package/dist/es2015/index.metadata.json +1 -1
  69. package/dist/es2015/{models/events/edit-event.interface.d.ts → localization/gantt-localization.service.d.ts} +6 -10
  70. package/dist/es2015/localization/gantt-localization.service.js +25 -0
  71. package/dist/es2015/localization/messages.d.ts +46 -2
  72. package/dist/es2015/localization/messages.js +45 -1
  73. package/dist/es2015/main.d.ts +1 -0
  74. package/dist/es2015/main.js +1 -0
  75. package/dist/es2015/models/dependency-type.enum.d.ts +1 -1
  76. package/dist/es2015/models/dependency-type.enum.js +16 -0
  77. package/dist/es2015/models/events/dependency-add-event.interface.d.ts +26 -0
  78. package/dist/es2015/models/events/{remove-event.interface.js → dependency-add-event.interface.js} +0 -0
  79. package/dist/es2015/models/events/task-add-event.interface.d.ts +31 -0
  80. package/dist/es2015/models/{toolbar-position.js → events/task-add-event.interface.js} +0 -0
  81. package/dist/es2015/models/events/task-click-event.interface.d.ts +3 -3
  82. package/dist/es2015/models/events/task-delete-event.interface.d.ts +21 -0
  83. package/dist/es2015/models/events/task-delete-event.interface.js +4 -0
  84. package/dist/es2015/models/events/task-edit-event.interface.d.ts +36 -6
  85. package/dist/es2015/models/models.d.ts +6 -3
  86. package/dist/es2015/models/models.js +1 -0
  87. package/dist/es2015/models/toolbar-settings.d.ts +29 -0
  88. package/dist/es2015/models/toolbar-settings.js +4 -0
  89. package/dist/es2015/models/view-item.interface.d.ts +35 -0
  90. package/dist/es2015/models/view-item.interface.js +4 -0
  91. package/dist/es2015/navigation/navigation-models.d.ts +34 -0
  92. package/dist/es2015/navigation/navigation-models.js +4 -0
  93. package/dist/es2015/navigation/navigation.service.d.ts +126 -0
  94. package/dist/es2015/navigation/navigation.service.js +355 -0
  95. package/dist/es2015/navigation/utils.d.ts +26 -0
  96. package/dist/es2015/navigation/utils.js +69 -0
  97. package/dist/es2015/package-metadata.js +1 -1
  98. package/dist/es2015/rendering/gantt-milestone-task.component.d.ts +3 -1
  99. package/dist/es2015/rendering/gantt-milestone-task.component.js +35 -8
  100. package/dist/es2015/rendering/gantt-summary-task.component.d.ts +5 -1
  101. package/dist/es2015/rendering/gantt-summary-task.component.js +47 -8
  102. package/dist/es2015/rendering/gantt-task-base.d.ts +20 -6
  103. package/dist/es2015/rendering/gantt-task-base.js +75 -22
  104. package/dist/es2015/rendering/gantt-task.component.d.ts +4 -2
  105. package/dist/es2015/rendering/gantt-task.component.js +47 -13
  106. package/dist/es2015/rendering/gantt-tasks-table-body.component.d.ts +6 -3
  107. package/dist/es2015/rendering/gantt-tasks-table-body.component.js +27 -9
  108. package/dist/es2015/scrolling/drag-scroll-settings.d.ts +47 -0
  109. package/dist/es2015/scrolling/drag-scroll-settings.js +20 -0
  110. package/dist/es2015/scrolling/scroll-sync.service.d.ts +1 -1
  111. package/dist/es2015/scrolling/timeline-scroll.directive.d.ts +24 -0
  112. package/dist/es2015/scrolling/timeline-scroll.directive.js +78 -0
  113. package/dist/es2015/scrolling/timeline-scroll.service.d.ts +20 -0
  114. package/dist/es2015/scrolling/timeline-scroll.service.js +44 -0
  115. package/dist/es2015/scrolling/utils.d.ts +29 -0
  116. package/dist/es2015/scrolling/utils.js +80 -0
  117. package/dist/es2015/timeline/gantt-timeline.component.d.ts +29 -4
  118. package/dist/es2015/timeline/gantt-timeline.component.js +67 -5
  119. package/dist/es2015/toolbar/toolbar-template.directive.d.ts +1 -1
  120. package/dist/es2015/toolbar/toolbar.component.d.ts +6 -5
  121. package/dist/es2015/toolbar/toolbar.component.js +22 -13
  122. package/dist/es2015/toolbar/view-selector.component.js +3 -1
  123. package/dist/es2015/utils.d.ts +77 -8
  124. package/dist/es2015/utils.js +153 -12
  125. package/dist/fesm2015/index.js +5258 -3012
  126. package/dist/fesm5/index.js +2862 -733
  127. package/dist/npm/common/touch-enabled.js +11 -0
  128. package/dist/npm/dependencies/utils.js +40 -5
  129. package/dist/npm/dragging/dependency-drag-create.directive.js +349 -0
  130. package/dist/npm/dragging/drag-validation-tooltip.component.js +29 -0
  131. package/dist/npm/editing/add-task.component.js +96 -0
  132. package/dist/npm/editing/dependencies-table.component.js +133 -0
  133. package/dist/npm/editing/edit-dialog.component.js +38 -7
  134. package/dist/npm/editing/edit.service.js +91 -7
  135. package/dist/npm/editing/task-fields.component.js +45 -0
  136. package/dist/npm/editing/{util.js → utils.js} +0 -0
  137. package/dist/npm/gantt.component.js +409 -57
  138. package/dist/npm/gantt.module.js +35 -7
  139. package/dist/npm/index.js +18 -0
  140. package/dist/npm/localization/gantt-localization.service.js +28 -0
  141. package/dist/npm/localization/messages.js +45 -1
  142. package/dist/npm/main.js +2 -0
  143. package/dist/npm/models/dependency-type.enum.js +16 -0
  144. package/dist/npm/models/events/{add-event.interface.js → dependency-add-event.interface.js} +0 -0
  145. package/dist/npm/models/events/{edit-event.interface.js → task-add-event.interface.js} +0 -0
  146. package/dist/npm/models/events/{remove-event.interface.js → task-delete-event.interface.js} +0 -0
  147. package/dist/npm/models/models.js +2 -0
  148. package/dist/npm/models/{toolbar-position.js → toolbar-settings.js} +0 -0
  149. package/dist/npm/models/view-item.interface.js +6 -0
  150. package/dist/npm/navigation/navigation-models.js +6 -0
  151. package/dist/npm/navigation/navigation.service.js +392 -0
  152. package/dist/npm/navigation/utils.js +79 -0
  153. package/dist/npm/package-metadata.js +1 -1
  154. package/dist/npm/rendering/gantt-milestone-task.component.js +11 -5
  155. package/dist/npm/rendering/gantt-summary-task.component.js +26 -5
  156. package/dist/npm/rendering/gantt-task-base.js +84 -22
  157. package/dist/npm/rendering/gantt-task.component.js +12 -7
  158. package/dist/npm/rendering/gantt-tasks-table-body.component.js +13 -5
  159. package/dist/npm/scrolling/drag-scroll-settings.js +22 -0
  160. package/dist/npm/scrolling/timeline-scroll.directive.js +91 -0
  161. package/dist/npm/scrolling/timeline-scroll.service.js +41 -0
  162. package/dist/npm/scrolling/utils.js +83 -0
  163. package/dist/npm/timeline/gantt-timeline.component.js +49 -3
  164. package/dist/npm/toolbar/toolbar.component.js +18 -11
  165. package/dist/npm/toolbar/view-selector.component.js +1 -1
  166. package/dist/npm/utils.js +153 -12
  167. package/dist/systemjs/kendo-angular-gantt.js +1 -1
  168. package/package.json +7 -4
  169. package/dist/es2015/models/events/add-event.interface.d.ts +0 -16
  170. package/dist/es2015/models/events/remove-event.interface.d.ts +0 -16
  171. package/dist/es2015/models/toolbar-position.d.ts +0 -9
@@ -0,0 +1,72 @@
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 { AfterViewInit, NgZone, OnDestroy, Renderer2 } from '@angular/core';
6
+ import { PopupService } from '@progress/kendo-angular-popup';
7
+ import { GanttComponent } from '../gantt.component';
8
+ import { MappingService } from '../common/mapping.service';
9
+ import { TimelineScrollService } from '../scrolling/timeline-scroll.service';
10
+ /**
11
+ * A directive which enables the creation of new dependencies via dragging.
12
+ */
13
+ export declare class DependencyDragCreateDirective implements AfterViewInit, OnDestroy {
14
+ private gantt;
15
+ private zone;
16
+ private renderer;
17
+ private mapper;
18
+ private popupService;
19
+ private timelineScrollService;
20
+ /**
21
+ * Specifies whether the validation tooltip will be displayed during drag operations.
22
+ *
23
+ * @default true
24
+ */
25
+ displayValidationTooltip: boolean;
26
+ private readonly container;
27
+ private readonly polyline;
28
+ private readonly popupContainer;
29
+ /**
30
+ * Points to the drag clue where the dragging started (the FROM task).
31
+ * Used to attach/detach classes to the target element and its task wrapper parent element.
32
+ */
33
+ private fromTaskClue;
34
+ /**
35
+ * The drag start element coords will be the same through the enitre dragging session, so compute them on press and cache them.
36
+ */
37
+ private polylineStartCoords;
38
+ /**
39
+ * Stored during dragging to be consumed by the container scroll subscription.
40
+ * The scroll event doesn't expose the current pointer position, so it has to be stored separately.
41
+ */
42
+ private currentPointerClientCoords;
43
+ private scrollListenerDisposer;
44
+ private dragPopup;
45
+ private dragSubscriptions;
46
+ constructor(gantt: GanttComponent, zone: NgZone, renderer: Renderer2, mapper: MappingService, popupService: PopupService, timelineScrollService: TimelineScrollService);
47
+ ngAfterViewInit(): void;
48
+ ngOnDestroy(): void;
49
+ private subscribeDraggable;
50
+ private unsubscribeDraggable;
51
+ private handlePress;
52
+ private handleDrag;
53
+ private handleRelease;
54
+ private updatePolyline;
55
+ private clearPolyline;
56
+ private assignDragStartClasses;
57
+ private removeDragStartClasses;
58
+ private scrollPointIntoView;
59
+ private cancelScroll;
60
+ private addScrollListener;
61
+ private removeScrollListener;
62
+ private openDragPopup;
63
+ private updateDragPopup;
64
+ private closeDragPopup;
65
+ private extractTaskName;
66
+ private getTooltipContext;
67
+ /**
68
+ * Restricts the popup position to not go below the scroll height or width of the container.
69
+ * Flips the position of the popup when there's not enough vertical space in the visible part of the container to render the popup.
70
+ */
71
+ private normalizePopupPosition;
72
+ }
@@ -0,0 +1,324 @@
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 { Directive, Input, NgZone, Renderer2 } from '@angular/core';
7
+ import { isDocumentAvailable } from '@progress/kendo-angular-common';
8
+ import { PopupService } from '@progress/kendo-angular-popup';
9
+ import { GanttComponent } from '../gantt.component';
10
+ import { MappingService } from '../common/mapping.service';
11
+ import { TimelineScrollService } from '../scrolling/timeline-scroll.service';
12
+ import { DragValidationTooltipComponent } from './drag-validation-tooltip.component';
13
+ import { clientToOffsetCoords, getElementClientCenterCoords } from '../dependencies/utils';
14
+ import { isPresent, isDependencyDragClue, getClosestTaskWrapper, getDependencyTypeFromTargetTasks, getClosestTaskIndex, sameTaskClues, isTaskWrapper, fitToRange } from '../utils';
15
+ import { elementFromPoint } from '../utils';
16
+ /**
17
+ * When added to the .k-task-dot, the element will be kept with hover styles.
18
+ * Used for the drag clue from which the dragging has started.
19
+ */
20
+ const DRAG_CLUE_HOVER_CLASS = 'k-state-hover';
21
+ /**
22
+ * Add the selection disabling class to the enitre container.
23
+ * Otherwise existing selection on a given task text prevents dragging the clue even if the clue has `user-select: none` styles.
24
+ */
25
+ const USER_SELECT_NONE_CLASS = 'k-user-select-none';
26
+ /**
27
+ * When added to the .k-task-wrap, the containing .k-task-dot elements will be kept visible even when not hovered.
28
+ * Used for the drag clue from which the dragging has started.
29
+ */
30
+ const TASK_WRAPPER_DRAG_CLASS = 'k-origin';
31
+ /**
32
+ * Use 20px margin between the pointer and the popup.
33
+ * Could be made user-configurable if there's demand.
34
+ */
35
+ const DEFAULT_POPUP_VERTICAL_MARGIN = 20;
36
+ /**
37
+ * A directive which enables the creation of new dependencies via dragging.
38
+ */
39
+ let DependencyDragCreateDirective = class DependencyDragCreateDirective {
40
+ constructor(gantt, zone, renderer, mapper, popupService, timelineScrollService) {
41
+ this.gantt = gantt;
42
+ this.zone = zone;
43
+ this.renderer = renderer;
44
+ this.mapper = mapper;
45
+ this.popupService = popupService;
46
+ this.timelineScrollService = timelineScrollService;
47
+ /**
48
+ * Specifies whether the validation tooltip will be displayed during drag operations.
49
+ *
50
+ * @default true
51
+ */
52
+ this.displayValidationTooltip = true;
53
+ this.gantt.renderDependencyDragClues = true;
54
+ }
55
+ get container() {
56
+ if (!isPresent(this.gantt.timeline) || !isPresent(this.gantt.timeline.timelineContent)) {
57
+ return null;
58
+ }
59
+ return this.gantt.timeline.timelineContent.nativeElement;
60
+ }
61
+ get polyline() {
62
+ if (!isPresent(this.gantt.timeline) || !isPresent(this.gantt.timeline.dependencyDragCreatePolyline)) {
63
+ return null;
64
+ }
65
+ return this.gantt.timeline.dependencyDragCreatePolyline.nativeElement;
66
+ }
67
+ get popupContainer() {
68
+ if (!isPresent(this.gantt.timeline) || !isPresent(this.gantt.timeline.dragPopupContainer)) {
69
+ return null;
70
+ }
71
+ return this.gantt.timeline.dragPopupContainer;
72
+ }
73
+ ngAfterViewInit() {
74
+ this.subscribeDraggable();
75
+ this.addScrollListener();
76
+ }
77
+ ngOnDestroy() {
78
+ this.unsubscribeDraggable();
79
+ this.removeScrollListener();
80
+ this.fromTaskClue = null;
81
+ this.cancelScroll();
82
+ this.closeDragPopup();
83
+ }
84
+ subscribeDraggable() {
85
+ this.dragSubscriptions = this.gantt.timeline.timelineContainerPress
86
+ .subscribe(this.handlePress.bind(this));
87
+ this.dragSubscriptions.add(this.gantt.timeline.timelineContainerDrag
88
+ .subscribe(this.handleDrag.bind(this)));
89
+ this.dragSubscriptions.add(this.gantt.timeline.timelineContainerRelease
90
+ .subscribe(this.handleRelease.bind(this)));
91
+ }
92
+ unsubscribeDraggable() {
93
+ if (isPresent(this.dragSubscriptions)) {
94
+ this.dragSubscriptions.unsubscribe();
95
+ this.dragSubscriptions = null;
96
+ }
97
+ }
98
+ handlePress({ clientX, clientY }) {
99
+ // using `originalEvent.target` is not reliable under mobile devices with the current implementation of the draggable, so use this instead
100
+ const target = elementFromPoint(clientX, clientY);
101
+ if (isDependencyDragClue(target)) {
102
+ this.fromTaskClue = target;
103
+ this.assignDragStartClasses(this.fromTaskClue);
104
+ // use the center of the target clue as polyline starting point
105
+ const dragClueCenterCoords = getElementClientCenterCoords(this.fromTaskClue);
106
+ // the polyline uses `position: aboslute`, so translate the client coordinates to offset coordinates (`left` and `top` relative to the timeline container)
107
+ this.polylineStartCoords = clientToOffsetCoords(dragClueCenterCoords.left, dragClueCenterCoords.top, this.container);
108
+ }
109
+ }
110
+ handleDrag({ clientX, clientY }) {
111
+ if (isPresent(this.fromTaskClue)) {
112
+ // the polyline uses `position: aboslute`, so translate the client coordinates to offset coordinates (`left` and `top` relative to the timeline container)
113
+ const pointerOffsetCoords = clientToOffsetCoords(clientX, clientY, this.container);
114
+ // the start coords are calculated just once per drag session in handlePress
115
+ // use the current drag coords as polyline end coords
116
+ this.updatePolyline(this.polylineStartCoords, pointerOffsetCoords);
117
+ this.currentPointerClientCoords = { left: clientX, top: clientY };
118
+ if (this.gantt.dragScrollSettings.enabled) {
119
+ // use client coordinates for scroll trigger
120
+ this.scrollPointIntoView(this.currentPointerClientCoords);
121
+ }
122
+ if (this.displayValidationTooltip) {
123
+ this.updateDragPopup(pointerOffsetCoords);
124
+ }
125
+ }
126
+ }
127
+ handleRelease({ clientX, clientY }) {
128
+ if (!isPresent(this.fromTaskClue)) {
129
+ return;
130
+ }
131
+ // using `originalEvent.target` is not reliable under mobile devices with the current implementation of the draggable, so use this instead
132
+ const target = elementFromPoint(clientX, clientY);
133
+ if (isDependencyDragClue(target) && !sameTaskClues(this.fromTaskClue, target, this.container)) {
134
+ this.zone.run(() => {
135
+ const fromTaskClue = this.fromTaskClue;
136
+ const toTaskClue = target;
137
+ const fromTask = this.gantt.renderedTreeListItems[getClosestTaskIndex(fromTaskClue, this.container)];
138
+ const toTask = this.gantt.renderedTreeListItems[getClosestTaskIndex(toTaskClue, this.container)];
139
+ const dependencyType = getDependencyTypeFromTargetTasks(fromTaskClue, toTaskClue);
140
+ const { fromId, toId, type } = this.mapper.dependencyFields;
141
+ this.gantt.dependencyAdd.emit({
142
+ fromTask: fromTask,
143
+ toTask: toTask,
144
+ type: dependencyType,
145
+ isValid: this.gantt.validateNewDependency({
146
+ [fromId]: this.mapper.extractFromTask(fromTask, 'id'),
147
+ [toId]: this.mapper.extractFromTask(toTask, 'id'),
148
+ [type]: dependencyType
149
+ })
150
+ });
151
+ });
152
+ }
153
+ this.clearPolyline();
154
+ this.removeDragStartClasses(this.fromTaskClue);
155
+ this.fromTaskClue = null;
156
+ this.cancelScroll();
157
+ this.closeDragPopup();
158
+ }
159
+ updatePolyline(start, end) {
160
+ const points = `${start.left},${start.top} ${end.left},${end.top}`;
161
+ this.renderer.setAttribute(this.polyline, 'points', points);
162
+ }
163
+ clearPolyline() {
164
+ this.renderer.removeAttribute(this.polyline, 'points');
165
+ }
166
+ assignDragStartClasses(dragClue) {
167
+ if (!isPresent(dragClue)) {
168
+ return;
169
+ }
170
+ this.renderer.addClass(this.container, USER_SELECT_NONE_CLASS);
171
+ this.renderer.addClass(dragClue, DRAG_CLUE_HOVER_CLASS);
172
+ const taskWrapper = getClosestTaskWrapper(dragClue, this.container);
173
+ if (isPresent(taskWrapper)) {
174
+ this.renderer.addClass(taskWrapper, TASK_WRAPPER_DRAG_CLASS);
175
+ }
176
+ }
177
+ removeDragStartClasses(dragClue) {
178
+ if (!isPresent(dragClue)) {
179
+ return;
180
+ }
181
+ this.renderer.removeClass(this.container, USER_SELECT_NONE_CLASS);
182
+ this.renderer.removeClass(dragClue, DRAG_CLUE_HOVER_CLASS);
183
+ const taskWrapper = getClosestTaskWrapper(dragClue, this.container);
184
+ if (isPresent(taskWrapper)) {
185
+ this.renderer.removeClass(taskWrapper, TASK_WRAPPER_DRAG_CLASS);
186
+ }
187
+ }
188
+ scrollPointIntoView({ left, top }) {
189
+ this.timelineScrollService.requestScrollCancel();
190
+ this.timelineScrollService.requestHorizontalScroll(left);
191
+ this.timelineScrollService.requestVerticalScroll(top);
192
+ }
193
+ cancelScroll() {
194
+ this.timelineScrollService.requestScrollCancel();
195
+ }
196
+ addScrollListener() {
197
+ if (!isDocumentAvailable()) {
198
+ return;
199
+ }
200
+ this.zone.runOutsideAngular(() => this.scrollListenerDisposer = this.renderer.listen(this.container, 'scroll', () => {
201
+ // update the polyline only if we're currently dragging
202
+ if (isPresent(this.fromTaskClue) && isPresent(this.currentPointerClientCoords)) {
203
+ const { left, top } = this.currentPointerClientCoords;
204
+ const pointerOffsetCoords = clientToOffsetCoords(left, top, this.container);
205
+ this.updatePolyline(this.polylineStartCoords, pointerOffsetCoords);
206
+ if (this.displayValidationTooltip) {
207
+ this.updateDragPopup(pointerOffsetCoords);
208
+ }
209
+ }
210
+ }));
211
+ }
212
+ removeScrollListener() {
213
+ if (isPresent(this.scrollListenerDisposer)) {
214
+ this.scrollListenerDisposer();
215
+ this.scrollListenerDisposer = null;
216
+ }
217
+ }
218
+ openDragPopup() {
219
+ if (isPresent(this.dragPopup)) {
220
+ this.closeDragPopup();
221
+ }
222
+ this.dragPopup = this.popupService.open({
223
+ animate: false,
224
+ content: DragValidationTooltipComponent,
225
+ appendTo: this.popupContainer,
226
+ positionMode: 'absolute',
227
+ popupClass: 'k-popup-transparent'
228
+ });
229
+ }
230
+ updateDragPopup(pointerOffsetPosition) {
231
+ if (!isPresent(this.dragPopup)) {
232
+ this.openDragPopup();
233
+ }
234
+ const tooltip = this.dragPopup.content.instance;
235
+ const { fromTaskName, toTaskName, isValid, showValidityStatus } = this.getTooltipContext();
236
+ if (tooltip.fromTaskName !== fromTaskName ||
237
+ tooltip.toTaskName !== toTaskName ||
238
+ tooltip.isValid !== isValid ||
239
+ tooltip.showValidityStatus !== showValidityStatus) {
240
+ tooltip.fromTaskName = fromTaskName;
241
+ tooltip.toTaskName = toTaskName;
242
+ tooltip.isValid = isValid;
243
+ tooltip.showValidityStatus = showValidityStatus;
244
+ this.dragPopup.content.changeDetectorRef.detectChanges();
245
+ }
246
+ this.dragPopup.popup.instance.offset = this.normalizePopupPosition(pointerOffsetPosition);
247
+ this.dragPopup.popup.changeDetectorRef.detectChanges();
248
+ }
249
+ closeDragPopup() {
250
+ if (isPresent(this.dragPopup)) {
251
+ this.dragPopup.close();
252
+ this.dragPopup = null;
253
+ }
254
+ }
255
+ extractTaskName(target) {
256
+ if (!isTaskWrapper(target, this.container)) {
257
+ return null;
258
+ }
259
+ const taskIndex = getClosestTaskIndex(target, this.container);
260
+ const task = this.gantt.renderedTreeListItems[taskIndex];
261
+ const taskName = this.mapper.extractFromTask(task, 'title');
262
+ return taskName;
263
+ }
264
+ getTooltipContext() {
265
+ const fromTaskName = this.extractTaskName(this.fromTaskClue);
266
+ const currentPointerTarget = elementFromPoint(this.currentPointerClientCoords.left, this.currentPointerClientCoords.top);
267
+ const toTaskName = isTaskWrapper(currentPointerTarget, this.container) && !sameTaskClues(this.fromTaskClue, currentPointerTarget, this.container) ?
268
+ this.extractTaskName(currentPointerTarget) :
269
+ '';
270
+ const showValidityStatus = isDependencyDragClue(currentPointerTarget) && !sameTaskClues(this.fromTaskClue, currentPointerTarget, this.container);
271
+ const { fromId, toId, type } = this.mapper.dependencyFields;
272
+ return {
273
+ fromTaskName,
274
+ toTaskName,
275
+ showValidityStatus,
276
+ isValid: showValidityStatus && this.gantt.validateNewDependency({
277
+ [fromId]: this.mapper.extractFromTask(this.gantt.renderedTreeListItems[getClosestTaskIndex(this.fromTaskClue, this.container)], 'id'),
278
+ [toId]: this.mapper.extractFromTask(this.gantt.renderedTreeListItems[getClosestTaskIndex(currentPointerTarget, this.container)], 'id'),
279
+ [type]: getDependencyTypeFromTargetTasks(this.fromTaskClue, currentPointerTarget)
280
+ })
281
+ };
282
+ }
283
+ /**
284
+ * Restricts the popup position to not go below the scroll height or width of the container.
285
+ * Flips the position of the popup when there's not enough vertical space in the visible part of the container to render the popup.
286
+ */
287
+ normalizePopupPosition(pointerOffsetPosition) {
288
+ let top = pointerOffsetPosition.top + DEFAULT_POPUP_VERTICAL_MARGIN;
289
+ const containerClientBottom = this.container.clientHeight + this.container.scrollTop;
290
+ const popupHeight = this.dragPopup.popupElement.querySelector('.k-tooltip').clientHeight;
291
+ const enoughSpaceToRender = top < containerClientBottom - popupHeight;
292
+ // flip the popup above the pointer if there's not enough space in the bottom of the container
293
+ if (!enoughSpaceToRender) {
294
+ // margin * 2 to account for the already applied margin
295
+ top -= popupHeight + (DEFAULT_POPUP_VERTICAL_MARGIN * 2);
296
+ }
297
+ // center the popup horizontally according to the pointer position
298
+ const popupWidth = this.dragPopup.popupElement.querySelector('.k-tooltip').clientWidth;
299
+ const left = pointerOffsetPosition.left - popupWidth / 2;
300
+ // don't allow the popup to be cut out of the viewport
301
+ const minLeftTop = 0;
302
+ // restrict the popup from being positioned beyond or before the available scrollable space
303
+ return {
304
+ left: fitToRange(left, minLeftTop, this.container.scrollWidth - popupWidth),
305
+ top: fitToRange(top, minLeftTop, this.container.scrollHeight - popupHeight)
306
+ };
307
+ }
308
+ };
309
+ tslib_1.__decorate([
310
+ Input(),
311
+ tslib_1.__metadata("design:type", Boolean)
312
+ ], DependencyDragCreateDirective.prototype, "displayValidationTooltip", void 0);
313
+ DependencyDragCreateDirective = tslib_1.__decorate([
314
+ Directive({
315
+ selector: '[kendoGanttDependencyDragCreate]'
316
+ }),
317
+ tslib_1.__metadata("design:paramtypes", [GanttComponent,
318
+ NgZone,
319
+ Renderer2,
320
+ MappingService,
321
+ PopupService,
322
+ TimelineScrollService])
323
+ ], DependencyDragCreateDirective);
324
+ export { DependencyDragCreateDirective };
@@ -0,0 +1,29 @@
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 class DragValidationTooltipComponent {
9
+ /**
10
+ * Sets the status class of the attempted operation.
11
+ * Note that the status will be ignored and the `neutral` status class will be rendered,
12
+ * if the any of the fromTaskName or toTaskName are not populated.
13
+ */
14
+ isValid: boolean;
15
+ /**
16
+ * The name of the task where the dragging has started.
17
+ */
18
+ fromTaskName: string;
19
+ /**
20
+ * The name of the task which is being currently hovered.
21
+ */
22
+ toTaskName: string;
23
+ /**
24
+ * Specifies whether the valid/invalid validity classes should be rendered or not.
25
+ * Prevents the validity classes being rendered when e.g. the same task is hovered during drag,
26
+ * or when a task body is hovered and not an actual drag clue.
27
+ */
28
+ showValidityStatus: boolean;
29
+ }
@@ -0,0 +1,76 @@
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 { Component } from '@angular/core';
7
+ /**
8
+ * @hidden
9
+ */
10
+ let DragValidationTooltipComponent = class DragValidationTooltipComponent {
11
+ /**
12
+ * @hidden
13
+ */
14
+ constructor() {
15
+ /**
16
+ * Sets the status class of the attempted operation.
17
+ * Note that the status will be ignored and the `neutral` status class will be rendered,
18
+ * if the any of the fromTaskName or toTaskName are not populated.
19
+ */
20
+ this.isValid = false;
21
+ }
22
+ };
23
+ DragValidationTooltipComponent = tslib_1.__decorate([
24
+ Component({
25
+ template: `
26
+ <div
27
+ class="k-tooltip k-gantt-tooltip-validation"
28
+ [class.k-gantt-tooltip-valid]="showValidityStatus && isValid"
29
+ [class.k-gantt-tooltip-invalid]="showValidityStatus && !isValid"
30
+ >
31
+ <div class="k-gantt-tooltip-validation-row">
32
+ <span class="k-gantt-tooltip-validation-label">From:</span>
33
+ <span class="k-gantt-tooltip-validation-value">{{ fromTaskName }}</span>
34
+ </div>
35
+ <div class="k-gantt-tooltip-validation-row">
36
+ <span class="k-gantt-tooltip-validation-label">To:</span>
37
+ <span class="k-gantt-tooltip-validation-value">{{ toTaskName }}</span>
38
+ </div>
39
+ </div>
40
+ `,
41
+ styles: [`
42
+ .k-gantt-tooltip-validation {
43
+ max-width: 200px;
44
+ display: block;
45
+ }
46
+ .k-gantt-tooltip-validation::before {
47
+ content: '';
48
+ position: absolute;
49
+ left: 0;
50
+ top: 0;
51
+ width: 4px;
52
+ height: 100%;
53
+ background: #656565;
54
+ }
55
+ .k-gantt-tooltip-validation.k-gantt-tooltip-valid::before {
56
+ background: #37B400;
57
+ }
58
+ .k-gantt-tooltip-validation.k-gantt-tooltip-invalid::before {
59
+ background: #F31700;
60
+ }
61
+ .k-gantt-tooltip-validation-row {
62
+ white-space: nowrap;
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ }
66
+ .k-gantt-tooltip-validation-label {
67
+ display: inline-flex;
68
+ width: 50px;
69
+ }
70
+ .k-gantt-tooltip-validation-value {
71
+ font-weight: bold;
72
+ }
73
+ `]
74
+ })
75
+ ], DragValidationTooltipComponent);
76
+ export { DragValidationTooltipComponent };
@@ -0,0 +1,45 @@
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 } from '@angular/core';
6
+ import { LocalizationService } from '@progress/kendo-angular-l10n';
7
+ import { PreventableEvent } from '@progress/kendo-angular-treelist';
8
+ import { GanttAddTaskActionItem } from '../models/events/task-add-event.interface';
9
+ import { EditService } from './edit.service';
10
+ /**
11
+ * The UI for adding new items to the Gantt.
12
+ * Use it within a toolbar template to provide a custom icon or list of options.
13
+ */
14
+ export declare class GanttAddTaskComponent {
15
+ private localizationService;
16
+ private editService;
17
+ private ngZone;
18
+ /**
19
+ * Sets the data of the DropDownButton.
20
+ * > The data has to be provided in an array-like list.
21
+ */
22
+ data: GanttAddTaskActionItem[];
23
+ /**
24
+ * Defines the name of an existing icon in a Kendo UI theme.
25
+ * @default 'plus'
26
+ */
27
+ icon: string;
28
+ constructor(localizationService: LocalizationService, editService: EditService, ngZone: NgZone);
29
+ /**
30
+ * @hidden
31
+ */
32
+ getText(message: string): string;
33
+ /**
34
+ * @hidden
35
+ */
36
+ handleOpen(e: PreventableEvent): void;
37
+ /**
38
+ * @hidden
39
+ */
40
+ handleMouseClick(): void;
41
+ /**
42
+ * @hidden
43
+ */
44
+ handleItemClick(e: any): void;
45
+ }
@@ -0,0 +1,102 @@
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 { Component, Input, NgZone } from '@angular/core';
7
+ import { LocalizationService } from '@progress/kendo-angular-l10n';
8
+ import { EditService } from './edit.service';
9
+ /**
10
+ * The UI for adding new items to the Gantt.
11
+ * Use it within a toolbar template to provide a custom icon or list of options.
12
+ */
13
+ let GanttAddTaskComponent = class GanttAddTaskComponent {
14
+ constructor(localizationService, editService, ngZone) {
15
+ this.localizationService = localizationService;
16
+ this.editService = editService;
17
+ this.ngZone = ngZone;
18
+ /**
19
+ * Sets the data of the DropDownButton.
20
+ * > The data has to be provided in an array-like list.
21
+ */
22
+ this.data = [{
23
+ text: this.getText('addChildText'),
24
+ type: 'addChild'
25
+ }, {
26
+ text: this.getText('addAboveText'),
27
+ type: 'addAbove'
28
+ }, {
29
+ text: this.getText('addBelowText'),
30
+ type: 'addBelow'
31
+ }];
32
+ /**
33
+ * Defines the name of an existing icon in a Kendo UI theme.
34
+ * @default 'plus'
35
+ */
36
+ this.icon = 'plus';
37
+ }
38
+ /**
39
+ * @hidden
40
+ */
41
+ getText(message) {
42
+ return this.localizationService.get(message);
43
+ }
44
+ /**
45
+ * @hidden
46
+ */
47
+ handleOpen(e) {
48
+ if (!this.editService.getSelectedItem()) {
49
+ e.preventDefault();
50
+ }
51
+ }
52
+ /**
53
+ * @hidden
54
+ */
55
+ handleMouseClick() {
56
+ if (!this.editService.getSelectedItem()) {
57
+ this.ngZone.run(() => {
58
+ this.editService.addEvent.next({
59
+ selectedItem: null,
60
+ actionType: 'addTask'
61
+ });
62
+ });
63
+ }
64
+ }
65
+ /**
66
+ * @hidden
67
+ */
68
+ handleItemClick(e) {
69
+ this.editService.addEvent.next({
70
+ actionType: e.type,
71
+ selectedItem: null
72
+ });
73
+ }
74
+ };
75
+ tslib_1.__decorate([
76
+ Input(),
77
+ tslib_1.__metadata("design:type", Array)
78
+ ], GanttAddTaskComponent.prototype, "data", void 0);
79
+ tslib_1.__decorate([
80
+ Input(),
81
+ tslib_1.__metadata("design:type", String)
82
+ ], GanttAddTaskComponent.prototype, "icon", void 0);
83
+ GanttAddTaskComponent = tslib_1.__decorate([
84
+ Component({
85
+ selector: 'kendo-gantt-add-task',
86
+ template: `
87
+ <kendo-dropdownbutton
88
+ [data]="data"
89
+ [icon]="icon"
90
+ [kendoEventsOutsideAngular]="{ click: handleMouseClick }"
91
+ [scope]="this"
92
+ (itemClick)="handleItemClick($event)"
93
+ (open)="handleOpen($event)">
94
+ {{ getText('addTaskText') }}
95
+ </kendo-dropdownbutton>
96
+ `
97
+ }),
98
+ tslib_1.__metadata("design:paramtypes", [LocalizationService,
99
+ EditService,
100
+ NgZone])
101
+ ], GanttAddTaskComponent);
102
+ export { GanttAddTaskComponent };