@syncfusion/ej2-gantt 19.4.55 → 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.
- package/CHANGELOG.md +1072 -1047
- package/README.md +75 -75
- package/dist/ej2-gantt.umd.min.js +1 -10
- package/dist/ej2-gantt.umd.min.js.map +1 -1
- package/dist/es6/ej2-gantt.es2015.js +341 -240
- package/dist/es6/ej2-gantt.es2015.js.map +1 -1
- package/dist/es6/ej2-gantt.es5.js +713 -598
- package/dist/es6/ej2-gantt.es5.js.map +1 -1
- package/dist/global/ej2-gantt.min.js +1 -10
- package/dist/global/ej2-gantt.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/dist/ts/components.ts +4 -0
- package/dist/ts/gantt/actions/actions.ts +18 -0
- package/dist/ts/gantt/actions/cell-edit.ts +606 -0
- package/dist/ts/gantt/actions/chart-scroll.ts +167 -0
- package/dist/ts/gantt/actions/column-menu.ts +35 -0
- package/dist/ts/gantt/actions/column-reorder.ts +52 -0
- package/dist/ts/gantt/actions/column-resize.ts +52 -0
- package/dist/ts/gantt/actions/connector-line-edit.ts +829 -0
- package/dist/ts/gantt/actions/context-menu.ts +754 -0
- package/dist/ts/gantt/actions/day-markers.ts +80 -0
- package/dist/ts/gantt/actions/dependency.ts +692 -0
- package/dist/ts/gantt/actions/dialog-edit.ts +2208 -0
- package/dist/ts/gantt/actions/edit.ts +3499 -0
- package/dist/ts/gantt/actions/excel-export.ts +61 -0
- package/dist/ts/gantt/actions/filter.ts +302 -0
- package/dist/ts/gantt/actions/keyboard.ts +306 -0
- package/dist/ts/gantt/actions/pdf-export.ts +214 -0
- package/dist/ts/gantt/actions/rowdragdrop.ts +839 -0
- package/dist/ts/gantt/actions/selection.ts +536 -0
- package/dist/ts/gantt/actions/sort.ts +98 -0
- package/dist/ts/gantt/actions/taskbar-edit.ts +1940 -0
- package/dist/ts/gantt/actions/toolbar.ts +489 -0
- package/dist/ts/gantt/actions/virtual-scroll.ts +60 -0
- package/dist/ts/gantt/base/common.ts +9 -0
- package/dist/ts/gantt/base/constant.ts +13 -0
- package/dist/ts/gantt/base/css-constants.ts +148 -0
- package/dist/ts/gantt/base/date-processor.ts +1257 -0
- package/dist/ts/gantt/base/enum.ts +372 -0
- package/dist/ts/gantt/base/gantt-chart.ts +1248 -0
- package/dist/ts/gantt/base/gantt.ts +4069 -0
- package/dist/ts/gantt/base/interface.ts +955 -0
- package/dist/ts/gantt/base/splitter.ts +174 -0
- package/dist/ts/gantt/base/task-processor.ts +2217 -0
- package/dist/ts/gantt/base/tree-grid.ts +694 -0
- package/dist/ts/gantt/base/utils.ts +208 -0
- package/dist/ts/gantt/export/export-helper.ts +552 -0
- package/dist/ts/gantt/export/pdf-base/dictionary.ts +152 -0
- package/dist/ts/gantt/export/pdf-base/pdf-borders.ts +277 -0
- package/dist/ts/gantt/export/pdf-base/pdf-grid-table.ts +901 -0
- package/dist/ts/gantt/export/pdf-base/pdf-style/gantt-theme.ts +131 -0
- package/dist/ts/gantt/export/pdf-base/pdf-style/style.ts +91 -0
- package/dist/ts/gantt/export/pdf-base/treegrid-layouter.ts +414 -0
- package/dist/ts/gantt/export/pdf-connector-line.ts +422 -0
- package/dist/ts/gantt/export/pdf-gantt.ts +282 -0
- package/dist/ts/gantt/export/pdf-taskbar.ts +395 -0
- package/dist/ts/gantt/export/pdf-timeline.ts +202 -0
- package/dist/ts/gantt/export/pdf-treegrid.ts +406 -0
- package/dist/ts/gantt/models/add-dialog-field-settings.ts +33 -0
- package/dist/ts/gantt/models/column.ts +464 -0
- package/dist/ts/gantt/models/day-working-time.ts +22 -0
- package/dist/ts/gantt/models/edit-dialog-field-settings.ts +33 -0
- package/dist/ts/gantt/models/edit-settings.ts +79 -0
- package/dist/ts/gantt/models/event-marker.ts +27 -0
- package/dist/ts/gantt/models/filter-settings.ts +53 -0
- package/dist/ts/gantt/models/holiday.ts +34 -0
- package/dist/ts/gantt/models/label-settings.ts +30 -0
- package/dist/ts/gantt/models/models.ts +36 -0
- package/dist/ts/gantt/models/resource-fields.ts +38 -0
- package/dist/ts/gantt/models/search-settings.ts +77 -0
- package/dist/ts/gantt/models/selection-settings.ts +56 -0
- package/dist/ts/gantt/models/sort-settings.ts +50 -0
- package/dist/ts/gantt/models/splitter-settings.ts +47 -0
- package/dist/ts/gantt/models/task-fields.ts +171 -0
- package/dist/ts/gantt/models/timeline-settings.ts +112 -0
- package/dist/ts/gantt/models/tooltip-settings.ts +46 -0
- package/dist/ts/gantt/renderer/chart-rows.ts +1838 -0
- package/dist/ts/gantt/renderer/connector-line.ts +1025 -0
- package/dist/ts/gantt/renderer/edit-tooltip.ts +228 -0
- package/dist/ts/gantt/renderer/event-marker.ts +96 -0
- package/dist/ts/gantt/renderer/nonworking-day.ts +205 -0
- package/dist/ts/gantt/renderer/render.ts +5 -0
- package/dist/ts/gantt/renderer/timeline.ts +1397 -0
- package/dist/ts/gantt/renderer/tooltip.ts +450 -0
- package/dist/ts/gantt/renderer/virtual-content-render.ts +50 -0
- package/license +9 -9
- package/package.json +80 -80
- package/src/gantt/actions/cell-edit.js +2 -1
- package/src/gantt/actions/dialog-edit.js +2 -1
- package/src/gantt/actions/edit.js +36 -9
- package/src/gantt/actions/rowdragdrop.js +37 -15
- package/src/gantt/actions/selection.js +3 -2
- package/src/gantt/actions/taskbar-edit.js +24 -24
- package/src/gantt/base/date-processor.js +0 -1
- package/src/gantt/base/gantt-chart.js +36 -5
- package/src/gantt/base/gantt-model.d.ts +779 -779
- package/src/gantt/base/gantt.d.ts +27 -27
- package/src/gantt/base/gantt.js +35 -76
- package/src/gantt/base/splitter.js +1 -0
- package/src/gantt/base/task-processor.js +13 -13
- package/src/gantt/base/tree-grid.js +3 -1
- package/src/gantt/export/pdf-base/treegrid-layouter.js +13 -13
- package/src/gantt/export/pdf-connector-line.js +11 -11
- package/src/gantt/export/pdf-gantt.js +24 -24
- package/src/gantt/export/pdf-taskbar.js +11 -11
- package/src/gantt/export/pdf-treegrid.js +13 -13
- package/src/gantt/models/add-dialog-field-settings-model.d.ts +21 -21
- package/src/gantt/models/add-dialog-field-settings.js +19 -19
- package/src/gantt/models/day-working-time-model.d.ts +11 -11
- package/src/gantt/models/day-working-time.js +19 -19
- package/src/gantt/models/edit-dialog-field-settings-model.d.ts +21 -21
- package/src/gantt/models/edit-dialog-field-settings.js +19 -19
- package/src/gantt/models/edit-settings-model.d.ts +50 -50
- package/src/gantt/models/edit-settings.js +19 -19
- package/src/gantt/models/event-marker-model.d.ts +16 -16
- package/src/gantt/models/event-marker.js +19 -19
- package/src/gantt/models/filter-settings-model.d.ts +34 -34
- package/src/gantt/models/filter-settings.js +19 -19
- package/src/gantt/models/holiday-model.d.ts +21 -21
- package/src/gantt/models/holiday.js +19 -19
- package/src/gantt/models/label-settings-model.d.ts +16 -16
- package/src/gantt/models/label-settings.js +19 -19
- package/src/gantt/models/resource-fields-model.d.ts +21 -21
- package/src/gantt/models/resource-fields.js +19 -19
- package/src/gantt/models/search-settings-model.d.ts +56 -56
- package/src/gantt/models/search-settings.js +19 -19
- package/src/gantt/models/selection-settings-model.d.ts +35 -35
- package/src/gantt/models/selection-settings.js +19 -19
- package/src/gantt/models/sort-settings-model.d.ts +24 -24
- package/src/gantt/models/sort-settings.js +19 -19
- package/src/gantt/models/splitter-settings-model.d.ts +30 -30
- package/src/gantt/models/splitter-settings.js +19 -19
- package/src/gantt/models/task-fields-model.d.ts +110 -110
- package/src/gantt/models/task-fields.js +19 -19
- package/src/gantt/models/timeline-settings-model.d.ts +71 -71
- package/src/gantt/models/timeline-settings.js +19 -19
- package/src/gantt/models/tooltip-settings-model.d.ts +26 -26
- package/src/gantt/models/tooltip-settings.js +19 -19
- package/src/gantt/renderer/chart-rows.js +49 -37
- package/src/gantt/renderer/connector-line.js +22 -18
- package/src/gantt/renderer/event-marker.js +1 -0
- package/src/gantt/renderer/nonworking-day.js +13 -6
- package/src/gantt/renderer/timeline.d.ts +1 -0
- package/src/gantt/renderer/timeline.js +51 -12
- package/src/gantt/renderer/tooltip.js +11 -3
- package/styles/bootstrap-dark.css +442 -427
- package/styles/bootstrap.css +442 -433
- package/styles/bootstrap4.css +454 -479
- package/styles/bootstrap5-dark.css +457 -433
- package/styles/bootstrap5.css +457 -433
- package/styles/fabric-dark.css +438 -421
- package/styles/fabric.css +445 -428
- package/styles/fluent-dark.css +1938 -0
- package/styles/fluent-dark.scss +1 -0
- package/styles/fluent.css +1938 -0
- package/styles/fluent.scss +1 -0
- package/styles/gantt/_all.scss +2 -2
- package/styles/gantt/_bootstrap-dark-definition.scss +210 -156
- package/styles/gantt/_bootstrap-definition.scss +211 -157
- package/styles/gantt/_bootstrap4-definition.scss +213 -158
- package/styles/gantt/_bootstrap5-definition.scss +215 -162
- package/styles/gantt/_fabric-dark-definition.scss +211 -157
- package/styles/gantt/_fabric-definition.scss +211 -157
- package/styles/gantt/_fluent-dark-definition.scss +1 -0
- package/styles/gantt/_fluent-definition.scss +215 -162
- package/styles/gantt/_fusionnew-definition.scss +214 -0
- package/styles/gantt/_highcontrast-definition.scss +211 -157
- package/styles/gantt/_highcontrast-light-definition.scss +211 -157
- package/styles/gantt/_layout.scss +1446 -1027
- package/styles/gantt/_material-dark-definition.scss +212 -157
- package/styles/gantt/_material-definition.scss +212 -157
- package/styles/gantt/_material3-definition.scss +215 -0
- package/styles/gantt/_tailwind-definition.scss +215 -161
- package/styles/gantt/_theme.scss +702 -668
- package/styles/gantt/bootstrap-dark.css +442 -427
- package/styles/gantt/bootstrap.css +442 -433
- package/styles/gantt/bootstrap4.css +454 -479
- package/styles/gantt/bootstrap5-dark.css +457 -433
- package/styles/gantt/bootstrap5.css +457 -433
- package/styles/gantt/fabric-dark.css +438 -421
- package/styles/gantt/fabric.css +445 -428
- package/styles/gantt/fluent-dark.css +1938 -0
- package/styles/gantt/fluent-dark.scss +22 -0
- package/styles/gantt/fluent.css +1938 -0
- package/styles/gantt/fluent.scss +22 -0
- package/styles/gantt/highcontrast-light.css +405 -405
- package/styles/gantt/highcontrast.css +444 -456
- package/styles/gantt/icons/_bootstrap-dark.scss +124 -113
- package/styles/gantt/icons/_bootstrap.scss +124 -113
- package/styles/gantt/icons/_bootstrap4.scss +124 -113
- package/styles/gantt/icons/_bootstrap5.scss +124 -112
- package/styles/gantt/icons/_fabric-dark.scss +124 -112
- package/styles/gantt/icons/_fabric.scss +124 -112
- package/styles/gantt/icons/_fluent-dark.scss +1 -0
- package/styles/gantt/icons/_fluent.scss +124 -112
- package/styles/gantt/icons/_fusionnew.scss +120 -0
- package/styles/gantt/icons/_highcontrast.scss +124 -112
- package/styles/gantt/icons/_material-dark.scss +124 -112
- package/styles/gantt/icons/_material.scss +124 -112
- package/styles/gantt/icons/_material3.scss +124 -0
- package/styles/gantt/icons/_tailwind-dark.scss +124 -113
- package/styles/gantt/icons/_tailwind.scss +124 -113
- package/styles/gantt/material-dark.css +446 -417
- package/styles/gantt/material.css +445 -419
- package/styles/gantt/tailwind-dark.css +452 -482
- package/styles/gantt/tailwind.css +449 -479
- package/styles/highcontrast-light.css +405 -405
- package/styles/highcontrast.css +444 -456
- package/styles/material-dark.css +446 -417
- package/styles/material.css +445 -419
- package/styles/tailwind-dark.css +452 -482
- package/styles/tailwind.css +449 -479
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
import { TreeGrid, RowDD as TreeGridRowDD } from '@syncfusion/ej2-treegrid';
|
|
2
|
+
import { RowDragEventArgs } from '@syncfusion/ej2-grids';
|
|
3
|
+
import { Gantt } from '../base/gantt';
|
|
4
|
+
import { isNullOrUndefined, extend, classList, addClass, getValue, closest } from '@syncfusion/ej2-base';
|
|
5
|
+
import { DataManager } from '@syncfusion/ej2-data';
|
|
6
|
+
import { IGanttData, RowPosition, isCountRequired } from '../base/common';
|
|
7
|
+
import { RowDropEventArgs, IParent } from '../base/interface';
|
|
8
|
+
import { ITreeData } from '@syncfusion/ej2-treegrid';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gantt Excel Export module
|
|
13
|
+
*/
|
|
14
|
+
export class RowDD {
|
|
15
|
+
private parent: Gantt;
|
|
16
|
+
public isTest: boolean = false;
|
|
17
|
+
/** @hidden */
|
|
18
|
+
private ganttData: IGanttData[];
|
|
19
|
+
/** @hidden */
|
|
20
|
+
private treeGridData: ITreeData[];
|
|
21
|
+
/** @hidden */
|
|
22
|
+
private draggedRecord: IGanttData;
|
|
23
|
+
/** @hidden */
|
|
24
|
+
private updateParentRecords: IGanttData[] = [];
|
|
25
|
+
/** @hidden */
|
|
26
|
+
private droppedRecord: IGanttData;
|
|
27
|
+
/** @hidden */
|
|
28
|
+
public isaddtoBottom: boolean = false;
|
|
29
|
+
/** @hidden */
|
|
30
|
+
private previousParent: string;
|
|
31
|
+
private dropPosition: string;
|
|
32
|
+
/** @hidden */
|
|
33
|
+
private isSharedTask: boolean = false;
|
|
34
|
+
/** @hidden */
|
|
35
|
+
private canDrop: boolean = true;
|
|
36
|
+
/**
|
|
37
|
+
* Constructor for Excel Export module
|
|
38
|
+
*
|
|
39
|
+
* @param {Gantt} gantt .
|
|
40
|
+
*/
|
|
41
|
+
constructor(gantt: Gantt) {
|
|
42
|
+
this.parent = gantt;
|
|
43
|
+
TreeGrid.Inject(TreeGridRowDD);
|
|
44
|
+
this.parent.treeGrid.allowRowDragAndDrop = this.parent.allowRowDragAndDrop;
|
|
45
|
+
this.bindEvents();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* For internal use only - Get the module name.
|
|
49
|
+
*
|
|
50
|
+
* @returns {string} .
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
protected getModuleName(): string {
|
|
54
|
+
return 'rowDragAndDrop';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* To destroy excel export module.
|
|
58
|
+
*
|
|
59
|
+
* @returns {void} .
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
public destroy(): void {
|
|
63
|
+
// Destroy Method
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* To bind excel exporting events.
|
|
67
|
+
*
|
|
68
|
+
* @returns {void} .
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private bindEvents(): void {
|
|
72
|
+
this.parent.treeGrid.rowDragStart = this.rowDragStart.bind(this);
|
|
73
|
+
this.parent.treeGrid.rowDragStartHelper = this.rowDragStartHelper.bind(this);
|
|
74
|
+
this.parent.treeGrid.rowDrag = this.rowDrag.bind(this);
|
|
75
|
+
this.parent.treeGrid.rowDrop = this.rowDrop.bind(this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private rowDragStart(args: RowDragEventArgs): void {
|
|
79
|
+
this.parent.trigger('rowDragStart', args);
|
|
80
|
+
this.parent.element.style.position = 'relative'; // for positioning the drag element properly
|
|
81
|
+
}
|
|
82
|
+
private addErrorElem(): void {
|
|
83
|
+
const dragelem: Element = document.getElementsByClassName('e-ganttdrag')[0];
|
|
84
|
+
const errorelem: number = dragelem.querySelectorAll('.e-errorelem').length;
|
|
85
|
+
if (!errorelem) {
|
|
86
|
+
const ele: Element = document.createElement('div');
|
|
87
|
+
classList(ele, ['e-errorcontainer'], []);
|
|
88
|
+
classList(ele, ['e-icons', 'e-errorelem'], []);
|
|
89
|
+
const errorVal: Element = dragelem.querySelector('.errorValue');
|
|
90
|
+
let content: string = dragelem.querySelector('.e-rowcell').innerHTML;
|
|
91
|
+
if (errorVal) {
|
|
92
|
+
content = errorVal.innerHTML;
|
|
93
|
+
errorVal.parentNode.removeChild(errorVal);
|
|
94
|
+
}
|
|
95
|
+
dragelem.querySelector('.e-rowcell').innerHTML = '';
|
|
96
|
+
const spanContent: HTMLElement = document.createElement('span');
|
|
97
|
+
spanContent.className = 'errorValue';
|
|
98
|
+
spanContent.style.paddingLeft = '16px';
|
|
99
|
+
spanContent.innerHTML = content;
|
|
100
|
+
dragelem.querySelector('.e-rowcell').appendChild(ele);
|
|
101
|
+
dragelem.querySelector('.e-rowcell').appendChild(spanContent);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
private removeErrorElem(): void {
|
|
105
|
+
const errorelem: Element = document.querySelector('.e-errorelem');
|
|
106
|
+
if (errorelem) {
|
|
107
|
+
errorelem.remove();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private rowDrag(args: RowDragEventArgs): void {
|
|
112
|
+
const cloneElement: HTMLElement = this.parent.element.querySelector('.e-cloneproperties');
|
|
113
|
+
cloneElement.style.display = 'none';
|
|
114
|
+
const ganttDragElement: HTMLElement = cloneElement.cloneNode(true) as HTMLElement;
|
|
115
|
+
ganttDragElement.classList.add('e-ganttdrag');
|
|
116
|
+
ganttDragElement.style.display = '';
|
|
117
|
+
if (this.parent.element.querySelectorAll('.e-cloneproperties').length <= 1) {
|
|
118
|
+
this.parent.element.appendChild(ganttDragElement);
|
|
119
|
+
} else {
|
|
120
|
+
if (document.getElementsByClassName('e-cloneproperties')[0].querySelectorAll('.e-errorelem').length) {
|
|
121
|
+
this.addErrorElem();
|
|
122
|
+
} else {
|
|
123
|
+
this.removeErrorElem();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (this.parent.gridLines === 'Both') {
|
|
127
|
+
addClass(this.parent.element.querySelectorAll('.e-ganttdrag .e-rowcell'), ['e-bothganttlines']);
|
|
128
|
+
}
|
|
129
|
+
const dragElement: HTMLElement = this.parent.element.querySelector('.e-ganttdrag');
|
|
130
|
+
const ganttTop: number = this.parent.element.getClientRects()[0].top;
|
|
131
|
+
const ganttLeft: number = this.parent.element.getClientRects()[0].left;
|
|
132
|
+
const left: number = getValue('event', args.originalEvent).clientX - ganttLeft;
|
|
133
|
+
const top: number = getValue('event', args.originalEvent).clientY - ganttTop;
|
|
134
|
+
dragElement.style.left = left + 20 + 'px';
|
|
135
|
+
dragElement.style.top = top + 20 + 'px';
|
|
136
|
+
this.parent.trigger('rowDrag', args);
|
|
137
|
+
}
|
|
138
|
+
private rowDragStartHelper(args: RowDragEventArgs): void {
|
|
139
|
+
this.parent.trigger('rowDragStartHelper', args);
|
|
140
|
+
if (this.parent.readOnly || this.parent.filterSettings.columns.length > 0) {
|
|
141
|
+
args.cancel = true;
|
|
142
|
+
}
|
|
143
|
+
if (this.parent.viewType === 'ResourceView' && getValue('level', args.data[0]) === 0) {
|
|
144
|
+
args.cancel = true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
private rowDrop(args: RowDropEventArgs): void {
|
|
148
|
+
const ganttDragelem: Element = document.querySelector('.e-ganttdrag');
|
|
149
|
+
if (ganttDragelem) {
|
|
150
|
+
ganttDragelem.remove();
|
|
151
|
+
}
|
|
152
|
+
const gridRow: Element = closest(args.target, '.e-row');
|
|
153
|
+
const dropIndex: number = gridRow ? parseInt(gridRow.getAttribute('aria-rowindex'), 10) : args.dropIndex;
|
|
154
|
+
args.dropIndex = dropIndex;
|
|
155
|
+
args.dropRecord = this.parent.updatedRecords[args.dropIndex];
|
|
156
|
+
this.parent.trigger('rowDrop', args);
|
|
157
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
158
|
+
if (args.dropPosition === 'middleSegment') {
|
|
159
|
+
if (args.dropRecord.level === 1 || args.dropRecord.uniqueID === getValue('parentItem', args.data[0]).uniqueID) {
|
|
160
|
+
args.cancel = true; // preventing to drop the record as child to any child records
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (args.dropPosition !== 'middleSegment') {
|
|
164
|
+
if (args.dropRecord.level === 0 || getValue('parentItem', args.data[0]).uniqueID === args.dropRecord.parentItem.uniqueID) {
|
|
165
|
+
args.cancel = true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!args.cancel) {
|
|
170
|
+
args.cancel = true;
|
|
171
|
+
args.requestType = 'beforeDrop';
|
|
172
|
+
this.parent.trigger('actionBegin', args);
|
|
173
|
+
this.dropRows(args, true); // method to update the data collections based on drop action
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
private dropRows(args: RowDropEventArgs, isByMethod?: boolean): void {
|
|
177
|
+
if (!this.parent.readOnly) {
|
|
178
|
+
this.dropPosition = args.dropPosition;
|
|
179
|
+
if (args.dropPosition !== 'Invalid' && this.parent.editModule) {
|
|
180
|
+
const gObj: Gantt = this.parent;
|
|
181
|
+
let draggedRecord: IGanttData;
|
|
182
|
+
this.droppedRecord = gObj.updatedRecords[args.dropIndex];
|
|
183
|
+
let dragRecords: IGanttData[] = [];
|
|
184
|
+
const droppedRecord: IGanttData = this.droppedRecord;
|
|
185
|
+
if (!args.data[0]) {
|
|
186
|
+
dragRecords.push(args.data as IGanttData);
|
|
187
|
+
} else {
|
|
188
|
+
dragRecords = args.data;
|
|
189
|
+
}
|
|
190
|
+
let count: number = 0;
|
|
191
|
+
const dragLength: number = dragRecords.length;
|
|
192
|
+
for (let i: number = 0; i < dragLength; i++) {
|
|
193
|
+
this.parent.isOnEdit = true;
|
|
194
|
+
draggedRecord = dragRecords[i];
|
|
195
|
+
this.draggedRecord = draggedRecord;
|
|
196
|
+
if (this.dropPosition !== 'Invalid') {
|
|
197
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
198
|
+
this.checkisSharedTask();
|
|
199
|
+
this.previousParent = this.draggedRecord.parentItem.uniqueID;
|
|
200
|
+
}
|
|
201
|
+
if (this.isSharedTask) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (isByMethod) {
|
|
205
|
+
this.deleteDragRow();
|
|
206
|
+
}
|
|
207
|
+
const recordIndex1: number = this.treeGridData.indexOf(droppedRecord);
|
|
208
|
+
if (this.dropPosition === 'topSegment') {
|
|
209
|
+
this.dropAtTop(recordIndex1);
|
|
210
|
+
}
|
|
211
|
+
if (this.dropPosition === 'bottomSegment') {
|
|
212
|
+
if (!this.isSharedTask) {
|
|
213
|
+
if (!droppedRecord.hasChildRecords) {
|
|
214
|
+
if (this.parent.taskFields.parentID && this.ganttData.length > 0) {
|
|
215
|
+
this.ganttData.splice(recordIndex1 + 1, 0, this.draggedRecord.taskData);
|
|
216
|
+
}
|
|
217
|
+
this.treeGridData.splice(recordIndex1 + 1, 0, this.draggedRecord);
|
|
218
|
+
this.parent.ids.splice(recordIndex1 + 1, 0, this.draggedRecord.ganttProperties.rowUniqueID.toString());
|
|
219
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
220
|
+
const taskId: string = this.draggedRecord.level === 0 ? 'R' + this.draggedRecord.ganttProperties.taskId : 'T' + this.draggedRecord.ganttProperties.taskId;
|
|
221
|
+
this.parent.getTaskIds().splice(recordIndex1 + 1, 0, taskId);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
} else {
|
|
225
|
+
count = this.parent.editModule.getChildCount(droppedRecord, 0);
|
|
226
|
+
if (this.parent.taskFields.parentID && this.ganttData.length > 0) {
|
|
227
|
+
this.ganttData.splice(recordIndex1 + count + 1, 0, this.draggedRecord.taskData);
|
|
228
|
+
}
|
|
229
|
+
this.treeGridData.splice(recordIndex1 + count + 1, 0, this.draggedRecord);
|
|
230
|
+
/* eslint-disable-next-line */
|
|
231
|
+
this.parent.ids.splice(recordIndex1 + count + 1, 0, this.draggedRecord.ganttProperties.rowUniqueID.toString());
|
|
232
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
233
|
+
const spliceId: string = this.draggedRecord.level === 0 ? 'R' + this.draggedRecord.ganttProperties.taskId : 'T' + this.draggedRecord.ganttProperties.taskId;
|
|
234
|
+
this.parent.getTaskIds().splice(recordIndex1 + count + 1, 0, spliceId);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
this.parent.setRecordValue('parentItem', this.treeGridData[recordIndex1].parentItem, draggedRecord);
|
|
238
|
+
this.parent.setRecordValue('parentUniqueID', this.treeGridData[recordIndex1].parentUniqueID, draggedRecord);
|
|
239
|
+
this.parent.setRecordValue('level', this.treeGridData[recordIndex1].level, draggedRecord);
|
|
240
|
+
if (draggedRecord.hasChildRecords) {
|
|
241
|
+
const level: number = 1;
|
|
242
|
+
this.updateChildRecordLevel(draggedRecord, level);
|
|
243
|
+
this.updateChildRecord(draggedRecord, recordIndex1 + count + 1);
|
|
244
|
+
}
|
|
245
|
+
if (droppedRecord.parentItem) {
|
|
246
|
+
const rec: IGanttData[] = this.parent.getParentTask(droppedRecord.parentItem).childRecords;
|
|
247
|
+
const childRecords: IGanttData[] = rec;
|
|
248
|
+
const droppedRecordIndex: number = childRecords.indexOf(droppedRecord) + 1;
|
|
249
|
+
childRecords.splice(droppedRecordIndex, 0, draggedRecord);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (this.dropPosition === 'middleSegment') {
|
|
254
|
+
this.dropMiddle(recordIndex1);
|
|
255
|
+
if (droppedRecord.childRecords.length > 0) {
|
|
256
|
+
delete droppedRecord.ganttProperties.segments;
|
|
257
|
+
delete droppedRecord.taskData[this.parent.taskFields.segments];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// eslint-disable-next-line
|
|
261
|
+
if (!isNullOrUndefined(draggedRecord.parentItem && this.updateParentRecords.indexOf(draggedRecord.parentItem) !== -1)) {
|
|
262
|
+
this.updateParentRecords.push(draggedRecord.parentItem);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (!this.parent.enableVirtualization) {
|
|
266
|
+
let data: IGanttData[] = gObj.flatData;
|
|
267
|
+
let startIndex: number;
|
|
268
|
+
let endIndex: number;
|
|
269
|
+
let ganttData: Object[] = this.parent.dataSource as Object[];
|
|
270
|
+
let uniqueTaskID: string = this.parent.taskFields.id;
|
|
271
|
+
if (draggedRecord.index < droppedRecord.index) {
|
|
272
|
+
startIndex = draggedRecord.index;
|
|
273
|
+
for (let i: number = 0; i < ganttData.length; i++) {
|
|
274
|
+
let currentData: IGanttData = this.parent.currentViewData.filter(function (e: IGanttData) {
|
|
275
|
+
return e[uniqueTaskID] === ganttData[i][uniqueTaskID];
|
|
276
|
+
})[0];
|
|
277
|
+
if (currentData.index > droppedRecord.index) {
|
|
278
|
+
endIndex = currentData.index;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
startIndex = droppedRecord.index;
|
|
284
|
+
for (let i: number = 0; i < ganttData.length; i++) {
|
|
285
|
+
let currentData: IGanttData = this.parent.currentViewData.filter(function (e: IGanttData) {
|
|
286
|
+
return e[uniqueTaskID] === ganttData[i][uniqueTaskID];
|
|
287
|
+
})[0];
|
|
288
|
+
if (currentData.index > draggedRecord.index) {
|
|
289
|
+
endIndex = currentData.index;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for (let i: number = startIndex; i <= endIndex; i++) {
|
|
295
|
+
if (!isNullOrUndefined(data[i])) {
|
|
296
|
+
data[i].index = i;
|
|
297
|
+
if (!isNullOrUndefined(data[i].parentItem)) {
|
|
298
|
+
let updatedParent: ITreeData = data.filter((e: ITreeData) => {
|
|
299
|
+
return e.uniqueID === data[i].parentUniqueID;
|
|
300
|
+
})[0];
|
|
301
|
+
data[i].parentItem.index = updatedParent.index;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
gObj.rowDragAndDropModule.refreshDataSource();
|
|
307
|
+
}
|
|
308
|
+
if (this.dropPosition === 'middleSegment') {
|
|
309
|
+
if (droppedRecord.ganttProperties.predecessor) {
|
|
310
|
+
this.parent.editModule.removePredecessorOnDelete(droppedRecord);
|
|
311
|
+
droppedRecord.ganttProperties.predecessor = null;
|
|
312
|
+
droppedRecord.ganttProperties.predecessorsName = null;
|
|
313
|
+
droppedRecord[this.parent.taskFields.dependency] = null;
|
|
314
|
+
droppedRecord.taskData[this.parent.taskFields.dependency] = null;
|
|
315
|
+
}
|
|
316
|
+
if (droppedRecord.ganttProperties.isMilestone) {
|
|
317
|
+
this.parent.setRecordValue('isMilestone', false, droppedRecord.ganttProperties, true);
|
|
318
|
+
if (!isNullOrUndefined(droppedRecord.taskData[this.parent.taskFields.milestone])) {
|
|
319
|
+
if (droppedRecord.taskData[this.parent.taskFields.milestone] === true) {
|
|
320
|
+
droppedRecord.taskData[this.parent.taskFields.milestone] = false;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (this.parent.viewType === 'ResourceView' && !this.isSharedTask) {
|
|
326
|
+
let parentUniqueID: string;
|
|
327
|
+
if (this.dropPosition === 'middleSegment') {
|
|
328
|
+
parentUniqueID = this.droppedRecord.uniqueID;
|
|
329
|
+
} else {
|
|
330
|
+
parentUniqueID = this.droppedRecord.parentItem.uniqueID;
|
|
331
|
+
}
|
|
332
|
+
const droppedParentItem: IGanttData = this.parent.getTaskByUniqueID(parentUniqueID);
|
|
333
|
+
const editedObj: Object = {};
|
|
334
|
+
editedObj[this.parent.taskFields.resourceInfo] = [];
|
|
335
|
+
editedObj[this.parent.taskFields.resourceInfo].push(droppedParentItem.ganttProperties.taskId);
|
|
336
|
+
this.removeExistingResources();
|
|
337
|
+
const tempResourceInfo: Object[] = this.parent.dataOperation.setResourceInfo(editedObj);
|
|
338
|
+
const currentTask: IGanttData = this.draggedRecord;
|
|
339
|
+
if (isNullOrUndefined(currentTask.ganttProperties.resourceInfo)) {
|
|
340
|
+
currentTask.ganttProperties.resourceInfo = [];
|
|
341
|
+
}
|
|
342
|
+
if (droppedParentItem.ganttProperties.taskName === 'Unassigned Task') {
|
|
343
|
+
currentTask.ganttProperties.resourceInfo = [];
|
|
344
|
+
currentTask.ganttProperties.sharedTaskUniqueIds = [currentTask.ganttProperties.rowUniqueID];
|
|
345
|
+
} else {
|
|
346
|
+
currentTask.ganttProperties.resourceInfo.push(tempResourceInfo[0]);
|
|
347
|
+
}
|
|
348
|
+
this.updateCurrentTask(currentTask);
|
|
349
|
+
if (droppedParentItem.ganttProperties.taskName === 'Unassigned Task') {
|
|
350
|
+
this.deleteSharedResourceTask();
|
|
351
|
+
} else {
|
|
352
|
+
this.updateSharedResourceTask();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// method to update the edited parent records
|
|
356
|
+
for (let j: number = 0; j < this.updateParentRecords.length; j++) {
|
|
357
|
+
this.parent.dataOperation.updateParentItems(this.updateParentRecords[j]);
|
|
358
|
+
}
|
|
359
|
+
this.updateParentRecords = [];
|
|
360
|
+
this.parent.isOnEdit = false;
|
|
361
|
+
}
|
|
362
|
+
if (!isNullOrUndefined(this.parent.editModule)) {
|
|
363
|
+
this.parent.editModule.refreshRecord(args, true);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
private updateCurrentTask(currentTask: IGanttData): void {
|
|
368
|
+
this.parent.dataOperation.updateMappingData(currentTask, 'resourceInfo');
|
|
369
|
+
this.parent.editModule.updateResourceRelatedFields(currentTask, 'resource');
|
|
370
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
371
|
+
(this.parent.editModule.dialogModule as any).dialogEditValidationFlag = false;
|
|
372
|
+
this.parent.editModule.dialogModule.validateDuration(currentTask);
|
|
373
|
+
this.parent.dataOperation.updateWidthLeft(currentTask);
|
|
374
|
+
this.parent.dataOperation.updateTaskData(currentTask);
|
|
375
|
+
}
|
|
376
|
+
private deleteSharedResourceTask(): void {
|
|
377
|
+
for (let i: number = 0; i < this.parent.getTaskIds().length; i++) {
|
|
378
|
+
if (this.parent.getTaskIds()[i] === 'T' + this.draggedRecord.ganttProperties.taskId) {
|
|
379
|
+
if (this.parent.getTaskByUniqueID(this.parent.currentViewData[i].parentItem.uniqueID).ganttProperties.taskName !== 'Unassigned Task') {
|
|
380
|
+
this.removeRecords(this.parent.currentViewData[i]);
|
|
381
|
+
}
|
|
382
|
+
/* eslint-disable-next-line */
|
|
383
|
+
if (!isNullOrUndefined(this.parent.currentViewData[i].parentItem && this.updateParentRecords.indexOf(this.parent.currentViewData[i].parentItem) !== -1)) {
|
|
384
|
+
this.updateParentRecords.push(this.parent.currentViewData[i].parentItem);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
private removeExistingResources(): void {
|
|
390
|
+
const preParentRecord: IGanttData = this.parent.getTaskByUniqueID(this.previousParent);
|
|
391
|
+
if (this.draggedRecord.ganttProperties.resourceInfo) {
|
|
392
|
+
for (let count: number = 0; count < this.draggedRecord.ganttProperties.resourceInfo.length; count++) {
|
|
393
|
+
/* eslint-disable-next-line */
|
|
394
|
+
if (this.draggedRecord.ganttProperties.resourceInfo[count][this.parent.resourceFields.id] === preParentRecord.ganttProperties.taskId) {
|
|
395
|
+
this.draggedRecord.ganttProperties.resourceInfo.splice(count, 1);
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/*update the record for the same task which are shared with other tasks*/
|
|
402
|
+
private updateSharedResourceTask(): void {
|
|
403
|
+
for (let i: number = 0; i < this.parent.getTaskIds().length; i++) {
|
|
404
|
+
if (this.parent.getTaskIds()[i] === 'T' + this.draggedRecord.ganttProperties.taskId) {
|
|
405
|
+
this.parent.editModule.updateGanttProperties(this.draggedRecord, this.parent.flatData[i]);
|
|
406
|
+
this.parent.dataOperation.updateTaskData(this.parent.flatData[i]);
|
|
407
|
+
/* eslint-disable-next-line */
|
|
408
|
+
if (!isNullOrUndefined(this.parent.flatData[i].parentItem && this.updateParentRecords.indexOf(this.parent.currentViewData[i].parentItem) !== -1)) {
|
|
409
|
+
this.updateParentRecords.push(this.parent.flatData[i].parentItem);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
private _getExistingTaskWithID(record: IGanttData): IGanttData[] {
|
|
415
|
+
const existingTasks: IGanttData[] = [];
|
|
416
|
+
for (let i: number = 0; i < this.parent.getTaskIds().length; i++) {
|
|
417
|
+
if (this.parent.getTaskIds()[i] === 'T' + record.ganttProperties.taskId) {
|
|
418
|
+
existingTasks.push(this.parent.flatData[i]);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return existingTasks;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/*Method to remove resource from resource Info collection and update reosurce related fields*/
|
|
425
|
+
private removeResourceInfo(record: IGanttData): void {
|
|
426
|
+
const droppedParentItem: IGanttData = this.parent.getTaskByUniqueID(this.draggedRecord.parentItem.uniqueID);
|
|
427
|
+
if (record.ganttProperties.resourceInfo && record.ganttProperties.resourceInfo.length > 1) {
|
|
428
|
+
const sameIdTasks: IGanttData[] = this._getExistingTaskWithID(record);
|
|
429
|
+
let currentTask: IGanttData;
|
|
430
|
+
if (sameIdTasks == null) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
for (let i: number = 0; i < sameIdTasks.length; i++) {
|
|
434
|
+
currentTask = sameIdTasks[i];
|
|
435
|
+
const resources: object[] = currentTask.ganttProperties.resourceInfo;
|
|
436
|
+
for (let count: number = 0; count < resources.length; count++) {
|
|
437
|
+
if (resources[count][this.parent.resourceFields.id] === droppedParentItem.ganttProperties.taskId) {
|
|
438
|
+
resources.splice(count, 1);
|
|
439
|
+
this.parent.setRecordValue('resourceInfo', resources, currentTask.ganttProperties, true);
|
|
440
|
+
this.updateCurrentTask(currentTask);
|
|
441
|
+
if (!isNullOrUndefined(currentTask.parentItem && this.updateParentRecords.indexOf(currentTask.parentItem) !== -1)) {
|
|
442
|
+
this.updateParentRecords.push(currentTask.parentItem);
|
|
443
|
+
}
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
private refreshDataSource(): void {
|
|
451
|
+
const draggedRecord: IGanttData = this.draggedRecord;
|
|
452
|
+
const droppedRecord: IGanttData = this.droppedRecord;
|
|
453
|
+
const proxy: Gantt = this.parent;
|
|
454
|
+
let tempDataSource: Object; let idx: number;
|
|
455
|
+
if (this.parent.dataSource instanceof DataManager) {
|
|
456
|
+
tempDataSource = getValue('dataOperation.dataArray', this.parent);
|
|
457
|
+
} else {
|
|
458
|
+
tempDataSource = proxy.dataSource;
|
|
459
|
+
}
|
|
460
|
+
if ((tempDataSource as IGanttData[]).length > 0 && (!isNullOrUndefined(droppedRecord) && !droppedRecord.parentItem)) {
|
|
461
|
+
for (let i: number = 0; i < Object.keys(tempDataSource).length; i++) {
|
|
462
|
+
if (tempDataSource[i][this.parent.taskFields.child] === droppedRecord.taskData[this.parent.taskFields.child]) {
|
|
463
|
+
idx = i;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (this.dropPosition === 'topSegment') {
|
|
467
|
+
if (!this.parent.taskFields.parentID) {
|
|
468
|
+
(tempDataSource as IGanttData[]).splice(idx, 0, draggedRecord.taskData);
|
|
469
|
+
}
|
|
470
|
+
} else if (this.dropPosition === 'bottomSegment') {
|
|
471
|
+
if (!this.parent.taskFields.parentID) {
|
|
472
|
+
(tempDataSource as IGanttData[]).splice(idx + 1, 0, draggedRecord.taskData);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
} else if (!this.parent.taskFields.parentID && (!isNullOrUndefined(droppedRecord) && droppedRecord.parentItem)) {
|
|
476
|
+
if (this.dropPosition === 'topSegment' || this.dropPosition === 'bottomSegment') {
|
|
477
|
+
const rowPosition: RowPosition = this.dropPosition === 'topSegment' ? 'Above' : 'Below';
|
|
478
|
+
this.parent.editModule.addRowSelectedItem = droppedRecord;
|
|
479
|
+
this.parent.editModule.updateRealDataSource([draggedRecord], rowPosition);
|
|
480
|
+
delete this.parent.editModule.addRowSelectedItem;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (this.parent.taskFields.parentID) {
|
|
484
|
+
if (draggedRecord.parentItem) {
|
|
485
|
+
const droppedId: string = this.dropPosition === 'middleSegment' ? this.parent.taskFields.id :
|
|
486
|
+
this.parent.taskFields.parentID;
|
|
487
|
+
draggedRecord[this.parent.taskFields.parentID] = droppedRecord[droppedId];
|
|
488
|
+
draggedRecord.ganttProperties.parentId = droppedRecord[droppedId];
|
|
489
|
+
if ((this.parent.viewType === 'ResourceView' && !(this.dropPosition === 'middleSegment')) ||
|
|
490
|
+
this.parent.viewType === 'ProjectView') {
|
|
491
|
+
draggedRecord.taskData[this.parent.taskFields.parentID] = droppedRecord.taskData[droppedId];
|
|
492
|
+
}
|
|
493
|
+
} else {
|
|
494
|
+
draggedRecord[this.parent.taskFields.parentID] = null;
|
|
495
|
+
draggedRecord.taskData[this.parent.taskFields.parentID] = null;
|
|
496
|
+
draggedRecord.ganttProperties.parentId = null;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
private dropMiddle(recordIndex1: number): void {
|
|
502
|
+
const gObj: Gantt = this.parent;
|
|
503
|
+
const childRecords: number = this.parent.editModule.getChildCount(this.droppedRecord, 0);
|
|
504
|
+
const childRecordsLength: number = (isNullOrUndefined(childRecords) ||
|
|
505
|
+
childRecords === 0) ? recordIndex1 + 1 :
|
|
506
|
+
childRecords + recordIndex1 + 1;
|
|
507
|
+
if (this.dropPosition === 'middleSegment' && !this.isSharedTask) {
|
|
508
|
+
if (gObj.taskFields.parentID && this.ganttData.length > 0) {
|
|
509
|
+
this.ganttData.splice(childRecordsLength, 0, this.draggedRecord.taskData);
|
|
510
|
+
}
|
|
511
|
+
this.treeGridData.splice(childRecordsLength, 0, this.draggedRecord);
|
|
512
|
+
this.parent.ids.splice(childRecordsLength, 0, this.draggedRecord.ganttProperties.rowUniqueID.toString());
|
|
513
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
514
|
+
const recordId: string = this.draggedRecord.level === 0 ? 'R' + this.draggedRecord.ganttProperties.taskId : 'T' + this.draggedRecord.ganttProperties.taskId;
|
|
515
|
+
this.parent.getTaskIds().splice(childRecordsLength, 0, recordId);
|
|
516
|
+
}
|
|
517
|
+
if (this.draggedRecord.hasChildRecords) {
|
|
518
|
+
this.updateChildRecord(this.draggedRecord, childRecordsLength, this.droppedRecord.expanded);
|
|
519
|
+
}
|
|
520
|
+
this.recordLevel();
|
|
521
|
+
if (isNullOrUndefined(this.draggedRecord.parentItem &&
|
|
522
|
+
this.updateParentRecords.indexOf(this.draggedRecord.parentItem) !== -1)) {
|
|
523
|
+
this.updateParentRecords.push(this.draggedRecord.parentItem);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
private recordLevel(): void {
|
|
528
|
+
const gObj: Gantt = this.parent;
|
|
529
|
+
const draggedRecord: IGanttData = this.draggedRecord;
|
|
530
|
+
const droppedRecord: IGanttData = this.droppedRecord;
|
|
531
|
+
const childItem: string = gObj.taskFields.child;
|
|
532
|
+
if (!droppedRecord.hasChildRecords) {
|
|
533
|
+
droppedRecord.hasChildRecords = true;
|
|
534
|
+
if (!droppedRecord.childRecords.length) {
|
|
535
|
+
droppedRecord.childRecords = [];
|
|
536
|
+
if (!gObj.taskFields.parentID && isNullOrUndefined(droppedRecord.taskData[childItem])) {
|
|
537
|
+
droppedRecord.taskData[childItem] = [];
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (this.dropPosition === 'middleSegment') {
|
|
542
|
+
const parentItem: IGanttData = extend({}, droppedRecord);
|
|
543
|
+
delete parentItem.childRecords;
|
|
544
|
+
const createParentItem: IParent = {
|
|
545
|
+
uniqueID: parentItem.uniqueID,
|
|
546
|
+
expanded: parentItem.expanded,
|
|
547
|
+
level: parentItem.level,
|
|
548
|
+
index: parentItem.index,
|
|
549
|
+
taskId: parentItem.ganttProperties.rowUniqueID
|
|
550
|
+
};
|
|
551
|
+
this.parent.setRecordValue('parentItem', createParentItem, draggedRecord);
|
|
552
|
+
this.parent.setRecordValue('parentUniqueID', droppedRecord.uniqueID, draggedRecord);
|
|
553
|
+
droppedRecord.childRecords.splice(droppedRecord.childRecords.length, 0, draggedRecord);
|
|
554
|
+
if (!isNullOrUndefined(draggedRecord) && !gObj.taskFields.parentID && !isNullOrUndefined(droppedRecord.taskData[childItem])) {
|
|
555
|
+
droppedRecord.taskData[gObj.taskFields.child].splice(droppedRecord.childRecords.length, 0, draggedRecord.taskData);
|
|
556
|
+
}
|
|
557
|
+
if (!draggedRecord.hasChildRecords) {
|
|
558
|
+
draggedRecord.level = droppedRecord.level + 1;
|
|
559
|
+
} else {
|
|
560
|
+
const level: number = 1;
|
|
561
|
+
draggedRecord.level = droppedRecord.level + 1;
|
|
562
|
+
this.parent.setRecordValue('level' , this.draggedRecord.level , this.draggedRecord);
|
|
563
|
+
this.updateChildRecordLevel(draggedRecord, level);
|
|
564
|
+
}
|
|
565
|
+
droppedRecord.expanded = true;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
private deleteDragRow(): void {
|
|
569
|
+
this.treeGridData = isCountRequired(this.parent) ? getValue('result', this.parent.treeGrid.dataSource) :
|
|
570
|
+
this.parent.treeGrid.dataSource;
|
|
571
|
+
if (this.parent.dataSource instanceof DataManager) {
|
|
572
|
+
this.ganttData = getValue('dataOperation.dataArray', this.parent);
|
|
573
|
+
} else {
|
|
574
|
+
this.ganttData = isCountRequired(this.parent) ? getValue('result', this.parent.dataSource) :
|
|
575
|
+
this.parent.dataSource as Object[];
|
|
576
|
+
}
|
|
577
|
+
const deletedRow: IGanttData = this.parent.getTaskByUniqueID(this.draggedRecord.uniqueID);
|
|
578
|
+
this.removeRecords(deletedRow);
|
|
579
|
+
}
|
|
580
|
+
//method to check the dropped record has already present in the child collection
|
|
581
|
+
private checkisSharedTask(): void {
|
|
582
|
+
this.isSharedTask = false;
|
|
583
|
+
let sharedTask: IGanttData = null;
|
|
584
|
+
// eslint-disable-next-line
|
|
585
|
+
const parentUniqueID: string = this.droppedRecord.level === 0 ? this.droppedRecord.uniqueID : this.droppedRecord.parentItem.uniqueID;
|
|
586
|
+
const droppedParentItem: IGanttData = this.parent.getTaskByUniqueID(parentUniqueID);
|
|
587
|
+
const childTasks: IGanttData[] = droppedParentItem.childRecords;
|
|
588
|
+
for (let i: number = 0; i < childTasks.length; i++) {
|
|
589
|
+
if ('T' + this.draggedRecord.ganttProperties.taskId === 'T' + childTasks[i].ganttProperties.taskId) {
|
|
590
|
+
this.isSharedTask = true;
|
|
591
|
+
sharedTask = childTasks[i];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (this.isSharedTask) {
|
|
595
|
+
this.removeResourceInfo(sharedTask);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
private dropAtTop(recordIndex1: number): void {
|
|
599
|
+
const gObj: Gantt = this.parent;
|
|
600
|
+
if (!this.isSharedTask) {
|
|
601
|
+
if (gObj.taskFields.parentID && this.ganttData.length > 0) {
|
|
602
|
+
this.ganttData.splice(recordIndex1, 0, this.draggedRecord.taskData);
|
|
603
|
+
}
|
|
604
|
+
this.treeGridData.splice(recordIndex1, 0, this.draggedRecord);
|
|
605
|
+
this.parent.ids.splice(recordIndex1, 0, this.draggedRecord.ganttProperties.rowUniqueID.toString());
|
|
606
|
+
this.parent.setRecordValue('parentItem', this.droppedRecord.parentItem, this.draggedRecord);
|
|
607
|
+
this.parent.setRecordValue('parentUniqueID', this.droppedRecord.parentUniqueID, this.draggedRecord);
|
|
608
|
+
this.parent.setRecordValue('level', this.droppedRecord.level, this.draggedRecord);
|
|
609
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
610
|
+
const id: string = this.draggedRecord.level === 0 ? 'R' + this.draggedRecord.ganttProperties.taskId : 'T' + this.draggedRecord.ganttProperties.taskId;
|
|
611
|
+
this.parent.getTaskIds().splice(recordIndex1, 0, id);
|
|
612
|
+
}
|
|
613
|
+
if (this.draggedRecord.hasChildRecords) {
|
|
614
|
+
const level: number = 1;
|
|
615
|
+
this.updateChildRecord(this.draggedRecord, recordIndex1);
|
|
616
|
+
this.updateChildRecordLevel(this.draggedRecord, level);
|
|
617
|
+
}
|
|
618
|
+
if (this.droppedRecord.parentItem) {
|
|
619
|
+
const rec: IGanttData[] = this.parent.getParentTask(this.droppedRecord.parentItem).childRecords;
|
|
620
|
+
const childRecords: IGanttData[] = rec;
|
|
621
|
+
const droppedRecordIndex: number = childRecords.indexOf(this.droppedRecord);
|
|
622
|
+
childRecords.splice(droppedRecordIndex, 0, this.draggedRecord);
|
|
623
|
+
}
|
|
624
|
+
/* eslint-disable-next-line */
|
|
625
|
+
if (!isNullOrUndefined(this.draggedRecord.parentItem && this.updateParentRecords.indexOf(this.draggedRecord.parentItem) !== -1)) {
|
|
626
|
+
this.updateParentRecords.push(this.draggedRecord.parentItem);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
private updateChildRecordLevel(record: IGanttData, level: number): number {
|
|
631
|
+
let length: number = 0;
|
|
632
|
+
let currentRecord: IGanttData;
|
|
633
|
+
level++;
|
|
634
|
+
if (!record.hasChildRecords) {
|
|
635
|
+
return 0;
|
|
636
|
+
}
|
|
637
|
+
length = record.childRecords.length;
|
|
638
|
+
for (let i: number = 0; i < length; i++) {
|
|
639
|
+
currentRecord = record.childRecords[i];
|
|
640
|
+
let parentData: IGanttData;
|
|
641
|
+
if (record.parentItem) {
|
|
642
|
+
const id: string = 'uniqueIDCollection';
|
|
643
|
+
parentData = this.parent.treeGrid[id][record.parentItem.uniqueID];
|
|
644
|
+
}
|
|
645
|
+
currentRecord.level = record.parentItem ? parentData.level + level : record.level + 1;
|
|
646
|
+
this.parent.setRecordValue('level' , currentRecord.level , currentRecord);
|
|
647
|
+
if (currentRecord.hasChildRecords) {
|
|
648
|
+
level--;
|
|
649
|
+
level = this.updateChildRecordLevel(currentRecord, level);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return level;
|
|
653
|
+
}
|
|
654
|
+
// eslint-disable-next-line
|
|
655
|
+
private updateChildRecord(record: IGanttData, count: number, expanded?: boolean): number {
|
|
656
|
+
let currentRecord: IGanttData;
|
|
657
|
+
const gObj: Gantt = this.parent;
|
|
658
|
+
let length: number = 0;
|
|
659
|
+
if (!record.hasChildRecords) {
|
|
660
|
+
return 0;
|
|
661
|
+
}
|
|
662
|
+
length = record.childRecords.length;
|
|
663
|
+
for (let i: number = 0; i < length; i++) {
|
|
664
|
+
currentRecord = record.childRecords[i];
|
|
665
|
+
count++;
|
|
666
|
+
gObj.flatData.splice(count, 0, currentRecord);
|
|
667
|
+
this.parent.ids.splice(count, 0, currentRecord.ganttProperties.rowUniqueID.toString());
|
|
668
|
+
if (gObj.taskFields.parentID && (gObj.dataSource as IGanttData[]).length > 0) {
|
|
669
|
+
(this.ganttData as IGanttData[]).splice(count, 0, currentRecord.taskData);
|
|
670
|
+
}
|
|
671
|
+
if (currentRecord.hasChildRecords) {
|
|
672
|
+
count = this.updateChildRecord(currentRecord, count);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return count;
|
|
676
|
+
}
|
|
677
|
+
private removeRecords(record: IGanttData): void {
|
|
678
|
+
const gObj: Gantt = this.parent;
|
|
679
|
+
let dataSource: Object;
|
|
680
|
+
if (this.parent.dataSource instanceof DataManager) {
|
|
681
|
+
dataSource = getValue('dataOperation.dataArray', this.parent);
|
|
682
|
+
} else {
|
|
683
|
+
dataSource = this.parent.dataSource;
|
|
684
|
+
}
|
|
685
|
+
const deletedRow: IGanttData = record;
|
|
686
|
+
const flatParentData: IGanttData = this.parent.getParentTask(deletedRow.parentItem);
|
|
687
|
+
if (deletedRow) {
|
|
688
|
+
if (deletedRow.parentItem) {
|
|
689
|
+
const childRecords: IGanttData[] = flatParentData ? flatParentData.childRecords : [];
|
|
690
|
+
let childIndex: number = 0;
|
|
691
|
+
if (childRecords && childRecords.length > 0) {
|
|
692
|
+
if (this.parent.viewType === 'ResourceView' && childRecords.length === 1) {
|
|
693
|
+
//For updating the parent record which has zero parent reords.
|
|
694
|
+
this.parent.isOnDelete = true;
|
|
695
|
+
childRecords[0].isDelete = true;
|
|
696
|
+
this.parent.dataOperation.updateParentItems(flatParentData);
|
|
697
|
+
this.parent.isOnDelete = false;
|
|
698
|
+
childRecords[0].isDelete = false;
|
|
699
|
+
}
|
|
700
|
+
childIndex = childRecords.indexOf(deletedRow);
|
|
701
|
+
flatParentData.childRecords.splice(childIndex, 1);
|
|
702
|
+
if (!this.parent.taskFields.parentID && flatParentData.taskData[this.parent.taskFields.child]) {
|
|
703
|
+
flatParentData.taskData[this.parent.taskFields.child].splice(childIndex, 1);
|
|
704
|
+
}
|
|
705
|
+
// collection for updating parent record
|
|
706
|
+
this.updateParentRecords.push(flatParentData);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
//method to delete the record from datasource collection
|
|
710
|
+
if (!this.parent.taskFields.parentID) {
|
|
711
|
+
const deleteRecordIDs: string[] = [];
|
|
712
|
+
deleteRecordIDs.push(deletedRow.ganttProperties.taskId.toString());
|
|
713
|
+
if (this.parent.viewType === 'ProjectView' || (this.parent.viewType === 'ResourceView' && this.dropPosition !== 'middleSegment')) {
|
|
714
|
+
this.parent.editModule.removeFromDataSource(deleteRecordIDs);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (gObj.taskFields.parentID) {
|
|
718
|
+
if (deletedRow.hasChildRecords && deletedRow.childRecords.length > 0) {
|
|
719
|
+
this.removeChildItem(deletedRow);
|
|
720
|
+
}
|
|
721
|
+
let idx: number;
|
|
722
|
+
const ganttData: IGanttData[] = (dataSource as IGanttData[]).length > 0 && this.parent.viewType !== 'ResourceView' ?
|
|
723
|
+
dataSource as IGanttData[] : this.parent.updatedRecords;
|
|
724
|
+
for (let i: number = 0; i < ganttData.length; i++) {
|
|
725
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
726
|
+
if (ganttData[i].ganttProperties.rowUniqueID === deletedRow.ganttProperties.rowUniqueID) {
|
|
727
|
+
idx = i;
|
|
728
|
+
}
|
|
729
|
+
} else {
|
|
730
|
+
if (ganttData[i][this.parent.taskFields.id] === deletedRow.taskData[this.parent.taskFields.id]) {
|
|
731
|
+
idx = i;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (idx !== -1) {
|
|
736
|
+
if ((dataSource as IGanttData[]).length > 0) {
|
|
737
|
+
(dataSource as IGanttData[]).splice(idx, 1);
|
|
738
|
+
}
|
|
739
|
+
const tempIndex: number = this.treeGridData.indexOf(deletedRow);
|
|
740
|
+
this.treeGridData.splice(tempIndex, 1);
|
|
741
|
+
this.parent.ids.splice(tempIndex, 1);
|
|
742
|
+
if (this.parent.treeGrid.parentData.indexOf(deletedRow) !== -1) {
|
|
743
|
+
this.parent.treeGrid.parentData.splice(this.parent.treeGrid.parentData.indexOf(deletedRow), 1);
|
|
744
|
+
}
|
|
745
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
746
|
+
this.parent.getTaskIds().splice(idx, 1);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
const recordIndex: number = this.treeGridData.indexOf(deletedRow);
|
|
751
|
+
if (!gObj.taskFields.parentID) {
|
|
752
|
+
const deletedRecordCount: number = this.parent.editModule.getChildCount(deletedRow, 0);
|
|
753
|
+
this.treeGridData.splice(recordIndex, deletedRecordCount + 1);
|
|
754
|
+
this.parent.ids.splice(recordIndex, deletedRecordCount + 1);
|
|
755
|
+
const parentIndex: number = this.ganttData.indexOf(deletedRow.taskData);
|
|
756
|
+
if (parentIndex !== -1) {
|
|
757
|
+
this.ganttData.splice(parentIndex, 1);
|
|
758
|
+
this.parent.treeGrid.parentData.splice(parentIndex, 1);
|
|
759
|
+
}
|
|
760
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
761
|
+
this.parent.getTaskIds().splice(recordIndex, deletedRecordCount + 1);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (deletedRow.parentItem && flatParentData && flatParentData.childRecords && !flatParentData.childRecords.length) {
|
|
765
|
+
flatParentData.expanded = false;
|
|
766
|
+
flatParentData.hasChildRecords = false;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
private removeChildItem(record: IGanttData): void {
|
|
771
|
+
let currentRecord: IGanttData;
|
|
772
|
+
let idx: number;
|
|
773
|
+
for (let i: number = 0; i < record.childRecords.length; i++) {
|
|
774
|
+
currentRecord = record.childRecords[i];
|
|
775
|
+
let ganttData: Object;
|
|
776
|
+
if (this.parent.dataSource instanceof DataManager) {
|
|
777
|
+
ganttData = getValue('dataOperation.dataArray', this.parent);
|
|
778
|
+
} else {
|
|
779
|
+
ganttData = this.parent.dataSource;
|
|
780
|
+
}
|
|
781
|
+
for (let j: number = 0; j < (<IGanttData[]>ganttData).length; j++) {
|
|
782
|
+
if (ganttData[j][this.parent.taskFields.id] === currentRecord.taskData[this.parent.taskFields.id]) {
|
|
783
|
+
idx = j;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (idx !== -1) {
|
|
787
|
+
if ((ganttData as IGanttData[]).length > 0) {
|
|
788
|
+
(ganttData as IGanttData[]).splice(idx, 1);
|
|
789
|
+
}
|
|
790
|
+
const tempIndex: number = this.treeGridData.indexOf(currentRecord);
|
|
791
|
+
this.treeGridData.splice(tempIndex, 1);
|
|
792
|
+
this.parent.ids.splice(tempIndex, 1);
|
|
793
|
+
if (this.parent.viewType === 'ResourceView') {
|
|
794
|
+
this.parent.getTaskIds().splice(idx, 1);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (currentRecord.hasChildRecords) {
|
|
798
|
+
this.removeChildItem(currentRecord);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Reorder the rows based on given indexes and position
|
|
804
|
+
*
|
|
805
|
+
* @param {number[]} fromIndexes .
|
|
806
|
+
* @param {number} toIndex .
|
|
807
|
+
* @param {string} position .
|
|
808
|
+
* @returns {void} .
|
|
809
|
+
*/
|
|
810
|
+
public reorderRows(fromIndexes: number[], toIndex: number, position: string): void {
|
|
811
|
+
if (!this.parent.readOnly) {
|
|
812
|
+
// eslint-disable-next-line
|
|
813
|
+
if (fromIndexes[0] !== toIndex && position === 'above' || 'below' || 'child') {
|
|
814
|
+
if (position === 'above') {
|
|
815
|
+
this.dropPosition = 'topSegment';
|
|
816
|
+
}
|
|
817
|
+
if (position === 'below') {
|
|
818
|
+
this.dropPosition = 'bottomSegment';
|
|
819
|
+
}
|
|
820
|
+
if (position === 'child') {
|
|
821
|
+
this.dropPosition = 'middleSegment';
|
|
822
|
+
}
|
|
823
|
+
const data: IGanttData[] = [];
|
|
824
|
+
for (let i: number = 0; i < fromIndexes.length; i++) {
|
|
825
|
+
data[i] = this.parent.updatedRecords[fromIndexes[i]];
|
|
826
|
+
}
|
|
827
|
+
const isByMethod: boolean = true;
|
|
828
|
+
const args: RowDropEventArgs = {
|
|
829
|
+
data: data,
|
|
830
|
+
dropIndex: toIndex,
|
|
831
|
+
dropPosition: this.dropPosition
|
|
832
|
+
};
|
|
833
|
+
this.dropRows(args, isByMethod);
|
|
834
|
+
} else {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|