@syncfusion/ej2-gantt 22.1.36 → 22.1.38

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.
@@ -1467,8 +1467,16 @@ class DateProcessor {
1467
1467
  viewData.forEach((data) => {
1468
1468
  taskRange = [];
1469
1469
  const task = data.ganttProperties;
1470
- const tempStartDate = this.getValidStartDate(task);
1471
- const tempEndDate = this.getValidEndDate(task);
1470
+ let tempStartDate;
1471
+ let tempEndDate;
1472
+ if (isNullOrUndefined(task.startDate) && isNullOrUndefined(task.endDate)) {
1473
+ tempStartDate = null;
1474
+ tempEndDate = null;
1475
+ }
1476
+ else {
1477
+ tempStartDate = this.getValidStartDate(task);
1478
+ tempEndDate = this.getValidEndDate(task);
1479
+ }
1472
1480
  addDateToList(minStartDate);
1473
1481
  addDateToList(maxEndDate);
1474
1482
  addDateToList(tempStartDate);
@@ -1528,6 +1536,7 @@ class DateProcessor {
1528
1536
  setValue('minStartDate', minStartDate, editArgs);
1529
1537
  setValue('maxEndDate', maxEndDate, editArgs);
1530
1538
  }
1539
+ this.parent['isProjectDateUpdated'] = true;
1531
1540
  }
1532
1541
  /**
1533
1542
  *
@@ -2070,7 +2079,7 @@ class TaskProcessor extends DateProcessor {
2070
2079
  endDate = this.getEndDate(startDate, duration, data.ganttProperties.durationUnit, data.ganttProperties, false);
2071
2080
  }
2072
2081
  else if (!taskSettings.duration && taskSettings.endDate) {
2073
- endDate = (!isNullOrUndefined(data.ganttProperties.endDate)) && endDate.getTime() >
2082
+ endDate = (!isNullOrUndefined(data.ganttProperties.endDate)) && endDate.getTime() <
2074
2083
  data.ganttProperties.endDate.getTime() && i !== segments.length - 1 ? endDate : data.ganttProperties.endDate;
2075
2084
  duration = this.getDuration(startDate, endDate, data.ganttProperties.durationUnit, data.ganttProperties.isAutoSchedule, data.ganttProperties.isMilestone);
2076
2085
  if (ganttSegments.length > 0 && endDate.getTime() < startDate.getTime()
@@ -2713,38 +2722,59 @@ class TaskProcessor extends DateProcessor {
2713
2722
  modifiedsDate = new Date(modifiedsDate.getTime() + ganttData.duration * 60 * 60 * 1000);
2714
2723
  }
2715
2724
  if (ganttData && ganttData.durationUnit == 'minute') {
2716
- modifiedsDate = new Date(modifiedsDate.getTime() + ganttData.duration * 60 * 60 * 60 * 1000);
2725
+ modifiedsDate = new Date(modifiedsDate.getTime() + ganttData.duration * 60 * 1000);
2717
2726
  }
2718
2727
  for (let i = 0; i < this.parent.dayWorkingTime.length; i++) {
2719
2728
  hour = hour + this.parent.dayWorkingTime[i].to - this.parent.dayWorkingTime[i].from;
2720
2729
  }
2721
2730
  let dateDiff = modifiedsDate.getTime() - sDate.getTime();
2722
- if (tierMode === 'Day') {
2723
- if ((Math.floor((dateDiff / (1000 * 60 * 60)) % 24) >= hour || dateDiff === 0)) {
2724
- isValid = true;
2731
+ if (ganttData && ganttData.durationUnit == 'minute' && ganttData.duration < (hour * 60)) {
2732
+ if (tierMode === 'Day') {
2733
+ if ((Math.floor((dateDiff / (1000 * 60 * 60)) % 24) >= hour || dateDiff === 0)) {
2734
+ isValid = true;
2735
+ }
2736
+ if (this.getSecondsInDecimal(sDate) === this.parent.defaultStartTime && isValid) {
2737
+ sDate.setHours(0, 0, 0, 0);
2738
+ }
2739
+ if (this.getSecondsInDecimal(eDate) === this.parent.defaultEndTime) {
2740
+ eDate.setHours(24);
2741
+ }
2742
+ if (this.getSecondsInDecimal(eDate) === this.parent.defaultStartTime) {
2743
+ eDate.setHours(0, 0, 0, 0);
2744
+ }
2725
2745
  }
2726
- if (this.getSecondsInDecimal(sDate) === this.parent.defaultStartTime && isValid) {
2727
- sDate.setHours(0, 0, 0, 0);
2746
+ else {
2747
+ isValid = true;
2728
2748
  }
2729
- if (this.getSecondsInDecimal(eDate) === this.parent.defaultEndTime) {
2730
- eDate.setHours(24);
2749
+ if ((sDate).getTime() === (eDate).getTime()) {
2750
+ return (this.parent.perDayWidth);
2731
2751
  }
2732
- if (this.getSecondsInDecimal(eDate) === this.parent.defaultStartTime) {
2733
- eDate.setHours(0, 0, 0, 0);
2752
+ else {
2753
+ if (isValid) {
2754
+ return ((this.getTimeDifference(sDate, eDate) / (1000 * 60 * 60 * 24)) * this.parent.perDayWidth);
2755
+ }
2756
+ else {
2757
+ return ((this.getTimeDifference(sDate, eDate) / (1000 * 60 * 60 * hour)) * this.parent.perDayWidth);
2758
+ }
2734
2759
  }
2735
2760
  }
2736
2761
  else {
2737
- isValid = true;
2738
- }
2739
- if ((sDate).getTime() === (eDate).getTime()) {
2740
- return (this.parent.perDayWidth);
2741
- }
2742
- else {
2743
- if (isValid) {
2744
- return ((this.getTimeDifference(sDate, eDate) / (1000 * 60 * 60 * 24)) * this.parent.perDayWidth);
2762
+ if (tierMode === 'Day') {
2763
+ if (this.getSecondsInDecimal(sDate) === this.parent.defaultStartTime) {
2764
+ sDate.setHours(0, 0, 0, 0);
2765
+ }
2766
+ if (this.getSecondsInDecimal(eDate) === this.parent.defaultEndTime) {
2767
+ eDate.setHours(24);
2768
+ }
2769
+ if (this.getSecondsInDecimal(eDate) === this.parent.defaultStartTime) {
2770
+ eDate.setHours(0, 0, 0, 0);
2771
+ }
2772
+ }
2773
+ if ((sDate).getTime() === (eDate).getTime()) {
2774
+ return (this.parent.perDayWidth);
2745
2775
  }
2746
2776
  else {
2747
- return ((this.getTimeDifference(sDate, eDate) / (1000 * 60 * 60 * hour)) * this.parent.perDayWidth);
2777
+ return ((this.getTimeDifference(sDate, eDate) / (1000 * 60 * 60 * 24)) * this.parent.perDayWidth);
2748
2778
  }
2749
2779
  }
2750
2780
  }
@@ -5120,7 +5150,6 @@ class GanttChart {
5120
5150
  this.updateWidthAndHeight();
5121
5151
  this.reRenderConnectorLines();
5122
5152
  getValue('chartRow', args).setAttribute('aria-expanded', 'false');
5123
- this.parent.trigger('collapsed', args);
5124
5153
  }
5125
5154
  /**
5126
5155
  * To expand gantt rows
@@ -5174,7 +5203,6 @@ class GanttChart {
5174
5203
  this.updateWidthAndHeight();
5175
5204
  this.reRenderConnectorLines();
5176
5205
  getValue('chartRow', args).setAttribute('aria-expanded', 'true');
5177
- this.parent.trigger('expanded', args);
5178
5206
  }
5179
5207
  renderMultiTaskbar(record) {
5180
5208
  if (this.parent.enableMultiTaskbar) {
@@ -5218,20 +5246,27 @@ class GanttChart {
5218
5246
  removeClass([targetElement[t]], 'e-row-expand');
5219
5247
  }
5220
5248
  }
5221
- const childRecords = record.childRecords;
5222
- const chartRows = this.getChartRows();
5223
- const rows = [];
5224
- for (let i = 0; i < chartRows.length; i++) {
5225
- if (chartRows[i].classList.contains('gridrowtaskId'
5226
- + record.ganttProperties.rowUniqueID + 'level' + (record.level + 1))) {
5227
- rows.push(chartRows[i]);
5249
+ if (!this.parent.enableVirtualization) {
5250
+ const childRecords = record.childRecords;
5251
+ const chartRows = this.getChartRows();
5252
+ const rows = [];
5253
+ for (let i = 0; i < chartRows.length; i++) {
5254
+ if (chartRows[i].classList.contains("gridrowtaskId" +
5255
+ record.ganttProperties.rowUniqueID +
5256
+ "level" +
5257
+ (record.level + 1))) {
5258
+ rows.push(chartRows[i]);
5259
+ }
5228
5260
  }
5229
- }
5230
- for (let i = 0; i < rows.length; i++) {
5231
- rows[i].style.display = displayType;
5232
- if ((childRecords[i].childRecords && childRecords[i].childRecords.length)
5233
- && (action === 'collapse' || childRecords[i].expanded || this.isExpandAll)) {
5234
- this.expandCollapseChartRows(action, rows[i], childRecords[i], true);
5261
+ for (let i = 0; i < rows.length; i++) {
5262
+ rows[i].style.display = displayType;
5263
+ if (childRecords[i].childRecords &&
5264
+ childRecords[i].childRecords.length &&
5265
+ (action === "collapse" ||
5266
+ childRecords[i].expanded ||
5267
+ this.isExpandAll)) {
5268
+ this.expandCollapseChartRows(action, rows[i], childRecords[i], true);
5269
+ }
5235
5270
  }
5236
5271
  }
5237
5272
  }
@@ -5894,6 +5929,9 @@ class Timeline {
5894
5929
  */
5895
5930
  processZooming(isZoomIn) {
5896
5931
  this.isZoomToFit = false;
5932
+ if (!this.parent['isProjectDateUpdated']) {
5933
+ this.parent.dateValidationModule.calculateProjectDates();
5934
+ }
5897
5935
  if (!isNullOrUndefined(this.parent.zoomingProjectStartDate)) {
5898
5936
  this.parent.cloneProjectStartDate = this.parent.cloneProjectStartDate.getTime() < this.parent.zoomingProjectStartDate.getTime()
5899
5937
  ? this.parent.cloneProjectStartDate : this.parent.zoomingProjectStartDate;
@@ -6068,6 +6106,8 @@ class Timeline {
6068
6106
  this.parent.showSpinner();
6069
6107
  }
6070
6108
  this.changeTimelineSettings(newTimeline);
6109
+ this.isZoomToFit = false;
6110
+ this.parent.isTimelineRoundOff = this.isZoomToFit ? false : isNullOrUndefined(this.parent.projectStartDate) ? true : false;
6071
6111
  }
6072
6112
  bottomTierCellWidthCalc(mode, zoomLevel, date) {
6073
6113
  let convertedMilliSeconds;
@@ -7585,25 +7625,60 @@ class GanttTreeGrid {
7585
7625
  collapsing(args) {
7586
7626
  // Collapsing event
7587
7627
  const callBackPromise = new Deferred();
7628
+ let collapsingArgs;
7629
+ const record = getValue('data', args);
7630
+ const recordLength = record.length;
7588
7631
  if (!this.parent.ganttChartModule.isExpandCollapseFromChart) {
7589
- const collapsingArgs = this.createExpandCollapseArgs(args);
7590
- this.parent.ganttChartModule.collapseGanttRow(collapsingArgs);
7591
- setValue('cancel', getValue('cancel', collapsingArgs), args);
7632
+ if (!isNullOrUndefined(recordLength)) {
7633
+ for (let i = 0; i < recordLength; i++) {
7634
+ collapsingArgs = this.createExpandCollapseArgs(args, record[i]);
7635
+ this.parent.ganttChartModule.collapseGanttRow(collapsingArgs);
7636
+ }
7637
+ setValue('cancel', getValue('cancel', collapsingArgs), args);
7638
+ }
7639
+ else {
7640
+ collapsingArgs = this.createExpandCollapseArgs(args, null);
7641
+ this.parent.ganttChartModule.collapseGanttRow(collapsingArgs);
7642
+ setValue('cancel', getValue('cancel', collapsingArgs), args);
7643
+ }
7592
7644
  }
7593
7645
  }
7594
7646
  expanding(args) {
7595
7647
  // Expanding event
7596
7648
  const callBackPromise = new Deferred();
7649
+ let expandingArgs;
7650
+ const record = getValue('data', args);
7651
+ const recordLength = record.length;
7597
7652
  if (!this.parent.ganttChartModule.isExpandCollapseFromChart) {
7598
- const expandingArgs = this.createExpandCollapseArgs(args);
7599
- this.parent.ganttChartModule.expandGanttRow(expandingArgs);
7600
- setValue('cancel', getValue('cancel', expandingArgs), args);
7653
+ if (!isNullOrUndefined(recordLength)) {
7654
+ for (let i = 0; i < recordLength; i++) {
7655
+ expandingArgs = this.createExpandCollapseArgs(args, record[i]);
7656
+ this.parent.ganttChartModule.expandGanttRow(expandingArgs);
7657
+ }
7658
+ setValue('cancel', getValue('cancel', expandingArgs), args);
7659
+ }
7660
+ else {
7661
+ expandingArgs = this.createExpandCollapseArgs(args, null);
7662
+ this.parent.ganttChartModule.expandGanttRow(expandingArgs);
7663
+ setValue('cancel', getValue('cancel', expandingArgs), args);
7664
+ }
7601
7665
  }
7602
7666
  }
7603
7667
  collapsed(args) {
7604
7668
  if (!this.parent.ganttChartModule.isExpandCollapseFromChart && !this.parent.isExpandCollapseLevelMethod) {
7605
- const collapsedArgs = this.createExpandCollapseArgs(args);
7606
- this.parent.ganttChartModule.collapsedGanttRow(collapsedArgs);
7669
+ let collapsedArgs;
7670
+ const record = getValue('data', args);
7671
+ const recordLength = record.length;
7672
+ if (!isNullOrUndefined(recordLength)) {
7673
+ for (let i = 0; i < recordLength; i++) {
7674
+ collapsedArgs = this.createExpandCollapseArgs(args, record[i]);
7675
+ this.parent.ganttChartModule.collapsedGanttRow(collapsedArgs);
7676
+ }
7677
+ }
7678
+ else {
7679
+ collapsedArgs = this.createExpandCollapseArgs(args, null);
7680
+ this.parent.ganttChartModule.collapsedGanttRow(collapsedArgs);
7681
+ }
7607
7682
  if (this.parent.viewType === 'ResourceView' && !this.parent.allowTaskbarOverlap && collapsedArgs['gridRow']) {
7608
7683
  collapsedArgs['gridRow'].style.height = collapsedArgs['chartRow'].style.height;
7609
7684
  this.parent.contentHeight = this.parent.enableRtl ? this.parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
@@ -7617,19 +7692,29 @@ class GanttTreeGrid {
7617
7692
  else {
7618
7693
  this.parent.hideSpinner();
7619
7694
  }
7695
+ this.parent.trigger('collapsed', args);
7620
7696
  }
7621
7697
  expanded(args) {
7622
7698
  if (!this.parent.ganttChartModule.isExpandCollapseFromChart && !this.parent.isExpandCollapseLevelMethod) {
7623
- if (!args['data'].length) {
7624
- const expandedArgs = this.createExpandCollapseArgs(args);
7625
- this.parent.ganttChartModule.expandedGanttRow(expandedArgs);
7626
- if (this.parent.viewType === 'ResourceView' && !this.parent.allowTaskbarOverlap && args['row']) {
7627
- args['row'].style.height = this.parent.rowHeight + 'px';
7628
- this.parent.contentHeight = this.parent.enableRtl ? this.parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
7629
- this.parent['element'].getElementsByClassName('e-content')[0].children[0]['offsetHeight'];
7630
- document.getElementsByClassName('e-chart-rows-container')[0]['style'].height = this.parent.contentHeight + 'px';
7699
+ let expandedArgs;
7700
+ const record = getValue('data', args);
7701
+ const recordLength = record.length;
7702
+ if (!isNullOrUndefined(recordLength)) {
7703
+ for (let i = 0; i < recordLength; i++) {
7704
+ expandedArgs = this.createExpandCollapseArgs(args, record[i]);
7705
+ this.parent.ganttChartModule.expandedGanttRow(expandedArgs);
7631
7706
  }
7632
7707
  }
7708
+ else {
7709
+ expandedArgs = this.createExpandCollapseArgs(args, null);
7710
+ this.parent.ganttChartModule.expandedGanttRow(expandedArgs);
7711
+ }
7712
+ if (this.parent.viewType === 'ResourceView' && !this.parent.allowTaskbarOverlap && args['row']) {
7713
+ args['row'].style.height = this.parent.rowHeight + 'px';
7714
+ this.parent.contentHeight = this.parent.enableRtl ? this.parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
7715
+ this.parent['element'].getElementsByClassName('e-content')[0].children[0]['offsetHeight'];
7716
+ document.getElementsByClassName('e-chart-rows-container')[0]['style'].height = this.parent.contentHeight + 'px';
7717
+ }
7633
7718
  }
7634
7719
  if (!isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === "Shimmer") {
7635
7720
  this.parent.hideMaskRow();
@@ -7637,6 +7722,7 @@ class GanttTreeGrid {
7637
7722
  else {
7638
7723
  this.parent.hideSpinner();
7639
7724
  }
7725
+ this.parent.trigger('expanded', args);
7640
7726
  }
7641
7727
  actionBegin(args) {
7642
7728
  this.parent.notify('actionBegin', args);
@@ -7660,13 +7746,23 @@ class GanttTreeGrid {
7660
7746
  actionFailure(args) {
7661
7747
  this.parent.trigger('actionFailure', args);
7662
7748
  }
7663
- createExpandCollapseArgs(args) {
7664
- const record = getValue('data', args);
7665
- const gridRow = getValue('row', args);
7749
+ createExpandCollapseArgs(args, currentRecord) {
7666
7750
  let chartRow;
7667
- chartRow = this.parent.ganttChartModule.getChartRows()[this.parent.currentViewData.indexOf(record)];
7668
- const eventArgs = { data: record, gridRow: gridRow, chartRow: chartRow, cancel: false };
7669
- return eventArgs;
7751
+ const record = getValue('data', args);
7752
+ const recordLength = record.length;
7753
+ if (!isNullOrUndefined(recordLength)) {
7754
+ const gridRow = getValue('row', args);
7755
+ chartRow = this.parent.ganttChartModule.getChartRows()[this.parent.currentViewData.indexOf(currentRecord)];
7756
+ const eventArgs = { data: currentRecord, gridRow: gridRow, chartRow: chartRow, cancel: false };
7757
+ return eventArgs;
7758
+ }
7759
+ else {
7760
+ const record_1 = getValue('data', args);
7761
+ const gridRow = getValue('row', args);
7762
+ chartRow = this.parent.ganttChartModule.getChartRows()[this.parent.currentViewData.indexOf(record_1)];
7763
+ const eventArgs = { data: record_1, gridRow: gridRow, chartRow: chartRow, cancel: false };
7764
+ return eventArgs;
7765
+ }
7670
7766
  }
7671
7767
  treeActionComplete(args) {
7672
7768
  const updatedArgs = extend({}, args);
@@ -11128,6 +11224,9 @@ class Dependency {
11128
11224
  ganttRecord = predecessorsCollection[count];
11129
11225
  if ((!ganttRecord.hasChildRecords && !this.parent.allowParentDependency) || this.parent.allowParentDependency) {
11130
11226
  this.updatePredecessorHelper(ganttRecord, predecessorsCollection);
11227
+ if (!ganttRecord.ganttProperties.isAutoSchedule) {
11228
+ this.parent.connectorLineEditModule['calculateOffset'](ganttRecord);
11229
+ }
11131
11230
  }
11132
11231
  }
11133
11232
  }
@@ -11557,6 +11656,9 @@ class Dependency {
11557
11656
  if (validationOn !== 'predecessor' && this.parent.isValidationEnabled) {
11558
11657
  this.validateChildGanttRecord(parentGanttRecord, record);
11559
11658
  }
11659
+ else if (!record.ganttProperties.isAutoSchedule && this.parent.UpdateOffsetOnTaskbarEdit) {
11660
+ this.parent.connectorLineEditModule['calculateOffset'](record);
11661
+ }
11560
11662
  if (parentGanttRecord.expanded === false || record.expanded === false) {
11561
11663
  if (record) {
11562
11664
  this.validatePredecessor(record, undefined, 'successor');
@@ -19835,6 +19937,7 @@ class TaskbarEdit extends DateProcessor {
19835
19937
  }
19836
19938
  }
19837
19939
  }
19940
+ this.parent['isProjectDateUpdated'] = false;
19838
19941
  }
19839
19942
  /**
19840
19943
  * To cancel the taskbar edt action.
@@ -30280,65 +30383,79 @@ class ContextMenu$2 {
30280
30383
  }
30281
30384
  switch (this.item) {
30282
30385
  case 'TaskInformation':
30283
- if (isNaN(Number(this.rowData.ganttProperties.rowUniqueID))) {
30284
- this.parent.openEditDialog(this.rowData.ganttProperties.rowUniqueID);
30285
- }
30286
- else {
30287
- this.parent.openEditDialog(Number(this.rowData.ganttProperties.rowUniqueID));
30386
+ if (!isNullOrUndefined(this.rowData)) {
30387
+ if (isNaN(Number(this.rowData.ganttProperties.rowUniqueID))) {
30388
+ this.parent.openEditDialog(this.rowData.ganttProperties.rowUniqueID);
30389
+ }
30390
+ else {
30391
+ this.parent.openEditDialog(Number(this.rowData.ganttProperties.rowUniqueID));
30392
+ }
30288
30393
  }
30289
30394
  break;
30290
30395
  case 'Above':
30291
30396
  case 'Below':
30292
30397
  case 'Child':
30293
- position = this.item;
30294
- data = extend({}, {}, this.rowData.taskData, true);
30295
- taskfields = this.parent.taskFields;
30296
- if (data[taskfields.startDate]) {
30297
- this.parent.setRecordValue(taskfields.startDate, this.rowData.ganttProperties.startDate, data, true);
30298
- }
30299
- if (data[taskfields.endDate]) {
30300
- this.parent.setRecordValue(taskfields.endDate, this.rowData.ganttProperties.endDate, data, true);
30301
- }
30302
- if (!isNullOrUndefined(taskfields.dependency)) {
30303
- data[taskfields.dependency] = null;
30304
- }
30305
- if (!isNullOrUndefined(taskfields.child) && data[taskfields.child]) {
30306
- delete data[taskfields.child];
30307
- }
30308
- if (!isNullOrUndefined(taskfields.parentID) && data[taskfields.parentID]) {
30309
- data[taskfields.parentID] = null;
30398
+ if (!isNullOrUndefined(this.rowData)) {
30399
+ position = this.item;
30400
+ data = extend({}, {}, this.rowData.taskData, true);
30401
+ taskfields = this.parent.taskFields;
30402
+ if (data[taskfields.startDate]) {
30403
+ this.parent.setRecordValue(taskfields.startDate, this.rowData.ganttProperties.startDate, data, true);
30404
+ }
30405
+ if (data[taskfields.endDate]) {
30406
+ this.parent.setRecordValue(taskfields.endDate, this.rowData.ganttProperties.endDate, data, true);
30407
+ }
30408
+ if (!isNullOrUndefined(taskfields.dependency)) {
30409
+ data[taskfields.dependency] = null;
30410
+ }
30411
+ if (!isNullOrUndefined(taskfields.child) && data[taskfields.child]) {
30412
+ delete data[taskfields.child];
30413
+ }
30414
+ if (!isNullOrUndefined(taskfields.parentID) && data[taskfields.parentID]) {
30415
+ data[taskfields.parentID] = null;
30416
+ }
30417
+ if (this.rowData) {
30418
+ const rowIndex = this.parent.updatedRecords.indexOf(this.rowData);
30419
+ this.parent.addRecord(data, position, rowIndex);
30420
+ }
30310
30421
  }
30311
- if (this.rowData) {
30312
- const rowIndex = this.parent.updatedRecords.indexOf(this.rowData);
30313
- this.parent.addRecord(data, position, rowIndex);
30422
+ else if (this.parent.flatData.length === 0) {
30423
+ this.parent.addRecord();
30314
30424
  }
30315
30425
  break;
30316
30426
  case 'Milestone':
30317
30427
  case 'ToMilestone':
30318
- this.parent.convertToMilestone(this.rowData.ganttProperties.rowUniqueID);
30428
+ if (!isNullOrUndefined(this.rowData)) {
30429
+ this.parent.convertToMilestone(this.rowData.ganttProperties.rowUniqueID);
30430
+ }
30431
+ else if (this.parent.flatData.length === 0) {
30432
+ this.parent.addRecord();
30433
+ }
30319
30434
  break;
30320
30435
  case 'DeleteTask':
30321
30436
  this.parent.editModule.deleteRecord(this.rowData);
30322
30437
  break;
30323
30438
  case 'ToTask':
30324
- data = extend({}, {}, this.rowData.taskData, true);
30325
- taskfields = this.parent.taskFields;
30326
- if (!isNullOrUndefined(taskfields.duration)) {
30327
- const ganttProp = this.rowData.ganttProperties;
30328
- data[taskfields.duration] = '1 ' + ganttProp.durationUnit;
30329
- }
30330
- else {
30331
- data[taskfields.startDate] = new Date(this.rowData.taskData[taskfields.startDate]);
30332
- const endDate = new Date(this.rowData.taskData[taskfields.startDate]);
30333
- endDate.setDate(endDate.getDate() + 1);
30334
- data[taskfields.endDate] = endDate;
30335
- }
30336
- if (!isNullOrUndefined(data[taskfields.milestone])) {
30337
- if (data[taskfields.milestone] === true) {
30338
- data[taskfields.milestone] = false;
30439
+ if (!isNullOrUndefined(this.rowData)) {
30440
+ data = extend({}, {}, this.rowData.taskData, true);
30441
+ taskfields = this.parent.taskFields;
30442
+ if (!isNullOrUndefined(taskfields.duration)) {
30443
+ const ganttProp = this.rowData.ganttProperties;
30444
+ data[taskfields.duration] = '1 ' + ganttProp.durationUnit;
30445
+ }
30446
+ else {
30447
+ data[taskfields.startDate] = new Date(this.rowData.taskData[taskfields.startDate]);
30448
+ const endDate = new Date(this.rowData.taskData[taskfields.startDate]);
30449
+ endDate.setDate(endDate.getDate() + 1);
30450
+ data[taskfields.endDate] = endDate;
30451
+ }
30452
+ if (!isNullOrUndefined(data[taskfields.milestone])) {
30453
+ if (data[taskfields.milestone] === true) {
30454
+ data[taskfields.milestone] = false;
30455
+ }
30339
30456
  }
30457
+ this.parent.updateRecordByID(data);
30340
30458
  }
30341
- this.parent.updateRecordByID(data);
30342
30459
  break;
30343
30460
  case 'Cancel':
30344
30461
  this.parent.cancelEdit();
@@ -30491,7 +30608,7 @@ class ContextMenu$2 {
30491
30608
  this.contextMenu.enableItems(['Add', 'Save', 'Convert', 'Delete Dependency', 'Delete Task', 'TaskMode', 'Indent', 'Outdent', 'SplitTask', 'MergeTask'], false);
30492
30609
  }
30493
30610
  if ((isNullOrUndefined(args.gridRow) && isNullOrUndefined(args.chartRow)) || this.contentMenuItems.length === 0) {
30494
- if (!isNullOrUndefined(args.parentItem) && !isNullOrUndefined(menuElement)) {
30611
+ if (!isNullOrUndefined(args.parentItem) && !isNullOrUndefined(menuElement) || !isNullOrUndefined(closest(target, '.e-content'))) {
30495
30612
  args.cancel = false;
30496
30613
  }
30497
30614
  else {
@@ -30530,7 +30647,7 @@ class ContextMenu$2 {
30530
30647
  args.disableItems = this.disableItems;
30531
30648
  args.hideItems = this.hideItems;
30532
30649
  args.hideChildItems = [];
30533
- if (args.rowData.level === 0 && this.parent.viewType === 'ResourceView') {
30650
+ if (!isNullOrUndefined(args.rowData) && args.rowData.level === 0 && this.parent.viewType === 'ResourceView') {
30534
30651
  args.cancel = true;
30535
30652
  return;
30536
30653
  }
@@ -30572,6 +30689,9 @@ class ContextMenu$2 {
30572
30689
  if (!this.parent.editSettings.allowEditing || !this.parent.editModule) {
30573
30690
  this.updateItemVisibility(item.text);
30574
30691
  }
30692
+ if (this.parent.flatData.length === 0) {
30693
+ this.hideItems.push(item.text);
30694
+ }
30575
30695
  break;
30576
30696
  case 'Add':
30577
30697
  if (!this.parent.editSettings.allowAdding || !this.parent.editModule) {
@@ -30583,14 +30703,14 @@ class ContextMenu$2 {
30583
30703
  this.hideItems.push(item.text);
30584
30704
  break;
30585
30705
  case 'Convert':
30586
- if (this.rowData.hasChildRecords) {
30706
+ if (!isNullOrUndefined(this.rowData) && this.rowData.hasChildRecords) {
30587
30707
  this.hideItems.push(item.text);
30588
30708
  }
30589
30709
  else if (!this.parent.editSettings.allowEditing || !this.parent.editModule) {
30590
30710
  this.updateItemVisibility(item.text);
30591
30711
  }
30592
30712
  else {
30593
- if (!this.rowData.ganttProperties.isMilestone) {
30713
+ if (!isNullOrUndefined(this.rowData) && !this.rowData.ganttProperties.isMilestone) {
30594
30714
  subMenu.push(this.createItemModel(content, 'ToMilestone', this.getLocale('toMilestone')));
30595
30715
  }
30596
30716
  else {
@@ -30598,11 +30718,14 @@ class ContextMenu$2 {
30598
30718
  }
30599
30719
  item.items = subMenu;
30600
30720
  }
30721
+ if (this.parent.flatData.length === 0) {
30722
+ this.hideItems.push(item.text);
30723
+ }
30601
30724
  break;
30602
30725
  case 'DeleteDependency':
30603
30726
  {
30604
30727
  const items = this.getPredecessorsItems();
30605
- if (this.rowData.hasChildRecords) {
30728
+ if (!isNullOrUndefined(this.rowData) && this.rowData.hasChildRecords) {
30606
30729
  this.hideItems.push(item.text);
30607
30730
  }
30608
30731
  else if (!this.parent.editSettings.allowDeleting || items.length === 0 || !this.parent.editModule) {
@@ -30617,6 +30740,9 @@ class ContextMenu$2 {
30617
30740
  if (!this.parent.editSettings.allowDeleting || !this.parent.editModule) {
30618
30741
  this.updateItemVisibility(item.text);
30619
30742
  }
30743
+ if (this.parent.flatData.length === 0) {
30744
+ this.hideItems.push(item.text);
30745
+ }
30620
30746
  break;
30621
30747
  case 'TaskMode':
30622
30748
  if (this.parent.taskMode !== 'Custom') {