@syncfusion/ej2-gantt 20.4.50 → 20.4.52

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.
@@ -632,7 +632,7 @@ var DateProcessor = /** @__PURE__ @class */ (function () {
632
632
  * @returns {Date} .
633
633
  * @private
634
634
  */
635
- DateProcessor.prototype.getStartDate = function (endDate, duration, durationUnit, ganttProp) {
635
+ DateProcessor.prototype.getStartDate = function (endDate, duration, durationUnit, ganttProp, fromValidation) {
636
636
  var tempEnd = new Date(endDate.getTime());
637
637
  var startDate = new Date(endDate.getTime());
638
638
  var secondDuration = this.getDurationAsSeconds(duration, durationUnit);
@@ -648,6 +648,12 @@ var DateProcessor = /** @__PURE__ @class */ (function () {
648
648
  }
649
649
  tempEnd = new Date(startDate.getTime());
650
650
  }
651
+ /* To render the milestone in proper date while loading */
652
+ if (fromValidation && ganttProp.isMilestone) {
653
+ startDate.setDate(startDate.getDate() - 1);
654
+ this.parent.dateValidationModule.setTime(this.parent.defaultEndTime, startDate);
655
+ startDate = this.parent.dateValidationModule.checkStartDate(startDate, ganttProp, true);
656
+ }
651
657
  return startDate;
652
658
  };
653
659
  /**
@@ -699,6 +705,7 @@ var DateProcessor = /** @__PURE__ @class */ (function () {
699
705
  * @private
700
706
  */
701
707
  DateProcessor.prototype.getValidStartDate = function (ganttProp, isAuto) {
708
+ var _this = this;
702
709
  var sDate = null;
703
710
  var startDate = isAuto ? ganttProp.autoStartDate : ganttProp.startDate;
704
711
  var endDate = isAuto ? ganttProp.autoEndDate : ganttProp.endDate;
@@ -709,7 +716,21 @@ var DateProcessor = /** @__PURE__ @class */ (function () {
709
716
  this.setTime(this.parent.defaultStartTime, sDate);
710
717
  }
711
718
  else if (!isNullOrUndefined(duration)) {
712
- sDate = this.getProjectStartDate(ganttProp);
719
+ this.parent.flatData.map(function (record) {
720
+ if (record.ganttProperties.taskId == ganttProp.taskId) {
721
+ if ((!isNullOrUndefined(record.parentItem)) && (record.parentItem.taskId)) {
722
+ _this.parent.flatData.map(function (data) {
723
+ if (data.ganttProperties.taskId === record.parentItem.taskId) {
724
+ if (!isNullOrUndefined(data.ganttProperties.startDate))
725
+ sDate = data.ganttProperties.startDate;
726
+ }
727
+ });
728
+ }
729
+ else {
730
+ sDate = _this.getProjectStartDate(ganttProp);
731
+ }
732
+ }
733
+ });
713
734
  }
714
735
  }
715
736
  else {
@@ -1694,7 +1715,7 @@ var TaskProcessor = /** @__PURE__ @class */ (function (_super) {
1694
1715
  TaskProcessor.prototype.constructResourceViewDataSource = function (resources, data, unassignedTasks) {
1695
1716
  var _loop_1 = function (i) {
1696
1717
  var tempData = data[i];
1697
- var child = this_1.parent.taskFields.child;
1718
+ child = this_1.parent.taskFields.child != null ? this_1.parent.taskFields.child : 'Children';
1698
1719
  var resourceData = tempData && tempData[this_1.parent.taskFields.resourceInfo];
1699
1720
  var resourceIdMapping = this_1.parent.resourceFields.id;
1700
1721
  if ((!tempData[child] || tempData[child].length === 0) && resourceData && resourceData.length) {
@@ -1721,7 +1742,7 @@ var TaskProcessor = /** @__PURE__ @class */ (function (_super) {
1721
1742
  this_1.constructResourceViewDataSource(resources, tempData[this_1.parent.taskFields.child], unassignedTasks);
1722
1743
  }
1723
1744
  };
1724
- var this_1 = this;
1745
+ var this_1 = this, child;
1725
1746
  for (var i = 0; i < data.length; i++) {
1726
1747
  _loop_1(i);
1727
1748
  }
@@ -2942,6 +2963,40 @@ var TaskProcessor = /** @__PURE__ @class */ (function (_super) {
2942
2963
  task.taskData[this.parent.taskFields.durationUnit] = task.ganttProperties.durationUnit;
2943
2964
  }
2944
2965
  };
2966
+ TaskProcessor.prototype.setDataSource = function (data) {
2967
+ var createData = [];
2968
+ var length = data.length;
2969
+ for (var i = 0; i < length; i++) {
2970
+ var record = data[i];
2971
+ createData.push(record);
2972
+ if (!(isNullOrUndefined(data[i][this.parent.taskFields.child]))) {
2973
+ this.setDataSource(data[i][this.parent.taskFields.child]);
2974
+ }
2975
+ }
2976
+ return createData;
2977
+ };
2978
+ TaskProcessor.prototype.setStartDate = function (task) {
2979
+ var _this = this;
2980
+ var hierarchicalData = [];
2981
+ if (!isNullOrUndefined(this.parent.taskFields.parentID) && !isNullOrUndefined(this.parent.taskFields.id)) {
2982
+ hierarchicalData = this.setDataSource(this.parent.dataSource);
2983
+ }
2984
+ else {
2985
+ hierarchicalData = this.parent.dataSource;
2986
+ }
2987
+ this.parent.flatData.map(function (data) {
2988
+ hierarchicalData.map(function (record) {
2989
+ if (data.ganttProperties.taskId === record[_this.parent.taskFields.id]) {
2990
+ if (!isNullOrUndefined(_this.parent.taskFields.startDate)) {
2991
+ task[_this.parent.taskFields.endDate] = record[_this.parent.taskFields.endDate];
2992
+ }
2993
+ if (!isNullOrUndefined(_this.parent.taskFields.endDate)) {
2994
+ task[_this.parent.taskFields.endDate] = record[_this.parent.taskFields.endDate];
2995
+ }
2996
+ }
2997
+ });
2998
+ });
2999
+ };
2945
3000
  TaskProcessor.prototype.getWorkInHour = function (work, workUnit) {
2946
3001
  if (workUnit === 'day') {
2947
3002
  return work * (this.parent.secondsPerDay / 3600);
@@ -3236,6 +3291,9 @@ var TaskProcessor = /** @__PURE__ @class */ (function (_super) {
3236
3291
  if (!isNullOrUndefined(this.parent.taskFields.duration)) {
3237
3292
  this.setRecordDuration(ganttData, this.parent.taskFields.duration);
3238
3293
  }
3294
+ if (this.parent.isLoad) {
3295
+ this.setStartDate(ganttData);
3296
+ }
3239
3297
  this.calculateScheduledValues(ganttData, data, false);
3240
3298
  }
3241
3299
  this.updateGanttData();
@@ -5708,6 +5766,9 @@ var Timeline = /** @__PURE__ @class */ (function () {
5708
5766
  */
5709
5767
  Timeline.prototype.changeTimelineSettings = function (newTimeline) {
5710
5768
  var _this = this;
5769
+ if (!this.isZoomIn) {
5770
+ this.isSingleTier = newTimeline.topTier.unit === 'None' || newTimeline.bottomTier.unit === 'None' ? true : false;
5771
+ }
5711
5772
  var skipProperty = this.isSingleTier ?
5712
5773
  this.customTimelineSettings.topTier.unit === 'None' ?
5713
5774
  'topTier' : 'bottomTier' : null;
@@ -5719,7 +5780,9 @@ var Timeline = /** @__PURE__ @class */ (function () {
5719
5780
  else {
5720
5781
  var value = property === 'topTier' ? 'bottomTier' : 'topTier';
5721
5782
  var assignValue = 'bottomTier';
5722
- _this.customTimelineSettings[value] = __assign({}, newTimeline[assignValue]);
5783
+ if (newTimeline[assignValue].unit != "None") {
5784
+ _this.customTimelineSettings[value] = __assign({}, newTimeline[assignValue]);
5785
+ }
5723
5786
  }
5724
5787
  });
5725
5788
  this.parent.isTimelineRoundOff = this.isZoomToFit ? false : isNullOrUndefined(this.parent.projectStartDate) ? true : false;
@@ -5955,7 +6018,9 @@ var Timeline = /** @__PURE__ @class */ (function () {
5955
6018
  this.customTimelineSettings.bottomTier.count : this.customTimelineSettings.topTier.count;
5956
6019
  var unit = this.customTimelineSettings.bottomTier.unit !== 'None' ?
5957
6020
  this.customTimelineSettings.bottomTier.unit : this.customTimelineSettings.topTier.unit;
5958
- var zoomLevel = this.getCurrentZoomingLevel(unit, count);
6021
+ var tier = this.customTimelineSettings.bottomTier.unit !== 'None' ?
6022
+ "bottomTier" : "topTier";
6023
+ var zoomLevel = this.getCurrentZoomingLevel(unit, count, tier);
5959
6024
  if (this.parent.toolbarModule) {
5960
6025
  if (zoomLevel === this.parent.zoomingLevels[this.parent.zoomingLevels.length - 1].level) {
5961
6026
  this.parent.toolbarModule.enableItems([this.parent.controlId + '_zoomin'], false);
@@ -5973,7 +6038,7 @@ var Timeline = /** @__PURE__ @class */ (function () {
5973
6038
  * @returns {number} .
5974
6039
  * @private
5975
6040
  */
5976
- Timeline.prototype.getCurrentZoomingLevel = function (unit, count) {
6041
+ Timeline.prototype.getCurrentZoomingLevel = function (unit, count, tier) {
5977
6042
  var level;
5978
6043
  var currentZoomCollection;
5979
6044
  var checkSameCountLevels;
@@ -5983,16 +6048,31 @@ var Timeline = /** @__PURE__ @class */ (function () {
5983
6048
  this.parent.zoomingLevels = this.parent.getZoomingLevels();
5984
6049
  }
5985
6050
  var sameUnitLevels = this.parent.zoomingLevels.filter(function (tempLevel) {
5986
- return tempLevel.bottomTier.unit === unit;
6051
+ if (tier === "bottomTier") {
6052
+ return tempLevel.bottomTier.unit === unit;
6053
+ }
6054
+ else {
6055
+ return tempLevel.topTier.unit === unit;
6056
+ }
5987
6057
  });
5988
6058
  if (sameUnitLevels.length === 0) {
5989
6059
  var closestUnit_1 = this.getClosestUnit(unit, '', false);
5990
6060
  sameUnitLevels = this.parent.zoomingLevels.filter(function (tempLevel) {
5991
- return tempLevel.bottomTier.unit === closestUnit_1;
6061
+ if (tier === "bottomTier") {
6062
+ return tempLevel.bottomTier.unit === closestUnit_1;
6063
+ }
6064
+ else {
6065
+ return tempLevel.topTier.unit === closestUnit_1;
6066
+ }
5992
6067
  });
5993
6068
  }
5994
6069
  var sortedUnitLevels = sameUnitLevels.sort(function (a, b) {
5995
- return (a.bottomTier.count < b.bottomTier.count) ? 1 : -1;
6070
+ if (tier === "bottomTier") {
6071
+ return (a.bottomTier.count < b.bottomTier.count) ? 1 : -1;
6072
+ }
6073
+ else {
6074
+ return (a.topTier.count < b.topTier.count) ? 1 : -1;
6075
+ }
5996
6076
  });
5997
6077
  for (var i = 0; i < sortedUnitLevels.length; i++) {
5998
6078
  firstValue = sortedUnitLevels[i];
@@ -6003,10 +6083,15 @@ var Timeline = /** @__PURE__ @class */ (function () {
6003
6083
  else {
6004
6084
  secondValue = sortedUnitLevels[i + 1];
6005
6085
  }
6006
- if (count >= firstValue.bottomTier.count) {
6086
+ if (count >= firstValue[tier].count) {
6007
6087
  currentZoomCollection = sortedUnitLevels[i];
6008
6088
  checkSameCountLevels = sortedUnitLevels.filter(function (tempLevel) {
6009
- return tempLevel.bottomTier.count === currentZoomCollection.bottomTier.count;
6089
+ if (tier === "bottomTier") {
6090
+ return tempLevel.bottomTier.count === currentZoomCollection.bottomTier.count;
6091
+ }
6092
+ else {
6093
+ return tempLevel.topTier.count === currentZoomCollection.topTier.count;
6094
+ }
6010
6095
  });
6011
6096
  if (checkSameCountLevels.length > 1) {
6012
6097
  level = this.checkCollectionsWidth(checkSameCountLevels);
@@ -6016,10 +6101,15 @@ var Timeline = /** @__PURE__ @class */ (function () {
6016
6101
  }
6017
6102
  break;
6018
6103
  }
6019
- else if (count < firstValue.bottomTier.count && count > secondValue.bottomTier.count) {
6104
+ else if (count < firstValue[tier].count && count > secondValue[tier].count) {
6020
6105
  currentZoomCollection = sortedUnitLevels[i + 1];
6021
6106
  checkSameCountLevels = sortedUnitLevels.filter(function (tempLevel) {
6022
- return tempLevel.bottomTier.count === currentZoomCollection.bottomTier.count;
6107
+ if (tier === "bottomTier") {
6108
+ return tempLevel.bottomTier.count === currentZoomCollection.bottomTier.count;
6109
+ }
6110
+ else {
6111
+ return tempLevel.topTier.count === currentZoomCollection.topTier.count;
6112
+ }
6023
6113
  });
6024
6114
  if (checkSameCountLevels.length > 1) {
6025
6115
  level = this.checkCollectionsWidth(checkSameCountLevels);
@@ -11180,7 +11270,7 @@ var Dependency = /** @__PURE__ @class */ (function () {
11180
11270
  var offsetValue = predecessor.offset;
11181
11271
  var durationUnit = predecessor.offsetUnit;
11182
11272
  if (offsetValue < 0) {
11183
- resultDate = this.dateValidateModule.getStartDate(this.dateValidateModule.checkEndDate(date, record), (offsetValue * -1), durationUnit, record);
11273
+ resultDate = this.dateValidateModule.getStartDate(this.dateValidateModule.checkEndDate(date, record), (offsetValue * -1), durationUnit, record, true);
11184
11274
  }
11185
11275
  else {
11186
11276
  resultDate = this.dateValidateModule.getEndDate(date, offsetValue, durationUnit, record, false);
@@ -14705,6 +14795,7 @@ var Gantt = /** @__PURE__ @class */ (function (_super) {
14705
14795
  case 'dayWorkingTime':
14706
14796
  case 'allowUnscheduledTasks':
14707
14797
  case 'holidays':
14798
+ this.isLoad = true;
14708
14799
  if (prop === 'holidays') {
14709
14800
  this.totalHolidayDates = this.dataOperation.getHolidayDates();
14710
14801
  this.notify('ui-update', { module: 'day-markers', properties: newProp });
@@ -14713,6 +14804,7 @@ var Gantt = /** @__PURE__ @class */ (function (_super) {
14713
14804
  this.treeGrid.refreshColumns();
14714
14805
  this.chartRowsModule.initiateTemplates();
14715
14806
  this.chartRowsModule.refreshGanttRows();
14807
+ this.isLoad = false;
14716
14808
  break;
14717
14809
  case 'addDialogFields':
14718
14810
  case 'editDialogFields':
@@ -18418,6 +18510,16 @@ var TaskbarEdit = /** @__PURE__ @class */ (function (_super) {
18418
18510
  merge(_this.taskBarEditRecord.ganttProperties, arg.previousData);
18419
18511
  }
18420
18512
  });
18513
+ this.parent.flatData.map(function (data) {
18514
+ if ((!isNullOrUndefined(_this.taskBarEditRecord.parentItem)) && data.ganttProperties.taskId === _this.taskBarEditRecord.parentItem.taskId) {
18515
+ data.childRecords.map(function (s) {
18516
+ if (isNullOrUndefined(s.ganttProperties.startDate) || isNullOrUndefined(s.ganttProperties.endDate) ||
18517
+ isNullOrUndefined(s.ganttProperties.duration)) {
18518
+ _this.parent.dataOperation.updateGanttData();
18519
+ }
18520
+ });
18521
+ }
18522
+ });
18421
18523
  }
18422
18524
  };
18423
18525
  /**
@@ -18971,7 +19073,7 @@ var TaskbarEdit = /** @__PURE__ @class */ (function (_super) {
18971
19073
  };
18972
19074
  TaskbarEdit.prototype.updateChildDrag = function (item) {
18973
19075
  var left = this.getRoundOffStartLeft(item, this.roundOffDuration);
18974
- var projectStartDate = this.getDateByLeft(left);
19076
+ var projectStartDate = this.getDateByLeft(left, item.isMilestone, item);
18975
19077
  var endDate;
18976
19078
  if (this.segmentIndex === 0) {
18977
19079
  this.parent.setRecordValue('startDate', this.parent.dateValidationModule.checkStartDate(projectStartDate, item, null), item, true);
@@ -19194,10 +19296,16 @@ var TaskbarEdit = /** @__PURE__ @class */ (function (_super) {
19194
19296
  * @returns {Date} .
19195
19297
  * @private
19196
19298
  */
19197
- TaskbarEdit.prototype.getDateByLeft = function (left) {
19299
+ TaskbarEdit.prototype.getDateByLeft = function (left, isMilestone, property) {
19198
19300
  var pStartDate = new Date(this.parent.timelineModule.timelineStartDate.toString());
19199
19301
  var milliSecondsPerPixel = (24 * 60 * 60 * 1000) / this.parent.perDayWidth;
19200
19302
  pStartDate.setTime(pStartDate.getTime() + (left * milliSecondsPerPixel));
19303
+ /* To render the milestone in proper date while editing */
19304
+ if (isMilestone) {
19305
+ pStartDate.setDate(pStartDate.getDate() - 1);
19306
+ this.parent.dateValidationModule.setTime(this.parent.defaultEndTime, pStartDate);
19307
+ pStartDate = this.parent.dateValidationModule.checkStartDate(pStartDate, property, true);
19308
+ }
19201
19309
  var tierMode = this.parent.timelineModule.bottomTier !== 'None' ? this.parent.timelineModule.topTier :
19202
19310
  this.parent.timelineModule.bottomTier;
19203
19311
  if (tierMode !== 'Hour' && tierMode !== 'Minutes') {
@@ -24180,7 +24288,7 @@ var Edit$2 = /** @__PURE__ @class */ (function () {
24180
24288
  durationDiff = this.parent.dateValidationModule.getDuration(validStartDate, validEndDate, 'minute', true, false);
24181
24289
  }
24182
24290
  for (var i = 0; i < childRecords.length; i++) {
24183
- if (childRecords[i].ganttProperties.isAutoSchedule) {
24291
+ if ((!(this.parent.isUnscheduledTask(childRecords[i].ganttProperties))) && (childRecords[i].ganttProperties.isAutoSchedule)) {
24184
24292
  if (durationDiff > 0) {
24185
24293
  var startDate = isScheduledTask(childRecords[i].ganttProperties) ?
24186
24294
  childRecords[i].ganttProperties.startDate : childRecords[i].ganttProperties.startDate ?
@@ -24208,6 +24316,7 @@ var Edit$2 = /** @__PURE__ @class */ (function () {
24208
24316
  }
24209
24317
  if (childRecords.length) {
24210
24318
  this.parent.dataOperation.updateParentItems(ganttRecord, true);
24319
+ this.parent.dataOperation.updateGanttData();
24211
24320
  }
24212
24321
  };
24213
24322
  /**
@@ -24287,9 +24396,21 @@ var Edit$2 = /** @__PURE__ @class */ (function () {
24287
24396
  });
24288
24397
  };
24289
24398
  Edit$$1.prototype.dmSuccess = function (e, args) {
24290
- var eLength = e['length'];
24399
+ var eLength;
24400
+ var rec;
24401
+ if (e.changedRecords) {
24402
+ eLength = e.changedRecords['length'];
24403
+ }
24404
+ else {
24405
+ eLength = e['length'];
24406
+ }
24291
24407
  for (var i = 0; i < eLength; i++) {
24292
- var rec = e[i];
24408
+ if (e.changedRecords) {
24409
+ rec = e.changedRecords[i];
24410
+ }
24411
+ else {
24412
+ rec = e[i];
24413
+ }
24293
24414
  var _aLength = Object.keys(rec).length;
24294
24415
  for (var j = 0, _a = Object.keys(rec); j < _aLength; j++) {
24295
24416
  var key = _a[j];
@@ -24531,6 +24652,8 @@ var Edit$2 = /** @__PURE__ @class */ (function () {
24531
24652
  this.addRecordAsBottom(cAddedRecord);
24532
24653
  var parentRecord = this.parent.flatData[this.parent.flatData.length - 1];
24533
24654
  this.addNewRecord(updateRecord, parentRecord);
24655
+ var source = this.parent.dataSource;
24656
+ source.push(updateRecord.taskData);
24534
24657
  }
24535
24658
  var updatedData = this.parent.currentViewData.filter(function (data) {
24536
24659
  return (data.ganttProperties.taskId === updateRecord.ganttProperties.taskId &&
@@ -25952,9 +26075,9 @@ var Edit$2 = /** @__PURE__ @class */ (function () {
25952
26075
  var crud = data_2.saveChanges(updatedData_2, _this.parent.taskFields.id, null, query_2);
25953
26076
  crud.then(function (e) {
25954
26077
  if (_this.parent.taskFields.id && !isNullOrUndefined(e.addedRecords[0][_this.parent.taskFields.id]) &&
25955
- e.addedRecords[0][_this.parent.taskFields.id].toString() !== prevID_1) {
26078
+ e.addedRecords[0][_this.parent.taskFields.id].toString() == prevID_1) {
25956
26079
  _this.parent.setRecordValue('taskId', e.addedRecords[0][_this.parent.taskFields.id], args.data.ganttProperties, true);
25957
- _this.parent.setRecordValue('taskData.' + _this.parent.taskFields.id, e.addedRecords[0][_this.parent.taskFields.id], args.data);
26080
+ _this.parent.setRecordValue('taskData', e.addedRecords[0], args.data);
25958
26081
  _this.parent.setRecordValue(_this.parent.taskFields.id, e.addedRecords[0][_this.parent.taskFields.id], args.data);
25959
26082
  _this.parent.setRecordValue('rowUniqueID', e.addedRecords[0][_this.parent.taskFields.id].toString(), args.data.ganttProperties, true);
25960
26083
  var idsIndex = _this.parent.ids.indexOf(prevID_1);
@@ -34816,6 +34939,13 @@ var PdfGanttPredecessor = /** @__PURE__ @class */ (function () {
34816
34939
  PdfGanttPredecessor.prototype.add = function () {
34817
34940
  return new PdfGanttPredecessor(this.parent);
34818
34941
  };
34942
+ PdfGanttPredecessor.prototype.findindex = function (num) {
34943
+ var dataindex;
34944
+ this.parent.currentViewData.map(function (data, index) { if (data.index == num) {
34945
+ dataindex = index;
34946
+ } });
34947
+ return dataindex;
34948
+ };
34819
34949
  /**
34820
34950
  * Calculate the predecesor line point and draw the predecessor
34821
34951
  *
@@ -34826,8 +34956,8 @@ var PdfGanttPredecessor = /** @__PURE__ @class */ (function () {
34826
34956
  PdfGanttPredecessor.prototype.drawPredecessor = function (pdfGantt) {
34827
34957
  this.pdfGantt = pdfGantt;
34828
34958
  var pages = pdfGantt.result.page.section.getPages();
34829
- var parentTask = pdfGantt.taskbarCollection[this.parentIndex];
34830
- var childTask = pdfGantt.taskbarCollection[this.childIndex];
34959
+ var parentTask = pdfGantt.taskbarCollection[this.findindex(this.parentIndex)];
34960
+ var childTask = pdfGantt.taskbarCollection[this.findindex(this.childIndex)];
34831
34961
  var startPage = new PdfPage();
34832
34962
  var endPage = new PdfPage();
34833
34963
  var predecessorType = '';