@syncfusion/ej2-gantt 19.4.56 → 20.1.47-1460716

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 (211) hide show
  1. package/CHANGELOG.md +1072 -1060
  2. package/README.md +75 -75
  3. package/dist/ej2-gantt.umd.min.js +1 -10
  4. package/dist/ej2-gantt.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-gantt.es2015.js +274 -176
  6. package/dist/es6/ej2-gantt.es2015.js.map +1 -1
  7. package/dist/es6/ej2-gantt.es5.js +642 -534
  8. package/dist/es6/ej2-gantt.es5.js.map +1 -1
  9. package/dist/global/ej2-gantt.min.js +1 -10
  10. package/dist/global/ej2-gantt.min.js.map +1 -1
  11. package/dist/global/index.d.ts +0 -9
  12. package/dist/ts/components.ts +4 -0
  13. package/dist/ts/gantt/actions/actions.ts +18 -0
  14. package/dist/ts/gantt/actions/cell-edit.ts +606 -0
  15. package/dist/ts/gantt/actions/chart-scroll.ts +167 -0
  16. package/dist/ts/gantt/actions/column-menu.ts +35 -0
  17. package/dist/ts/gantt/actions/column-reorder.ts +52 -0
  18. package/dist/ts/gantt/actions/column-resize.ts +52 -0
  19. package/dist/ts/gantt/actions/connector-line-edit.ts +829 -0
  20. package/dist/ts/gantt/actions/context-menu.ts +754 -0
  21. package/dist/ts/gantt/actions/day-markers.ts +80 -0
  22. package/dist/ts/gantt/actions/dependency.ts +692 -0
  23. package/dist/ts/gantt/actions/dialog-edit.ts +2208 -0
  24. package/dist/ts/gantt/actions/edit.ts +3499 -0
  25. package/dist/ts/gantt/actions/excel-export.ts +61 -0
  26. package/dist/ts/gantt/actions/filter.ts +302 -0
  27. package/dist/ts/gantt/actions/keyboard.ts +306 -0
  28. package/dist/ts/gantt/actions/pdf-export.ts +214 -0
  29. package/dist/ts/gantt/actions/rowdragdrop.ts +839 -0
  30. package/dist/ts/gantt/actions/selection.ts +536 -0
  31. package/dist/ts/gantt/actions/sort.ts +98 -0
  32. package/dist/ts/gantt/actions/taskbar-edit.ts +1940 -0
  33. package/dist/ts/gantt/actions/toolbar.ts +489 -0
  34. package/dist/ts/gantt/actions/virtual-scroll.ts +60 -0
  35. package/dist/ts/gantt/base/common.ts +9 -0
  36. package/dist/ts/gantt/base/constant.ts +13 -0
  37. package/dist/ts/gantt/base/css-constants.ts +148 -0
  38. package/dist/ts/gantt/base/date-processor.ts +1257 -0
  39. package/dist/ts/gantt/base/enum.ts +372 -0
  40. package/dist/ts/gantt/base/gantt-chart.ts +1248 -0
  41. package/dist/ts/gantt/base/gantt.ts +4069 -0
  42. package/dist/ts/gantt/base/interface.ts +955 -0
  43. package/dist/ts/gantt/base/splitter.ts +174 -0
  44. package/dist/ts/gantt/base/task-processor.ts +2217 -0
  45. package/dist/ts/gantt/base/tree-grid.ts +694 -0
  46. package/dist/ts/gantt/base/utils.ts +208 -0
  47. package/dist/ts/gantt/export/export-helper.ts +552 -0
  48. package/dist/ts/gantt/export/pdf-base/dictionary.ts +152 -0
  49. package/dist/ts/gantt/export/pdf-base/pdf-borders.ts +277 -0
  50. package/dist/ts/gantt/export/pdf-base/pdf-grid-table.ts +901 -0
  51. package/dist/ts/gantt/export/pdf-base/pdf-style/gantt-theme.ts +131 -0
  52. package/dist/ts/gantt/export/pdf-base/pdf-style/style.ts +91 -0
  53. package/dist/ts/gantt/export/pdf-base/treegrid-layouter.ts +414 -0
  54. package/dist/ts/gantt/export/pdf-connector-line.ts +422 -0
  55. package/dist/ts/gantt/export/pdf-gantt.ts +282 -0
  56. package/dist/ts/gantt/export/pdf-taskbar.ts +395 -0
  57. package/dist/ts/gantt/export/pdf-timeline.ts +202 -0
  58. package/dist/ts/gantt/export/pdf-treegrid.ts +406 -0
  59. package/dist/ts/gantt/models/add-dialog-field-settings.ts +33 -0
  60. package/dist/ts/gantt/models/column.ts +464 -0
  61. package/dist/ts/gantt/models/day-working-time.ts +22 -0
  62. package/dist/ts/gantt/models/edit-dialog-field-settings.ts +33 -0
  63. package/dist/ts/gantt/models/edit-settings.ts +79 -0
  64. package/dist/ts/gantt/models/event-marker.ts +27 -0
  65. package/dist/ts/gantt/models/filter-settings.ts +53 -0
  66. package/dist/ts/gantt/models/holiday.ts +34 -0
  67. package/dist/ts/gantt/models/label-settings.ts +30 -0
  68. package/dist/ts/gantt/models/models.ts +36 -0
  69. package/dist/ts/gantt/models/resource-fields.ts +38 -0
  70. package/dist/ts/gantt/models/search-settings.ts +77 -0
  71. package/dist/ts/gantt/models/selection-settings.ts +56 -0
  72. package/dist/ts/gantt/models/sort-settings.ts +50 -0
  73. package/dist/ts/gantt/models/splitter-settings.ts +47 -0
  74. package/dist/ts/gantt/models/task-fields.ts +171 -0
  75. package/dist/ts/gantt/models/timeline-settings.ts +112 -0
  76. package/dist/ts/gantt/models/tooltip-settings.ts +46 -0
  77. package/dist/ts/gantt/renderer/chart-rows.ts +1838 -0
  78. package/dist/ts/gantt/renderer/connector-line.ts +1025 -0
  79. package/dist/ts/gantt/renderer/edit-tooltip.ts +228 -0
  80. package/dist/ts/gantt/renderer/event-marker.ts +96 -0
  81. package/dist/ts/gantt/renderer/nonworking-day.ts +205 -0
  82. package/dist/ts/gantt/renderer/render.ts +5 -0
  83. package/dist/ts/gantt/renderer/timeline.ts +1397 -0
  84. package/dist/ts/gantt/renderer/tooltip.ts +450 -0
  85. package/dist/ts/gantt/renderer/virtual-content-render.ts +50 -0
  86. package/license +9 -9
  87. package/package.json +80 -80
  88. package/src/gantt/actions/cell-edit.js +2 -1
  89. package/src/gantt/actions/dialog-edit.js +2 -1
  90. package/src/gantt/actions/edit.js +11 -2
  91. package/src/gantt/actions/rowdragdrop.js +37 -15
  92. package/src/gantt/actions/taskbar-edit.js +24 -24
  93. package/src/gantt/base/date-processor.js +0 -1
  94. package/src/gantt/base/gantt-chart.js +9 -4
  95. package/src/gantt/base/gantt-model.d.ts +779 -779
  96. package/src/gantt/base/gantt.d.ts +27 -27
  97. package/src/gantt/base/gantt.js +22 -22
  98. package/src/gantt/base/splitter.js +1 -0
  99. package/src/gantt/base/task-processor.js +13 -13
  100. package/src/gantt/base/tree-grid.js +3 -1
  101. package/src/gantt/export/pdf-base/treegrid-layouter.js +13 -13
  102. package/src/gantt/export/pdf-connector-line.js +11 -11
  103. package/src/gantt/export/pdf-gantt.js +24 -24
  104. package/src/gantt/export/pdf-taskbar.js +11 -11
  105. package/src/gantt/export/pdf-treegrid.js +13 -13
  106. package/src/gantt/models/add-dialog-field-settings-model.d.ts +21 -21
  107. package/src/gantt/models/add-dialog-field-settings.js +19 -19
  108. package/src/gantt/models/day-working-time-model.d.ts +11 -11
  109. package/src/gantt/models/day-working-time.js +19 -19
  110. package/src/gantt/models/edit-dialog-field-settings-model.d.ts +21 -21
  111. package/src/gantt/models/edit-dialog-field-settings.js +19 -19
  112. package/src/gantt/models/edit-settings-model.d.ts +50 -50
  113. package/src/gantt/models/edit-settings.js +19 -19
  114. package/src/gantt/models/event-marker-model.d.ts +16 -16
  115. package/src/gantt/models/event-marker.js +19 -19
  116. package/src/gantt/models/filter-settings-model.d.ts +34 -34
  117. package/src/gantt/models/filter-settings.js +19 -19
  118. package/src/gantt/models/holiday-model.d.ts +21 -21
  119. package/src/gantt/models/holiday.js +19 -19
  120. package/src/gantt/models/label-settings-model.d.ts +16 -16
  121. package/src/gantt/models/label-settings.js +19 -19
  122. package/src/gantt/models/resource-fields-model.d.ts +21 -21
  123. package/src/gantt/models/resource-fields.js +19 -19
  124. package/src/gantt/models/search-settings-model.d.ts +56 -56
  125. package/src/gantt/models/search-settings.js +19 -19
  126. package/src/gantt/models/selection-settings-model.d.ts +35 -35
  127. package/src/gantt/models/selection-settings.js +19 -19
  128. package/src/gantt/models/sort-settings-model.d.ts +24 -24
  129. package/src/gantt/models/sort-settings.js +19 -19
  130. package/src/gantt/models/splitter-settings-model.d.ts +30 -30
  131. package/src/gantt/models/splitter-settings.js +19 -19
  132. package/src/gantt/models/task-fields-model.d.ts +110 -110
  133. package/src/gantt/models/task-fields.js +19 -19
  134. package/src/gantt/models/timeline-settings-model.d.ts +71 -71
  135. package/src/gantt/models/timeline-settings.js +19 -19
  136. package/src/gantt/models/tooltip-settings-model.d.ts +26 -26
  137. package/src/gantt/models/tooltip-settings.js +19 -19
  138. package/src/gantt/renderer/chart-rows.js +49 -37
  139. package/src/gantt/renderer/connector-line.js +22 -18
  140. package/src/gantt/renderer/event-marker.js +1 -0
  141. package/src/gantt/renderer/nonworking-day.js +13 -6
  142. package/src/gantt/renderer/timeline.d.ts +1 -0
  143. package/src/gantt/renderer/timeline.js +48 -12
  144. package/src/gantt/renderer/tooltip.js +11 -3
  145. package/styles/bootstrap-dark.css +442 -427
  146. package/styles/bootstrap.css +442 -433
  147. package/styles/bootstrap4.css +454 -479
  148. package/styles/bootstrap5-dark.css +457 -433
  149. package/styles/bootstrap5.css +457 -433
  150. package/styles/fabric-dark.css +438 -421
  151. package/styles/fabric.css +445 -428
  152. package/styles/fluent-dark.css +1938 -0
  153. package/styles/fluent-dark.scss +1 -0
  154. package/styles/fluent.css +1938 -0
  155. package/styles/fluent.scss +1 -0
  156. package/styles/gantt/_all.scss +2 -2
  157. package/styles/gantt/_bootstrap-dark-definition.scss +210 -156
  158. package/styles/gantt/_bootstrap-definition.scss +211 -157
  159. package/styles/gantt/_bootstrap4-definition.scss +213 -158
  160. package/styles/gantt/_bootstrap5-definition.scss +215 -162
  161. package/styles/gantt/_fabric-dark-definition.scss +211 -157
  162. package/styles/gantt/_fabric-definition.scss +211 -157
  163. package/styles/gantt/_fluent-dark-definition.scss +1 -0
  164. package/styles/gantt/_fluent-definition.scss +215 -162
  165. package/styles/gantt/_fusionnew-definition.scss +214 -0
  166. package/styles/gantt/_highcontrast-definition.scss +211 -157
  167. package/styles/gantt/_highcontrast-light-definition.scss +211 -157
  168. package/styles/gantt/_layout.scss +1446 -1027
  169. package/styles/gantt/_material-dark-definition.scss +212 -157
  170. package/styles/gantt/_material-definition.scss +212 -157
  171. package/styles/gantt/_material3-definition.scss +215 -0
  172. package/styles/gantt/_tailwind-definition.scss +215 -161
  173. package/styles/gantt/_theme.scss +702 -668
  174. package/styles/gantt/bootstrap-dark.css +442 -427
  175. package/styles/gantt/bootstrap.css +442 -433
  176. package/styles/gantt/bootstrap4.css +454 -479
  177. package/styles/gantt/bootstrap5-dark.css +457 -433
  178. package/styles/gantt/bootstrap5.css +457 -433
  179. package/styles/gantt/fabric-dark.css +438 -421
  180. package/styles/gantt/fabric.css +445 -428
  181. package/styles/gantt/fluent-dark.css +1938 -0
  182. package/styles/gantt/fluent-dark.scss +22 -0
  183. package/styles/gantt/fluent.css +1938 -0
  184. package/styles/gantt/fluent.scss +22 -0
  185. package/styles/gantt/highcontrast-light.css +405 -405
  186. package/styles/gantt/highcontrast.css +444 -456
  187. package/styles/gantt/icons/_bootstrap-dark.scss +124 -113
  188. package/styles/gantt/icons/_bootstrap.scss +124 -113
  189. package/styles/gantt/icons/_bootstrap4.scss +124 -113
  190. package/styles/gantt/icons/_bootstrap5.scss +124 -112
  191. package/styles/gantt/icons/_fabric-dark.scss +124 -112
  192. package/styles/gantt/icons/_fabric.scss +124 -112
  193. package/styles/gantt/icons/_fluent-dark.scss +1 -0
  194. package/styles/gantt/icons/_fluent.scss +124 -112
  195. package/styles/gantt/icons/_fusionnew.scss +120 -0
  196. package/styles/gantt/icons/_highcontrast.scss +124 -112
  197. package/styles/gantt/icons/_material-dark.scss +124 -112
  198. package/styles/gantt/icons/_material.scss +124 -112
  199. package/styles/gantt/icons/_material3.scss +124 -0
  200. package/styles/gantt/icons/_tailwind-dark.scss +124 -113
  201. package/styles/gantt/icons/_tailwind.scss +124 -113
  202. package/styles/gantt/material-dark.css +446 -417
  203. package/styles/gantt/material.css +445 -419
  204. package/styles/gantt/tailwind-dark.css +452 -482
  205. package/styles/gantt/tailwind.css +449 -479
  206. package/styles/highcontrast-light.css +405 -405
  207. package/styles/highcontrast.css +444 -456
  208. package/styles/material-dark.css +446 -417
  209. package/styles/material.css +445 -419
  210. package/styles/tailwind-dark.css +452 -482
  211. package/styles/tailwind.css +449 -479
@@ -0,0 +1,536 @@
1
+ import { Gantt } from '../base/gantt';
2
+ import { RowSelectEventArgs, RowSelectingEventArgs, RowDeselectEventArgs, parentsUntil, getActualProperties } from '@syncfusion/ej2-grids';
3
+ import { CellDeselectEventArgs, ISelectedCell, setCssInGridPopUp, Grid } from '@syncfusion/ej2-grids';
4
+ import { CellSelectingEventArgs, CellSelectEventArgs, IIndex } from '@syncfusion/ej2-grids';
5
+ import { isNullOrUndefined, removeClass, getValue, addClass, closest, setValue, extend } from '@syncfusion/ej2-base';
6
+ import { IGanttData } from '../base/interface';
7
+ import { Deferred } from '@syncfusion/ej2-data';
8
+ import { TaskbarEdit } from './taskbar-edit';
9
+
10
+ /**
11
+ * The Selection module is used to handle cell and row selection.
12
+ */
13
+ export class Selection {
14
+ public parent: Gantt;
15
+ public selectedRowIndex: number;
16
+ public isMultiCtrlRequest: boolean;
17
+ public isMultiShiftRequest: boolean;
18
+ public isSelectionFromChart: boolean = false;
19
+ private actualTarget: EventTarget;
20
+ private isInteracted: boolean;
21
+ private prevRowIndex: number;
22
+ private selectedClass: HTMLElement;
23
+ private multipleIndexes: number[] = [];
24
+ public selectedRowIndexes: number[] = [];
25
+ public enableSelectMultiTouch: boolean = false;
26
+ public startIndex: number;
27
+ public endIndex: number;
28
+ private openPopup: boolean = false;
29
+ constructor(gantt: Gantt) {
30
+ this.parent = gantt;
31
+ this.bindEvents();
32
+ this.parent.treeGrid.selectedRowIndex = this.parent.selectedRowIndex;
33
+ this.parent.treeGrid.allowSelection = this.parent.allowSelection;
34
+ this.parent.treeGrid.grid.selectionSettings.enableToggle = this.parent.selectionSettings.enableToggle;
35
+ this.parent.treeGrid.selectionSettings = getActualProperties(this.parent.selectionSettings);
36
+ this.wireEvents();
37
+ }
38
+
39
+ /**
40
+ * Get module
41
+ *
42
+ * @returns {string} .
43
+ */
44
+ private getModuleName(): string {
45
+ return 'selection';
46
+ }
47
+
48
+ private wireEvents(): void {
49
+ this.parent.on('selectRowByIndex', this.selectRowByIndex, this);
50
+ if (this.parent.isAdaptive) {
51
+ this.parent.on('chartMouseClick', this.mouseUpHandler, this);
52
+ this.parent.on('treeGridClick', this.popUpClickHandler, this);
53
+ } else {
54
+ this.parent.on('chartMouseUp', this.mouseUpHandler, this);
55
+ }
56
+ }
57
+ /**
58
+ * To update selected index.
59
+ *
60
+ * @returns {void} .
61
+ * @private
62
+ */
63
+ public selectRowByIndex(): void {
64
+ if ((this.parent.selectedRowIndex !== -1 || this.parent.staticSelectedRowIndex !== -1) && this.parent.isLoad) {
65
+ this.selectRow(
66
+ this.parent.staticSelectedRowIndex !== -1 ? this.parent.staticSelectedRowIndex : this.parent.selectedRowIndex);
67
+ this.parent.staticSelectedRowIndex = -1;
68
+ }
69
+ }
70
+ /**
71
+ * To bind selection events.
72
+ *
73
+ * @returns {void} .
74
+ * @private
75
+ */
76
+ private bindEvents(): void {
77
+ this.parent.treeGrid.rowSelecting = this.rowSelecting.bind(this);
78
+ this.parent.treeGrid.rowSelected = this.rowSelected.bind(this);
79
+ this.parent.treeGrid.rowDeselecting = this.rowDeselecting.bind(this);
80
+ this.parent.treeGrid.rowDeselected = this.rowDeselected.bind(this);
81
+ this.parent.treeGrid.cellSelecting = this.cellSelecting.bind(this);
82
+ this.parent.treeGrid.cellSelected = this.cellSelected.bind(this);
83
+ this.parent.treeGrid.cellDeselecting = this.cellDeselecting.bind(this);
84
+ this.parent.treeGrid.cellDeselected = this.cellDeselected.bind(this);
85
+ }
86
+ private rowSelecting(args: RowSelectingEventArgs): void {
87
+ if (!this.parent.isGanttChartRendered) {
88
+ args.cancel = true;
89
+ return;
90
+ }
91
+ args.isCtrlPressed = this.isMultiCtrlRequest;
92
+ args.isShiftPressed = this.isMultiShiftRequest;
93
+ args.target = this.actualTarget as Element;
94
+ if (!isNullOrUndefined(args.foreignKeyData) && Object.keys(args.foreignKeyData).length === 0) {
95
+ delete args.foreignKeyData;
96
+ }
97
+ this.parent.trigger('rowSelecting', args);
98
+ }
99
+ private rowSelected(args: RowSelectEventArgs): void {
100
+ const rowIndexes: string = 'rowIndexes';
101
+ const index: number[] = (this.parent.selectionSettings.type === 'Multiple' && !isNullOrUndefined(args[rowIndexes])) ?
102
+ args[rowIndexes] : [args.rowIndex];
103
+ this.addRemoveClass(index);
104
+ this.selectedRowIndexes = extend([], this.getSelectedRowIndexes(), [], true) as number[];
105
+ this.parent.setProperties({ selectedRowIndex: this.parent.treeGrid.grid.selectedRowIndex }, true);
106
+ if (this.isMultiShiftRequest) {
107
+ this.selectedRowIndexes = index;
108
+ }
109
+ if (this.parent.autoFocusTasks) {
110
+ this.parent.ganttChartModule.updateScrollLeft(getValue('data.ganttProperties.left', args));
111
+ }
112
+ args.target = this.actualTarget as Element;
113
+ if (!isNullOrUndefined(args.foreignKeyData) && Object.keys(args.foreignKeyData).length === 0) {
114
+ delete args.foreignKeyData;
115
+ }
116
+ this.prevRowIndex = args.rowIndex;
117
+ if (!isNullOrUndefined(this.parent.toolbarModule)) {
118
+ this.parent.toolbarModule.refreshToolbarItems(args);
119
+ }
120
+ this.parent.trigger('rowSelected', args);
121
+ }
122
+ private rowDeselecting(args: RowDeselectEventArgs): void {
123
+ args.target = this.actualTarget as Element;
124
+ args.isInteracted = this.isInteracted;
125
+ this.parent.trigger('rowDeselecting', args);
126
+ }
127
+ private rowDeselected(args: RowDeselectEventArgs): void {
128
+ let index: number[];
129
+ let isContains: boolean;
130
+ if (this.multipleIndexes.length !== 0) {
131
+ index = this.multipleIndexes;
132
+ } else {
133
+ if (!isNullOrUndefined(args.rowIndexes)) {
134
+ for (let i: number = 0; i < args.rowIndexes.length; i++) {
135
+ if (args.rowIndexes[i] === args.rowIndex) {
136
+ isContains = true;
137
+ }
138
+ }
139
+ if (isContains) {
140
+ index = args.rowIndexes;
141
+ } else {
142
+ index = [args.rowIndex];
143
+ }
144
+ } else {
145
+ index = [args.rowIndex];
146
+ }
147
+ }
148
+ this.addRemoveClass(index);
149
+ this.selectedRowIndexes = extend([], this.getSelectedRowIndexes(), [], true) as number[];
150
+ this.parent.setProperties({ selectedRowIndex: -1 }, true);
151
+ if (this.selectedRowIndexes.length === 1) {
152
+ this.parent.setProperties({ selectedRowIndex: this.selectedRowIndexes[0] }, true);
153
+ }
154
+ if (!isNullOrUndefined(this.parent.toolbarModule)) {
155
+ this.parent.toolbarModule.refreshToolbarItems();
156
+ }
157
+ if (this.parent.selectionSettings.type === 'Multiple' && this.parent.isAdaptive
158
+ && this.selectedRowIndexes.length === 0) {
159
+ this.hidePopUp();
160
+ }
161
+ args.target = this.actualTarget as Element;
162
+ args.isInteracted = this.isInteracted;
163
+ this.parent.trigger('rowDeselected', args);
164
+ this.isInteracted = false;
165
+ this.multipleIndexes = [];
166
+ }
167
+ private cellSelecting(args: CellSelectingEventArgs): void | Deferred {
168
+ const callBackPromise: Deferred = new Deferred();
169
+ this.parent.trigger('cellSelecting', args, (cellselectingArgs: CellSelectingEventArgs) => {
170
+ callBackPromise.resolve(cellselectingArgs);
171
+ });
172
+ return callBackPromise;
173
+ }
174
+ private cellSelected(args: CellSelectEventArgs): void {
175
+ this.parent.trigger('cellSelected', args);
176
+ if (!isNullOrUndefined(this.parent.toolbarModule)) {
177
+ this.parent.toolbarModule.refreshToolbarItems();
178
+ }
179
+ }
180
+ private cellDeselecting(args: CellDeselectEventArgs): void {
181
+ this.parent.trigger('cellDeselecting', args);
182
+ }
183
+ private cellDeselected(args: CellDeselectEventArgs): void {
184
+ this.parent.trigger('cellDeselected', args);
185
+ if (!isNullOrUndefined(this.parent.toolbarModule)) {
186
+ this.parent.toolbarModule.refreshToolbarItems();
187
+ }
188
+ }
189
+ /**
190
+ * Selects a cell by given index.
191
+ *
192
+ * @param {IIndex} cellIndex - Defines the row and column indexes.
193
+ * @param {boolean} isToggle - If set to true, then it toggles the selection.
194
+ * @returns {void} .
195
+ */
196
+ public selectCell(cellIndex: IIndex, isToggle?: boolean): void {
197
+ this.parent.treeGrid.selectCell(cellIndex, isToggle);
198
+ }
199
+
200
+ /**
201
+ * Selects a collection of cells by row and column indexes.
202
+ *
203
+ * @param {ISelectedCell[]} rowCellIndexes - Specifies the row and column indexes.
204
+ * @returns {void} .
205
+ */
206
+ public selectCells(rowCellIndexes: ISelectedCell[]): void {
207
+ this.parent.treeGrid.grid.selectCells(rowCellIndexes);
208
+ }
209
+
210
+ /**
211
+ * Selects a row by given index.
212
+ *
213
+ * @param {number} index - Defines the row index.
214
+ * @param {boolean} isToggle - If set to true, then it toggles the selection.
215
+ * @param {boolean} isPreventFocus .
216
+ * @returns {void} .
217
+ */
218
+ public selectRow(index: number, isToggle?: boolean, isPreventFocus?: boolean): void {
219
+ const ganttRow: HTMLElement[] = [].slice.call(this.parent.ganttChartModule.chartBodyContent.querySelector('tbody').children);
220
+ // eslint-disable-next-line
221
+ const selectedRow: HTMLElement = ganttRow.filter((e: HTMLElement) => parseInt(e.getAttribute('aria-rowindex'), 0) === index)[0];
222
+ let condition: boolean;
223
+ if (index === -1 || isNullOrUndefined(selectedRow) || this.parent.selectionSettings.mode === 'Cell') {
224
+ return;
225
+ }
226
+ if (this.parent.showActiveElement && !isPreventFocus) {
227
+ this.parent.treeGrid.grid.selectionModule.preventFocus = true;
228
+ } else {
229
+ this.parent.treeGrid.grid.selectionModule.preventFocus = false;
230
+ }
231
+ if ((!isNullOrUndefined(this.selectedClass) && (this.selectedClass === selectedRow) && (!isToggle))) {
232
+ condition = true;
233
+ }
234
+ if (condition !== true) {
235
+ this.parent.treeGrid.selectRow(index, isToggle);
236
+ }
237
+ this.parent.treeGrid.grid.selectionModule.preventFocus = this.parent.treeGrid.grid.selectionModule.preventFocus === true ?
238
+ false : this.parent.treeGrid.grid.selectionModule.preventFocus;
239
+ this.prevRowIndex = index;
240
+ this.selectedClass = selectedRow;
241
+ }
242
+
243
+ /**
244
+ * Selects a collection of rows by indexes.
245
+ *
246
+ * @param {number[]} records - Defines the collection of row indexes.
247
+ * @returns {void} .
248
+ */
249
+ public selectRows(records: number[]): void {
250
+ if (!isNullOrUndefined(records) && records.length > 0) {
251
+ this.parent.treeGrid.selectRows(records);
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Gets the collection of selected row indexes.
257
+ *
258
+ * @returns {number[]} .
259
+ */
260
+ public getSelectedRowIndexes(): number[] {
261
+ return this.parent.treeGrid.getSelectedRowIndexes();
262
+ }
263
+
264
+ /**
265
+ * Gets the collection of selected row and cell indexes.
266
+ *
267
+ * @returns {number[]} .
268
+ */
269
+ public getSelectedRowCellIndexes(): ISelectedCell[] {
270
+ return this.parent.treeGrid.getSelectedRowCellIndexes();
271
+ }
272
+
273
+ /**
274
+ * Gets the collection of selected records.
275
+ *
276
+ * @returns {Object[]} .
277
+ */
278
+ public getSelectedRecords(): Object[] {
279
+ return this.parent.treeGrid.getSelectedRecords();
280
+ }
281
+
282
+ /**
283
+ * Get the selected records for cell selection.
284
+ *
285
+ * @returns {IGanttData[]} .
286
+ */
287
+ public getCellSelectedRecords(): IGanttData[] {
288
+ const cellDetails: ISelectedCell[] = this.parent.selectionModule.getSelectedRowCellIndexes();
289
+ const cellSelectedRecords: IGanttData[] = [];
290
+ for (let i: number = 0; i < cellDetails.length; i++) {
291
+ cellSelectedRecords.push(this.parent.currentViewData[cellDetails[i].rowIndex]);
292
+ }
293
+ return cellSelectedRecords;
294
+ }
295
+
296
+ /**
297
+ * Gets the collection of selected rows.
298
+ *
299
+ * @returns {Element[]} .
300
+ */
301
+ public getSelectedRows(): Element[] {
302
+ return this.parent.treeGrid.getSelectedRows();
303
+ }
304
+
305
+ /**
306
+ * Deselects the current selected rows and cells.
307
+ *
308
+ * @returns {void} .
309
+ */
310
+ public clearSelection(): void {
311
+ this.addRemoveClass(this.selectedRowIndexes);
312
+ this.parent.treeGrid.clearSelection();
313
+ this.parent.selectedRowIndex = -1;
314
+ this.selectedRowIndexes = [];
315
+ this.selectedClass = null;
316
+ if (!isNullOrUndefined(this.parent.toolbarModule)) {
317
+ this.parent.toolbarModule.refreshToolbarItems();
318
+ }
319
+ this.isInteracted = false;
320
+ }
321
+
322
+ private highlightSelectedRows(e: PointerEvent, fromChart: boolean): void {
323
+ this.isMultiCtrlRequest = e.ctrlKey || this.enableSelectMultiTouch;
324
+ this.isMultiShiftRequest = e.shiftKey;
325
+ this.actualTarget = e.target;
326
+ this.isInteracted = true;
327
+ this.isSelectionFromChart = fromChart;
328
+ if (fromChart) {
329
+ const selectedRow: Element = closest((e.target as Element), 'tr.e-chart-row');
330
+ const rIndex: number = parseInt(selectedRow.getAttribute('aria-rowindex'), 10);
331
+ const isToggle: boolean = this.parent.selectionSettings.enableToggle;
332
+ if (this.parent.selectionSettings.type === 'Single' || (!this.isMultiCtrlRequest && !this.isMultiShiftRequest)) {
333
+ this.selectRow(rIndex, isToggle);
334
+ } else {
335
+ if (this.isMultiShiftRequest) {
336
+ this.selectRowsByRange(isNullOrUndefined(this.prevRowIndex) ? rIndex : this.prevRowIndex, rIndex);
337
+ } else {
338
+ setValue('isMultiCtrlRequest', true, this.parent.treeGrid.grid.selectionModule);
339
+ this.parent.treeGrid.grid.selectionModule.addRowsToSelection([rIndex]);
340
+ const isUnSelected: boolean = this.selectedRowIndexes.indexOf(rIndex) > -1;
341
+ if (isUnSelected) {
342
+ this.addRemoveClass([rIndex]);
343
+ }
344
+ }
345
+ }
346
+ }
347
+ }
348
+
349
+ private getselectedrowsIndex(startIndex: number, endIndex?: number): void {
350
+ const indexes: number[] = [];
351
+ // eslint-disable-next-line
352
+ let { i, max }: { i: number, max: number } = (startIndex < endIndex) ?
353
+ { i: startIndex, max: endIndex } : { i: endIndex, max: startIndex };
354
+ for (; i <= max; i++) {
355
+ indexes.push(i);
356
+ }
357
+ if (startIndex > endIndex) {
358
+ indexes.reverse();
359
+ }
360
+ this.selectedRowIndexes = indexes;
361
+ }
362
+
363
+ /**
364
+ * Selects a range of rows from start and end row indexes.
365
+ *
366
+ * @param {number} startIndex - Defines the start row index.
367
+ * @param {number} endIndex - Defines the end row index.
368
+ * @returns {void} .
369
+ */
370
+ public selectRowsByRange(startIndex: number, endIndex?: number): void {
371
+ this.isSelectionFromChart = true;
372
+ this.getselectedrowsIndex(startIndex, endIndex);
373
+ this.selectRows(this.selectedRowIndexes);
374
+ }
375
+
376
+ private addRemoveClass(records: number[]): void {
377
+ const ganttRow: HTMLElement[] = [].slice.call(this.parent.ganttChartModule.chartBodyContent.querySelector('tbody').children);
378
+ for (let i: number = 0; i < records.length; i++) {
379
+ const selectedRow: HTMLElement = ganttRow.filter((e: HTMLElement) =>
380
+ // eslint-disable-next-line
381
+ parseInt(e.getAttribute('aria-rowindex'), 0) === records[i])[0];
382
+ if (!isNullOrUndefined(selectedRow)) {
383
+ // eslint-disable-next-line
384
+ this.getSelectedRowIndexes().indexOf(records[i]) > -1 ? this.addClass(selectedRow) : this.removeClass(selectedRow);
385
+ }
386
+ }
387
+ }
388
+ private addClass(selectedRow: HTMLElement): void {
389
+ addClass([selectedRow], 'e-active');
390
+ selectedRow.setAttribute('aria-selected', 'true');
391
+ }
392
+
393
+ private removeClass(selectedRow: HTMLElement): void {
394
+ removeClass([selectedRow], 'e-active');
395
+ selectedRow.removeAttribute('aria-selected');
396
+ }
397
+
398
+ private showPopup(e: MouseEvent): void {
399
+ if (this.isSelectionFromChart) {
400
+ setCssInGridPopUp(
401
+ <HTMLElement>this.parent.element.querySelector('.e-ganttpopup'), e,
402
+ 'e-rowselect e-icons e-icon-rowselect' +
403
+ ((this.enableSelectMultiTouch &&
404
+ (this.getSelectedRecords().length > 1 || this.getSelectedRowCellIndexes().length > 1)) ? ' e-spanclicked' : ''));
405
+ (<HTMLElement>document.getElementsByClassName('e-gridpopup')[0]).style.display = 'none';
406
+ this.openPopup = true;
407
+ } else if (this.selectedRowIndexes.length === 0) {
408
+ this.hidePopUp();
409
+ }
410
+ }
411
+ /**
412
+ * @returns {void} .
413
+ * @private
414
+ */
415
+ public hidePopUp(): void {
416
+ if (this.openPopup) {
417
+ (<HTMLElement>document.getElementsByClassName('e-ganttpopup')[0]).style.display = 'none';
418
+ this.openPopup = false;
419
+ } else {
420
+ (<HTMLElement>document.getElementsByClassName('e-gridpopup')[0]).style.display = 'none';
421
+ }
422
+ }
423
+
424
+ private popUpClickHandler(e: MouseEvent): void {
425
+ const target: Element = e.target as Element;
426
+ const grid: Grid = this.parent.treeGrid.grid;
427
+ const $popUpElemet: Element = closest(target, '.e-ganttpopup') ?
428
+ closest(target, '.e-ganttpopup') : closest(target, '.e-gridpopup');
429
+ if ($popUpElemet) {
430
+ const spanElement: Element = $popUpElemet.querySelector('.' + 'e-rowselect');
431
+ if (closest(target, '.e-ganttpopup') &&
432
+ !spanElement.classList.contains('e-spanclicked')) {
433
+ this.enableSelectMultiTouch = true;
434
+ spanElement.classList.add('e-spanclicked');
435
+ } else if (closest(target, '.e-gridpopup') &&
436
+ spanElement.classList.contains('e-spanclicked')) {
437
+ this.openPopup = true;
438
+ this.enableSelectMultiTouch = true;
439
+ } else {
440
+ this.hidePopUp();
441
+ this.enableSelectMultiTouch = false;
442
+ if (closest(target, '.e-ganttpopup')) {
443
+ spanElement.classList.remove('e-spanclicked');
444
+ }
445
+ }
446
+ } else if (this.parent.selectionSettings.type === 'Multiple' && this.parent.isAdaptive) {
447
+ const $tr: Element = closest(target, '.e-rowcell');
448
+ if ($tr && this.selectedRowIndexes.length === 0) {
449
+ this.hidePopUp();
450
+ }
451
+ }
452
+ if (grid) {
453
+ setValue('enableSelectMultiTouch', this.enableSelectMultiTouch, grid.selectionModule);
454
+ }
455
+ }
456
+
457
+ /**
458
+ * @param {PointerEvent} e .
459
+ * @returns {void} .
460
+ * @private
461
+ */
462
+ private mouseUpHandler(e: PointerEvent): void {
463
+ let isTaskbarEdited: boolean = false;
464
+ let targetElement: Element = null;
465
+ if ((e.target as Element).closest('.e-rowcell')) {
466
+ targetElement = e.target as HTMLElement;
467
+ } else if ((e.target as Element).closest('.e-chart-row')) {
468
+ targetElement = (e.target as Element).closest('.e-left-label-container') ||
469
+ (e.target as Element).closest('.e-taskbar-main-container') || (e.target as Element).closest('.e-right-label-container');
470
+ }
471
+ if (this.parent.focusModule) {
472
+ this.parent.focusModule.setActiveElement(targetElement as HTMLElement);
473
+ }
474
+ if (this.parent.editModule && this.parent.editSettings.allowTaskbarEditing && this.parent.editModule.taskbarEditModule) {
475
+ const taskbarEdit: TaskbarEdit = this.parent.editModule.taskbarEditModule;
476
+ if (taskbarEdit.isMouseDragged || taskbarEdit.tapPointOnFocus) {
477
+ isTaskbarEdited = true;
478
+ }
479
+ }
480
+ if (!isTaskbarEdited && this.parent.element.contains(e.target as Node)) {
481
+ const parent: Element = parentsUntil(e.target as Element, 'e-chart-row');
482
+ const isSelected: boolean = (e.target as HTMLElement).classList.contains('e-rowcell') ||
483
+ (e.target as HTMLElement).classList.contains('e-row') ||
484
+ (e.target as HTMLElement).classList.contains('e-treegridexpand') ||
485
+ (e.target as HTMLElement).classList.contains('e-treegridcollapse') || !isNullOrUndefined(parent);
486
+ this.popUpClickHandler(e);
487
+ if (this.parent.selectionSettings.mode !== 'Cell' && isSelected) {
488
+ if (closest((e.target as Element), 'tr.e-chart-row')) {
489
+ this.highlightSelectedRows(e, true);
490
+ } else {
491
+ this.highlightSelectedRows(e, false);
492
+ }
493
+ if (this.parent.selectionSettings.type === 'Multiple' && this.parent.isAdaptive) {
494
+ if (this.selectedRowIndexes.length > 0) {
495
+ this.showPopup(e);
496
+ } else {
497
+ this.hidePopUp();
498
+ }
499
+ }
500
+ } else {
501
+ this.isSelectionFromChart = false;
502
+ }
503
+ }
504
+ }
505
+ /**
506
+ * To add class for selected records in virtualization mode.
507
+ *
508
+ * @param {number} i .
509
+ * @returns {void} .
510
+ * @hidden
511
+ */
512
+ public maintainSelectedRecords(i: number): void {
513
+ const index: number = this.parent.selectionModule.getSelectedRowIndexes().indexOf(i);
514
+ if (index > -1) {
515
+ this.addRemoveClass([i]);
516
+ }
517
+ }
518
+ /**
519
+ * To destroy the selection module.
520
+ *
521
+ * @returns {void} .
522
+ * @private
523
+ */
524
+ public destroy(): void {
525
+ if (this.parent.isDestroyed) {
526
+ return;
527
+ }
528
+ this.parent.off('selectRowByIndex', this.selectRowByIndex);
529
+ if (this.parent.isAdaptive) {
530
+ this.parent.off('chartMouseClick', this.mouseUpHandler);
531
+ this.parent.off('treeGridClick', this.popUpClickHandler);
532
+ } else {
533
+ this.parent.off('chartMouseUp', this.mouseUpHandler);
534
+ }
535
+ }
536
+ }
@@ -0,0 +1,98 @@
1
+ import { TreeGrid, Sort as TreeGrdSort } from '@syncfusion/ej2-treegrid';
2
+ import { Gantt } from '../base/gantt';
3
+ import { SortDirection, getActualProperties } from '@syncfusion/ej2-grids';
4
+
5
+ /**
6
+ * The Sort module is used to handle sorting action.
7
+ */
8
+ export class Sort {
9
+ public parent: Gantt;
10
+ constructor(gantt: Gantt) {
11
+ this.parent = gantt;
12
+ TreeGrid.Inject(TreeGrdSort);
13
+ this.parent.treeGrid.allowSorting = this.parent.allowSorting;
14
+ this.parent.treeGrid.sortSettings = getActualProperties(this.parent.sortSettings);
15
+ this.addEventListener();
16
+ }
17
+
18
+ /**
19
+ * For internal use only - Get the module name.
20
+ *
21
+ * @returns {string} .
22
+ * @private
23
+ */
24
+ private getModuleName(): string {
25
+ return 'sort';
26
+ }
27
+
28
+ /**
29
+ * @returns {void} .
30
+ * @private
31
+ */
32
+ private addEventListener(): void {
33
+ this.parent.on('updateModel', this.updateModel, this);
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @returns {void} .
39
+ * @hidden
40
+ */
41
+ private removeEventListener(): void {
42
+ if (this.parent.isDestroyed) {
43
+ return;
44
+ }
45
+ this.parent.off('updateModel', this.updateModel);
46
+ }
47
+
48
+ /**
49
+ * Destroys the Sorting of TreeGrid.
50
+ *
51
+ * @returns {void} .
52
+ * @private
53
+ */
54
+ public destroy(): void {
55
+ this.removeEventListener();
56
+ }
57
+
58
+ /**
59
+ * Sort a column with given options.
60
+ *
61
+ * @param {string} columnName - Defines the column name to sort.
62
+ * @param {SortDirection} direction - Defines the direction of sort.
63
+ * @param {boolean} isMultiSort - Defines whether the previously sorted columns are to be maintained.
64
+ * @returns {void} .
65
+ */
66
+ public sortColumn(columnName: string, direction: SortDirection, isMultiSort?: boolean): void {
67
+ this.parent.treeGrid.sortByColumn(columnName, direction, isMultiSort);
68
+ }
69
+
70
+ /**
71
+ * Method to clear all sorted columns.
72
+ *
73
+ * @returns {void} .
74
+ */
75
+ public clearSorting(): void {
76
+ this.parent.treeGrid.clearSorting();
77
+ }
78
+
79
+ /**
80
+ * The function used to update sortSettings of TreeGrid.
81
+ *
82
+ * @returns {void} .
83
+ * @hidden
84
+ */
85
+ private updateModel(): void {
86
+ this.parent.sortSettings = this.parent.treeGrid.sortSettings;
87
+ }
88
+ /**
89
+ * To clear sorting for specific column.
90
+ *
91
+ * @param {string} columnName - Defines the sorted column name to remove.
92
+ * @returns {void} .
93
+ */
94
+ public removeSortColumn(columnName: string): void {
95
+ this.parent.treeGrid.grid.removeSortColumn(columnName);
96
+
97
+ }
98
+ }