all files / actions/ critical-path.js

96.96% Statements 511/527
88.78% Branches 364/410
100% Functions 18/18
96.96% Lines 511/527
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835   56× 56× 56× 56×     94× 94× 94× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91× 91×     91× 273× 161×   273×       91× 91× 1740× 1740× 1740× 1740× 1740× 1740× 663×   1740× 839× 805× 805×       91× 110×     91× 663× 567× 558×     126×   10×         567× 567× 567×   567× 567×     96×     91× 91× 663×   91× 91× 91× 805× 805× 805× 805× 805× 805× 805× 805× 805× 805× 1484× 1124×   360× 214×     146×   1484× 742× 621× 548× 548×     73× 73×       121× 80× 80×     41×   41×       1484× 1124×   360× 214×     146×   1484× 742× 587× 504× 504×     83×   83×       155× 124× 124×     31×   31×         805× 218× 218×   805× 184× 184×   805× 805×   91× 91× 91× 91× 805× 184× 184× 170×     14×   184× 184× 184× 184× 184× 184×           91× 184× 184×   91× 91× 91× 91× 91×   94×       3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 3519× 4705× 4705× 4705× 4705× 4679× 4679×     26× 26×   4705× 4705× 4705×   4705× 4705× 2780×   2778× 2777×         4705× 4705× 4592× 288×     4304×   4592× 562× 499× 198×     301×       4030×   2580× 1182× 40×     1142×       4592× 2754× 2754× 2754× 270×     4592× 4592× 4592× 4592× 12×     4705× 30× 27×     26×   27×           20×   17× 17×     11×       27×       27× 27× 27×               30×     4705× 34×   34× 10× 10×   34× 24× 24×   34×     30×   34× 31× 24×       24×                       34× 10× 10× 10×     34× 34× 34×   34×     4705× 49× 43× 15× 12×   11× 11×       11×   11×     10×                         15× 15× 15×     28× 22×     22× 22×       22×     22× 20×     20× 20×     19×                               28× 28× 28×             49×     4705× 3021×             3519× 3519× 3519× 2177× 3335×         83× 83× 83× 67×     16×     1558× 3706× 3706× 3660×     46× 46×   3706× 3706× 143× 143× 143× 143× 143×       3706× 3706× 3412×   294× 111×   183× 122×   61× 61×   3706×   1241× 1241× 1241× 1241× 1241×   447× 447× 447× 447×     1241× 753×           91× 91× 91× 91× 805× 772×     33×   805× 805× 805× 805× 1487× 1487× 1449×     38×   1487× 1487× 1487× 1487× 1329× 682×     647× 647× 647× 647× 373× 373×       1329× 1329× 177× 177×   1152× 162× 162×       158× 36×   122× 60×     62×   1487× 1126×     361×   1487×   439× 439×         805× 513× 475× 475× 475× 104×   475× 103×       805×   805×     91× 76× 567× 558×       567× 567× 567× 567×         91×   279× 279× 3498× 3498× 3438×     60× 720×   60× 77×   63×       3498× 3498× 3498× 3498× 3498× 2895× 73078×   2895× 2895× 2895× 1755× 1755× 1755×         3498×     3492×   3498×   2192× 326×   2192× 1530×   2192× 1536×       279× 279× 3498×   279× 258× 258× 258× 258× 258× 258× 2109× 2109× 2109× 1470× 1470× 1690× 1690× 36×   1690× 1690× 1412×   1690× 1550× 1550× 1550×   1550× 1286×   1286×                 27959×   56×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/css-constants"], function (require, exports, ej2_base_1, ej2_base_2, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CriticalPath = (function () {
        function CriticalPath(parent) {
            this.validatedids = [];
            this.resourceCollectionIds = [];
            this.criticalTasks = [];
            this.parent = parent;
        }
        CriticalPath.prototype.getCriticalTasks = function () {
            return this.criticalTasks;
        };
        CriticalPath.prototype.showCriticalPath = function (isCritical) {
            var modelIds = this.parent.ids;
            var totalRecords = this.parent.flatData;
            if (isCritical && this.parent.flatData.length > 0) {
                this.parent.enableCriticalPath = true;
                var parentRecords = this.parent.treeGrid.parentData;
                var checkEndDate = parentRecords[0].ganttProperties.endDate;
                var dateDifference = 0;
                var checkBeyondEnddate_1 = [];
                var totalPredecessorsCollection = [];
                var totalPredecessorsCollectionId = [];
                var predecessorIndex = 0;
                var taskBeyondEnddate = [];
                var predecessorTaskBeyondEnddate = [];
                var collection = [];
                var collectionTaskId = [];
                var fromDataObject = [];
                var criticalPathIds = [];
                this.criticalTasks = [];
                Iif (parentRecords[0].ganttProperties.autoEndDate > parentRecords[0].ganttProperties.endDate && !parentRecords[0].ganttProperties.isAutoSchedule) {
                    checkEndDate = parentRecords[0].ganttProperties.autoEndDate;
                }
                for (var i = 1; i < parentRecords.length; i++) {
                    if (parentRecords[i].ganttProperties.endDate >= checkEndDate) {
                        checkEndDate = parentRecords[i].ganttProperties.endDate;
                    }
                    if (!parentRecords[i].ganttProperties.isAutoSchedule) {
                        Eif (parentRecords[i].ganttProperties.autoEndDate >= checkEndDate) {
                            checkEndDate = parentRecords[i].ganttProperties.autoEndDate;
                        }
                    }
                }
                this.maxEndDate = checkEndDate;
                for (var j = 0; j < totalRecords.length; j++) {
                    totalRecords[j].isCritical = false;
                    totalRecords[j].ganttProperties.isCritical = false;
                    dateDifference = this.parent.dataOperation.getDuration(totalRecords[j].ganttProperties.endDate, checkEndDate, totalRecords[j].ganttProperties.durationUnit, totalRecords[j].ganttProperties.isAutoSchedule, totalRecords[j].ganttProperties.isMilestone);
                    totalRecords[j].slack = dateDifference + ' ' + totalRecords[j].ganttProperties.durationUnit;
                    totalRecords[j].ganttProperties.slack = dateDifference + ' ' + totalRecords[j].ganttProperties.durationUnit;
                    if (totalRecords[j].ganttProperties.endDate >= checkEndDate) {
                        checkBeyondEnddate_1.push(totalRecords[j].ganttProperties.taskId);
                    }
                    if (totalRecords[j].ganttProperties.predecessor) {
                        if (totalRecords[j].ganttProperties.predecessor.length !== 0) {
                            totalPredecessorsCollection.push(totalRecords[j]);
                            totalPredecessorsCollectionId.push((totalRecords[j].ganttProperties.taskId));
                        }
                    }
                }
                if (this.parent.viewType === 'ResourceView') {
                    for (var i = 0; i < this.parent.taskIds.length; i++) {
                        this.resourceCollectionIds[i] = this.parent.taskIds[i].slice(1);
                    }
                }
                var _loop_1 = function (k) {
                    if (totalPredecessorsCollectionId.indexOf(checkBeyondEnddate_1[k]) === -1) {
                        if (this_1.parent.viewType === 'ProjectView') {
                            predecessorIndex = modelIds.indexOf(checkBeyondEnddate_1[k].toString());
                        }
                        else {
                            var currentRecords = this_1.parent.currentViewData.filter(function (data) {
                                return parseInt(data.ganttProperties.taskId, 10) === checkBeyondEnddate_1[k];
                            });
                            for (var i = 0; i < currentRecords.length; i++) {
                                if (!currentRecords[i].hasChildRecords &&
                                    currentRecords[i].ganttProperties.endDate >= this_1.maxEndDate) {
                                    predecessorIndex = currentRecords[i].index;
                                }
                            }
                        }
                        Eif (totalRecords[predecessorIndex].ganttProperties.progress < 100) {
                            totalRecords[predecessorIndex].isCritical = true;
                            totalRecords[predecessorIndex].ganttProperties.isCritical = true;
                        }
                        totalRecords[predecessorIndex]['slack'] = 0 + ' ' + totalRecords[predecessorIndex].ganttProperties.durationUnit;
                        taskBeyondEnddate.push(checkBeyondEnddate_1[k]);
                    }
                    else {
                        predecessorTaskBeyondEnddate.push(checkBeyondEnddate_1[k]);
                    }
                };
                var this_1 = this;
                for (var k = 0; k < checkBeyondEnddate_1.length; k++) {
                    _loop_1(k);
                }
                var predecessorLength = totalPredecessorsCollection.length;
                var endTask = [];
                for (var x = 0; x < predecessorLength; x++) {
                    var to = -1;
                    var from = -1;
                    var toPredecessor = -1;
                    var fromPredecessor = -1;
                    var tempTaskId = void 0;
                    var currentIndex = x;
                    var predecessor = totalPredecessorsCollection[x].ganttProperties.predecessor;
                    var individualPredecessorLength = totalPredecessorsCollection[x].ganttProperties.predecessor.length;
                    var taskid = ((totalPredecessorsCollection[x].ganttProperties.taskId));
                    for (var y = 0; y < individualPredecessorLength; y++) {
                        if (!isNaN(Number(predecessor[y].from)) && typeof (taskid) !== 'string') {
                            tempTaskId = parseInt((predecessor[y].from), 10);
                        }
                        else if (!isNaN(Number(predecessor[y].from)) && typeof (taskid) === 'string') {
                            tempTaskId = predecessor[y].from;
                        }
                        else {
                            tempTaskId = predecessor[y].from;
                        }
                        if (tempTaskId === taskid) {
                            if (to === -1) {
                                if (!predecessor[y].offset) {
                                    to = predecessor[y].to;
                                    toPredecessor = predecessor[y].type;
                                }
                                else {
                                    to = predecessor[y].to + ':' + predecessor[y].offset + predecessor[y].offsetUnit;
                                    toPredecessor = predecessor[y].type;
                                }
                            }
                            else {
                                if (!predecessor[y].offset) {
                                    to = to + ',' + predecessor[y].to;
                                    toPredecessor = toPredecessor + ',' + predecessor[y].type;
                                }
                                else {
                                    to = to + ',' + predecessor[y].to + ':' + predecessor[y].offset +
                                        predecessor[y].offsetUnit;
                                    toPredecessor = toPredecessor + ',' + predecessor[y].type;
                                }
                            }
                        }
                        if (!isNaN(Number(predecessor[y].to)) && typeof (taskid) !== 'string') {
                            tempTaskId = parseInt((predecessor[y].to), 10);
                        }
                        else if (!isNaN(Number(predecessor[y].to)) && typeof (taskid) === 'string') {
                            tempTaskId = predecessor[y].to;
                        }
                        else {
                            tempTaskId = predecessor[y].to;
                        }
                        if (tempTaskId === taskid) {
                            if (from === -1) {
                                if (!predecessor[y].offset) {
                                    from = predecessor[y].from;
                                    fromPredecessor = predecessor[y].type;
                                }
                                else {
                                    from = predecessor[y].from + ':' + predecessor[y].offset +
                                        predecessor[y].offsetUnit;
                                    fromPredecessor = predecessor[y].type;
                                }
                            }
                            else {
                                if (!predecessor[y].offset) {
                                    from = from + ',' + predecessor[y].from;
                                    fromPredecessor = fromPredecessor + ',' + predecessor[y].type;
                                }
                                else {
                                    from = from + ',' + predecessor[y].from + ':' + predecessor[y].offset +
                                        predecessor[y].offsetUnit;
                                    fromPredecessor = fromPredecessor + ',' + predecessor[y].type;
                                }
                            }
                        }
                    }
                    if (from === -1) {
                        from = null;
                        fromPredecessor = null;
                    }
                    if (to === -1) {
                        to = null;
                        toPredecessor = null;
                    }
                    collection.push({ from: from, fromPredecessor: fromPredecessor, taskid: taskid, to: to, toPredecessor: toPredecessor, currentIndex: currentIndex, slack: null, enddate: null });
                    collectionTaskId.push(taskid);
                }
                var collectionLength = collection.length;
                var indexEnddate = 0;
                var num = void 0;
                for (var z = 0; z < collectionLength; z++) {
                    if (!collection[z]['to']) {
                        num = collection[z]['taskid'];
                        if (this.parent.viewType === 'ProjectView') {
                            indexEnddate = modelIds.indexOf(num.toString());
                        }
                        else {
                            indexEnddate = this.resourceCollectionIds.indexOf(num.toString());
                        }
                        var flatData = totalRecords[indexEnddate].ganttProperties;
                        dateDifference = this.parent.dataOperation.getDuration(flatData.endDate, checkEndDate, 'minute', flatData.isAutoSchedule, flatData.isMilestone);
                        collection[z]['slack'] = dateDifference;
                        collection[z]['fs'] = -1;
                        collection[z]['enddate'] = flatData.endDate;
                        endTask.push({
                            fromdata: collection[z]['from'], todateID: collection[z]['taskid'],
                            fromDataPredecessor: collection[z]['fromPredecessor']
                        });
                    }
                }
                for (var k = 0; k < endTask.length; k++) {
                    fromDataObject.push(endTask[k]);
                    this.slackCalculation(fromDataObject, collection, collectionTaskId, checkEndDate, totalRecords, modelIds);
                }
                criticalPathIds = this.finalCriticalPath(collection, taskBeyondEnddate, totalRecords, modelIds, checkEndDate);
                this.validatedids = [];
                this.criticalPathCollection = criticalPathIds;
                this.detailPredecessorCollection = collection;
                this.predecessorCollectionTaskIds = collectionTaskId;
            }
            if (isCritical === false && this.parent.flatData.length > 0) {
                var pathIndex = void 0;
                this.parent.enableCriticalPath = false;
                for (var z = 0; z < this.criticalPathCollection.length; z++) {
                    pathIndex = modelIds.indexOf(this.criticalPathCollection[z].toString());
                    totalRecords[pathIndex].isCritical = false;
                }
                this.criticalPathCollection = [];
                this.detailPredecessorCollection = [];
                this.predecessorCollectionTaskIds = [];
            }
        };
        CriticalPath.prototype.slackCalculation = function (fromDataObject, collection, collectionTaskId, checkEndDate, flatRecords, modelRecordIds) {
            var _this = this;
            var fromDateArray = fromDataObject[0]['fromdata'].split(',');
            var fromDataPredecessor = fromDataObject[0]['fromDataPredecessor'].split(',');
            collectionTaskId = collectionTaskId.toString();
            collectionTaskId = collectionTaskId.split(',');
            var fromDateArray1 = [];
            var fromTaskIdIndex;
            var indexFromTaskId;
            var indexToTaskId;
            var totaskId;
            var dateDifference;
            var prevTaskEnddate;
            var offsetInMillSec;
            var ffslack;
            for (var i = 0; i < fromDateArray.length; i++) {
                fromDateArray1 = fromDateArray[i].split(':');
                fromTaskIdIndex = collectionTaskId.indexOf((fromDateArray1[0].toString()));
                totaskId = collectionTaskId.indexOf((fromDataObject[0]['todateID'].toString()));
                if (this.parent.viewType === 'ProjectView') {
                    indexFromTaskId = modelRecordIds.indexOf(fromDateArray1[0].toString());
                    indexToTaskId = modelRecordIds.indexOf(fromDataObject[0]['todateID'].toString());
                }
                else {
                    indexFromTaskId = this.resourceCollectionIds.indexOf(fromDateArray1[0].toString());
                    indexToTaskId = this.resourceCollectionIds.indexOf(fromDataObject[0]['todateID'].toString());
                }
                var fromIdFlatData = void 0;
                Eif (indexFromTaskId !== -1) {
                    fromIdFlatData = flatRecords[indexFromTaskId].ganttProperties;
                }
                var toIdFlatData = flatRecords[indexToTaskId].ganttProperties;
                if (fromDateArray1.length > 1) {
                    if (fromDateArray1[1].indexOf('hour') !== -1) {
                        offsetInMillSec = parseFloat(fromDateArray1[1]) * 60;
                    }
                    else if (fromDateArray1[1].indexOf('day') !== -1) {
                        offsetInMillSec = parseFloat(fromDateArray1[1]) * (this.parent.secondsPerDay / 3600) * 60;
                    }
                    else {
                        offsetInMillSec = parseFloat(fromDateArray1[1]);
                    }
                }
                Eif (fromIdFlatData) {
                    if (fromDataPredecessor[i] === 'FS') {
                        if (fromIdFlatData.endDate > toIdFlatData.startDate) {
                            dateDifference = -(this.parent.dataOperation.getDuration(toIdFlatData.startDate, fromIdFlatData.endDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone));
                        }
                        else {
                            dateDifference = this.parent.dataOperation.getDuration(fromIdFlatData.endDate, toIdFlatData.startDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone);
                        }
                        if (ej2_base_1.isNullOrUndefined(collection[fromTaskIdIndex]['slack'])) {
                            if (fromDateArray1.length <= 1) {
                                if (collection[totaskId]['slack'] + dateDifference <= 0) {
                                    collection[fromTaskIdIndex]['slack'] = 0;
                                }
                                else {
                                    collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                }
                            }
                        }
                        else if (collection[fromTaskIdIndex]['slack'] > dateDifference &&
                            collection[fromTaskIdIndex]['slack'] !== 0) {
                            if (fromDateArray1.length <= 1) {
                                if (collection[totaskId]['slack'] + dateDifference <= 0) {
                                    collection[fromTaskIdIndex]['slack'] = 0;
                                }
                                else {
                                    collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                }
                            }
                        }
                        if (fromDateArray1.length > 1) {
                            collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                            collection[fromTaskIdIndex]['slack'] = collection[fromTaskIdIndex]['slack'] - (offsetInMillSec);
                            if (collection[fromTaskIdIndex]['slack'] <= 0) {
                                collection[fromTaskIdIndex]['slack'] = 0;
                            }
                        }
                        collection[fromTaskIdIndex]['fs'] = 1;
                        collection[fromTaskIdIndex]['fsslack'] = collection[fromTaskIdIndex]['slack'];
                        collection[fromTaskIdIndex]['enddate'] = fromIdFlatData.startDate;
                        if (fromIdFlatData.endDate >= checkEndDate) {
                            collection[fromTaskIdIndex]['slack'] = 0;
                        }
                    }
                    if (fromDataPredecessor[i] === 'SS') {
                        if (fromIdFlatData.isAutoSchedule) {
                            if (fromIdFlatData.startDate > toIdFlatData.startDate) {
                                dateDifference = -(this.parent.dataOperation.getDuration(toIdFlatData.endDate, fromIdFlatData.startDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone));
                            }
                            else {
                                dateDifference = this.parent.dataOperation.getDuration(fromIdFlatData.startDate, toIdFlatData.startDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone);
                            }
                            if (ej2_base_1.isNullOrUndefined(collection[fromTaskIdIndex]['slack'])) {
                                if (fromDateArray1.length <= 1) {
                                    if (collection[totaskId]['slack'] + dateDifference <= 0) {
                                        collection[fromTaskIdIndex]['slack'] = 0;
                                    }
                                    else {
                                        collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                    }
                                }
                            }
                            else if (collection[fromTaskIdIndex]['slack'] > dateDifference &&
                                collection[fromTaskIdIndex]['slack'] !== 0) {
                                Eif (fromDateArray1.length <= 1) {
                                    if (collection[totaskId]['slack'] + dateDifference <= 0) {
                                        collection[fromTaskIdIndex]['slack'] = 0;
                                    }
                                    else {
                                        collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                    }
                                }
                            }
                            if (fromDateArray1.length > 1) {
                                collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                collection[fromTaskIdIndex]['slack'] = collection[fromTaskIdIndex]['slack'] - (offsetInMillSec);
                                Iif (collection[fromTaskIdIndex]['slack'] <= 0) {
                                    collection[fromTaskIdIndex]['slack'] = 0;
                                }
                            }
                            collection[fromTaskIdIndex]['fs'] = 1;
                            collection[fromTaskIdIndex]['fsslack'] = collection[fromTaskIdIndex]['slack'];
                            collection[fromTaskIdIndex]['enddate'] = fromIdFlatData.startDate;
                        }
                        else Eif (!fromIdFlatData.isAutoSchedule) {
                            dateDifference = this.getSlackDuration(fromIdFlatData.endDate, checkEndDate, 'minute', flatRecords[indexFromTaskId]);
                            Eif (ej2_base_1.isNullOrUndefined(collection[fromTaskIdIndex]['slack'])) {
                                collection[fromTaskIdIndex]['slack'] = dateDifference;
                            }
                            else if (collection[fromTaskIdIndex]['slack'] > dateDifference &&
                                collection[fromTaskIdIndex]['slack'] !== 0) {
                                collection[fromTaskIdIndex]['slack'] = dateDifference;
                            }
                        }
                        if (fromIdFlatData.endDate >= checkEndDate && fromIdFlatData.endDate <= checkEndDate) {
                            collection[fromTaskIdIndex]['slack'] = 0;
                        }
                    }
                    if (fromDataPredecessor[i] === 'FF') {
                        Eif (collection[totaskId]['fs'] === 1 || collection[totaskId]['ff'] === 1 ||
                            collection[totaskId]['fs'] === -1) {
                            if (collection[totaskId]['fs'] === 1 || collection[totaskId]['ff'] === 1) {
                                prevTaskEnddate = toIdFlatData.endDate;
                                ffslack = collection[totaskId]['slack'];
                            }
                            if (collection[totaskId]['fs'] === -1) {
                                prevTaskEnddate = collection[totaskId]['enddate'];
                                ffslack = collection[totaskId]['slack'];
                            }
                            if (prevTaskEnddate > fromIdFlatData.endDate) {
                                dateDifference = -(this.getSlackDuration(fromIdFlatData.endDate, prevTaskEnddate, 'minute', flatRecords[indexFromTaskId]));
                            }
                            else {
                                dateDifference = this.getSlackDuration(prevTaskEnddate, fromIdFlatData.endDate, 'minute', flatRecords[indexFromTaskId]);
                            }
                            if (ej2_base_1.isNullOrUndefined(collection[fromTaskIdIndex]['slack'])) {
                                if (fromDateArray1.length <= 1) {
                                    Iif (ffslack - dateDifference < 0) {
                                        collection[fromTaskIdIndex]['slack'] = 0;
                                    }
                                    else {
                                        collection[fromTaskIdIndex]['slack'] = ffslack - dateDifference;
                                    }
                                }
                            }
                            else Eif (collection[fromTaskIdIndex]['slack'] > dateDifference && collection[fromTaskIdIndex]['slack'] !== 0) {
                                Iif (fromDateArray1.length <= 1) {
                                    if (ffslack - dateDifference < 0) {
                                        collection[fromTaskIdIndex]['slack'] = 0;
                                    }
                                    else {
                                        collection[fromTaskIdIndex]['slack'] = ffslack - dateDifference;
                                    }
                                }
                            }
                            if (fromDateArray1.length > 1) {
                                collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] - dateDifference;
                                collection[fromTaskIdIndex]['slack'] = collection[fromTaskIdIndex]['slack'] - (offsetInMillSec);
                                if (collection[fromTaskIdIndex]['slack'] <= 0) {
                                    collection[fromTaskIdIndex]['slack'] = 0;
                                }
                            }
                            collection[fromTaskIdIndex]['ff'] = 1;
                            collection[fromTaskIdIndex]['enddate'] = prevTaskEnddate;
                            collection[fromTaskIdIndex]['fsslack'] = ffslack;
                        }
                        if (fromIdFlatData.endDate >= checkEndDate && fromIdFlatData.endDate <= checkEndDate) {
                            collection[fromTaskIdIndex]['slack'] = 0;
                        }
                    }
                    if (fromDataPredecessor[i] === 'SF') {
                        if (fromIdFlatData.isAutoSchedule) {
                            if (ej2_base_1.isNullOrUndefined(collection[fromTaskIdIndex]['slack'])) {
                                if (fromDateArray1.length <= 1) {
                                    if (ej2_base_1.isNullOrUndefined(collection[totaskId]['to'])) {
                                        dateDifference = this.getSlackDuration(fromIdFlatData.endDate, checkEndDate, 'minute', flatRecords[indexFromTaskId]);
                                        collection[fromTaskIdIndex]['slack'] = dateDifference;
                                    }
                                    else Eif (!ej2_base_1.isNullOrUndefined(collection[totaskId]['to'])) {
                                        Iif (toIdFlatData.endDate > fromIdFlatData.startDate) {
                                            dateDifference = -(this.parent.dataOperation.getDuration(fromIdFlatData.startDate, toIdFlatData.endDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone));
                                        }
                                        else {
                                            dateDifference = this.getSlackDuration(toIdFlatData.endDate, fromIdFlatData.startDate, 'minute', flatRecords[indexFromTaskId]);
                                        }
                                        if (collection[totaskId]['slack'] + dateDifference <= 0) {
                                            collection[fromTaskIdIndex]['slack'] = 0;
                                        }
                                        else {
                                            collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                        }
                                    }
                                }
                                else Eif (fromDateArray1.length > 1) {
                                    if (toIdFlatData.endDate >= fromIdFlatData.endDate) {
                                        Iif (fromIdFlatData.startDate > toIdFlatData.endDate) {
                                            dateDifference = -(this.getSlackDuration(toIdFlatData.endDate, fromIdFlatData.startDate, 'minute', flatRecords[indexFromTaskId]));
                                        }
                                        else {
                                            dateDifference = this.parent.dataOperation.getDuration(fromIdFlatData.startDate, toIdFlatData.endDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone);
                                        }
                                    }
                                    else {
                                        dateDifference = this.getSlackDuration(fromIdFlatData.endDate, checkEndDate, 'minute', flatRecords[indexFromTaskId]);
                                    }
                                    collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                    collection[fromTaskIdIndex]['slack'] = collection[fromTaskIdIndex]['slack'] - (offsetInMillSec);
                                    if (collection[fromTaskIdIndex]['slack'] <= 0) {
                                        collection[fromTaskIdIndex]['slack'] = 0;
                                    }
                                }
                                collection[fromTaskIdIndex]['fs'] = 1;
                                collection[fromTaskIdIndex]['fsslack'] = collection[fromTaskIdIndex]['slack'];
                                collection[fromTaskIdIndex]['enddate'] = fromIdFlatData.startDate;
                            }
                            else {
                                if (fromDateArray1.length <= 1) {
                                    Iif (ej2_base_1.isNullOrUndefined(collection[totaskId]['to'])) {
                                        dateDifference = this.getSlackDuration(fromIdFlatData.endDate, checkEndDate, 'minute', flatRecords[indexFromTaskId]);
                                    }
                                    else Eif (!ej2_base_1.isNullOrUndefined(collection[totaskId]['to'])) {
                                        Iif (toIdFlatData.endDate > fromIdFlatData.startDate) {
                                            dateDifference = -(this.parent.dataOperation.getDuration(fromIdFlatData.startDate, toIdFlatData.endDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone));
                                        }
                                        else {
                                            dateDifference = this.getSlackDuration(toIdFlatData.endDate, fromIdFlatData.startDate, 'minute', flatRecords[indexFromTaskId]);
                                        }
                                    }
                                    if (collection[fromTaskIdIndex]['slack'] > dateDifference && collection[fromTaskIdIndex]['slack'] !== 0) {
                                        Iif (ej2_base_1.isNullOrUndefined(collection[totaskId]['to'])) {
                                            collection[fromTaskIdIndex]['slack'] = dateDifference;
                                        }
                                        else Eif (!ej2_base_1.isNullOrUndefined(collection[totaskId]['to'])) {
                                            if (collection[totaskId]['slack'] + dateDifference <= 0) {
                                                collection[fromTaskIdIndex]['slack'] = 0;
                                            }
                                            else {
                                                collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                            }
                                        }
                                    }
                                }
                                else Eif (fromDateArray1.length > 1) {
                                    if (toIdFlatData.endDate > fromIdFlatData.endDate) {
                                        Iif (fromIdFlatData.startDate > toIdFlatData.endDate) {
                                            dateDifference = -(this.getSlackDuration(toIdFlatData.endDate, fromIdFlatData.startDate, 'minute', flatRecords[indexFromTaskId]));
                                        }
                                        else {
                                            dateDifference = this.parent.dataOperation.getDuration(fromIdFlatData.startDate, toIdFlatData.endDate, 'minute', fromIdFlatData.isAutoSchedule, fromIdFlatData.isMilestone);
                                        }
                                    }
                                    else {
                                        dateDifference = this.getSlackDuration(fromIdFlatData.endDate, checkEndDate, 'minute', flatRecords[indexFromTaskId]);
                                    }
                                    if (collection[fromTaskIdIndex]['slack'] > dateDifference && collection[fromTaskIdIndex]['slack'] !== 0) {
                                        collection[fromTaskIdIndex]['slack'] = collection[totaskId]['slack'] + dateDifference;
                                        collection[fromTaskIdIndex]['slack'] = collection[fromTaskIdIndex]['slack'] - (offsetInMillSec);
                                        Iif (collection[fromTaskIdIndex]['slack'] <= 0) {
                                            collection[fromTaskIdIndex]['slack'] = 0;
                                        }
                                    }
                                }
                                collection[fromTaskIdIndex]['fs'] = 1;
                                collection[fromTaskIdIndex]['fsslack'] = collection[fromTaskIdIndex]['slack'];
                                collection[fromTaskIdIndex]['enddate'] = fromIdFlatData.startDate;
                            }
                        }
                        else Eif (!fromIdFlatData.isAutoSchedule) {
                            dateDifference = this.getSlackDuration(fromIdFlatData.endDate, checkEndDate, 'minute', flatRecords[indexFromTaskId]);
                            if (ej2_base_1.isNullOrUndefined(collection[fromTaskIdIndex]['slack'])) {
                                collection[fromTaskIdIndex]['slack'] = dateDifference;
                            }
                            else Iif (collection[fromTaskIdIndex]['slack'] > dateDifference && collection[fromTaskIdIndex]['slack'] !== 0) {
                                collection[fromTaskIdIndex]['slack'] = dateDifference;
                            }
                        }
                        if (fromIdFlatData.endDate >= checkEndDate && fromIdFlatData.endDate <= checkEndDate) {
                            collection[fromTaskIdIndex]['slack'] = 0;
                        }
                    }
                    if (collection[fromTaskIdIndex]['from']) {
                        fromDataObject.push({
                            fromdata: collection[fromTaskIdIndex]['from'], todateID: collection[fromTaskIdIndex]['taskid'],
                            fromDataPredecessor: collection[fromTaskIdIndex]['fromPredecessor']
                        });
                    }
                }
            }
            Eif (fromDataObject) {
                fromDataObject.splice(0, 1);
                if (fromDataObject.length > 0) {
                    fromDataObject.forEach(function (item) {
                        _this.slackCalculation([item], collection, collectionTaskId, checkEndDate, flatRecords, modelRecordIds);
                    });
                }
            }
        };
        CriticalPath.prototype.getSlackDuration = function (sDate, eDate, durationUnit, record) {
            var startDate = this.parent.dateValidationModule.checkStartDate(new Date(sDate));
            var endDate = this.parent.dateValidationModule.checkEndDate(new Date(eDate));
            if (this.parent.dataOperation['getTimeDifference'](startDate, endDate, true) <= 0) {
                return 0;
            }
            else {
                return this.parent.dataOperation.getDuration(startDate, endDate, durationUnit, record.ganttProperties.isAutoSchedule, true);
            }
        };
        CriticalPath.prototype.updateCriticalTasks = function (record, criticalPathIds) {
            for (var i = 0; i < record.ganttProperties.predecessor.length; i++) {
                var fromRecord = void 0;
                if (this.parent.viewType === 'ProjectView') {
                    fromRecord = this.parent.getRecordByID(record.ganttProperties.predecessor[i].from);
                }
                else {
                    var resourceIndex = this.resourceCollectionIds.indexOf(record.ganttProperties.predecessor[i].from.toString());
                    fromRecord = this.parent.flatData[resourceIndex];
                }
                var durationDiff = void 0;
                if (record.ganttProperties.endDate.getTime() >= this.maxEndDate.getTime()) {
                    record.ganttProperties.slack = record.slack = 0 + ' ' + record.ganttProperties.durationUnit;
                    Eif (record.ganttProperties.progress < 100) {
                        record.isCritical = true;
                        record.ganttProperties.isCritical = true;
                        if (criticalPathIds.indexOf(record.ganttProperties.taskId) === -1) {
                            criticalPathIds.push(record.ganttProperties.taskId);
                        }
                    }
                }
                Eif (fromRecord) {
                    if (record.ganttProperties.predecessor[i].type === 'FS') {
                        durationDiff = this.parent.dataOperation.getDuration(fromRecord.ganttProperties.endDate, record.ganttProperties.startDate, fromRecord.ganttProperties.durationUnit, fromRecord.ganttProperties.isAutoSchedule, true);
                    }
                    else if (record.ganttProperties.predecessor[i].type === 'SS') {
                        durationDiff = this.parent.dataOperation.getDuration(fromRecord.ganttProperties.startDate, record.ganttProperties.startDate, fromRecord.ganttProperties.durationUnit, fromRecord.ganttProperties.isAutoSchedule, true);
                    }
                    else if (record.ganttProperties.predecessor[i].type === 'FF') {
                        durationDiff = this.parent.dataOperation.getDuration(fromRecord.ganttProperties.endDate, record.ganttProperties.endDate, fromRecord.ganttProperties.durationUnit, fromRecord.ganttProperties.isAutoSchedule, true);
                    }
                    else Eif (record.ganttProperties.predecessor[i].type === 'SF') {
                        durationDiff = this.parent.dataOperation.getDuration(record.ganttProperties.endDate, fromRecord.ganttProperties.startDate, fromRecord.ganttProperties.durationUnit, fromRecord.ganttProperties.isAutoSchedule, true);
                    }
                    if (durationDiff >= 0 && this.validatedids.indexOf(parseInt(fromRecord.ganttProperties.taskId, 10)) === -1 &&
                        fromRecord.ganttProperties.taskId !== record.ganttProperties.taskId) {
                        fromRecord.ganttProperties.slack = record.ganttProperties.slack;
                        fromRecord.slack = record.slack;
                        fromRecord.isCritical = record.ganttProperties.isCritical;
                        fromRecord.ganttProperties.isCritical = record.ganttProperties.isCritical;
                        if (criticalPathIds.indexOf(fromRecord.ganttProperties.taskId) === -1 && fromRecord.ganttProperties.isCritical &&
                            fromRecord.ganttProperties.progress < 100) {
                            criticalPathIds.push(fromRecord.ganttProperties.taskId);
                            this.validatedids.push(parseInt(fromRecord.ganttProperties.taskId, 10));
                            Eif (this.criticalTasks.indexOf(fromRecord) === -1) {
                                this.criticalTasks.push(fromRecord);
                            }
                        }
                        if (fromRecord.ganttProperties.predecessorsName) {
                            this.updateCriticalTasks(fromRecord, criticalPathIds);
                        }
                    }
                }
            }
        };
        CriticalPath.prototype.finalCriticalPath = function (collection, taskBeyondEnddate, flatRecords, modelRecordIds, checkEndDate) {
            var criticalPathIds = [];
            var index;
            var predecessorFrom;
            for (var x = collection.length - 1; x >= 0; x--) {
                if (this.parent.viewType === 'ProjectView') {
                    index = modelRecordIds.indexOf(collection[x]['taskid'].toString());
                }
                else {
                    index = this.resourceCollectionIds.indexOf(collection[x]['taskid'].toString());
                }
                var predecessorLength = flatRecords[index].ganttProperties.predecessor;
                var noSlackValue = 0 + ' ' + flatRecords[index].ganttProperties.durationUnit;
                Eif (predecessorLength && predecessorLength.length > 0) {
                    for (var i = predecessorLength.length - 1; i >= 0; i--) {
                        var toID = void 0;
                        if (this.parent.viewType === 'ProjectView') {
                            toID = this.parent.ids.indexOf(predecessorLength[i].to);
                        }
                        else {
                            toID = this.resourceCollectionIds.indexOf(predecessorLength[i].to);
                        }
                        var dateDifference = void 0;
                        var currentData = flatRecords[index].ganttProperties;
                        Eif (toID !== -1) {
                            if (predecessorLength[i].type === 'FS') {
                                if (predecessorLength[i].to !== currentData.taskId.toString() || this.parent.viewType === 'ResourceView') {
                                    dateDifference = this.parent.dataOperation.getDuration(currentData.endDate, flatRecords[toID].ganttProperties.startDate, currentData.durationUnit, currentData.isAutoSchedule, currentData.isMilestone);
                                }
                                else {
                                    toID = this.parent.ids.indexOf(predecessorLength[i].from);
                                    Eif (toID !== -1) {
                                        dateDifference = this.parent.dataOperation.getDuration(flatRecords[toID].ganttProperties.endDate, currentData.startDate, currentData.durationUnit, currentData.isAutoSchedule, currentData.isMilestone);
                                        if (dateDifference === 0 && index !== toID && flatRecords[index].slack === noSlackValue) {
                                            flatRecords[toID].slack = flatRecords[index].slack;
                                            flatRecords[toID].ganttProperties.slack = flatRecords[index].slack;
                                        }
                                    }
                                }
                                Eif (toID !== -1) {
                                    if (dateDifference === 0 && index !== toID && flatRecords[index].slack !== noSlackValue) {
                                        flatRecords[index].slack = flatRecords[toID].slack;
                                        flatRecords[index].ganttProperties.slack = flatRecords[toID].slack;
                                    }
                                    else if (dateDifference !== 0 && index !== toID && flatRecords[toID].isCritical) {
                                        flatRecords[index].slack = dateDifference + ' ' + flatRecords[index].ganttProperties.durationUnit;
                                        flatRecords[index].ganttProperties.slack = dateDifference + ' ' + flatRecords[index].ganttProperties.durationUnit;
                                    }
                                }
                            }
                            else if (predecessorLength[i].type === 'SF') {
                                dateDifference = this.parent.dataOperation.getDuration(currentData.startDate, flatRecords[toID].ganttProperties.endDate, currentData.durationUnit, currentData.isAutoSchedule, currentData.isMilestone);
                            }
                            else if (predecessorLength[i].type === 'SS') {
                                dateDifference = this.parent.dataOperation.getDuration(currentData.startDate, flatRecords[toID].ganttProperties.startDate, currentData.durationUnit, currentData.isAutoSchedule, currentData.isMilestone);
                            }
                            else {
                                dateDifference = this.parent.dataOperation.getDuration(currentData.endDate, flatRecords[toID].ganttProperties.endDate, currentData.durationUnit, currentData.isAutoSchedule, currentData.isMilestone);
                            }
                            if (typeof (flatRecords[index][this.parent.taskFields.id]) === 'number') {
                                predecessorFrom = parseInt(predecessorLength[i].from, 10);
                            }
                            else {
                                predecessorFrom = predecessorLength[i].from;
                            }
                            if (predecessorFrom === flatRecords[index][this.parent.taskFields.id] &&
                                flatRecords[toID].slack === noSlackValue && dateDifference <= 0) {
                                flatRecords[index].slack = noSlackValue;
                                flatRecords[index].ganttProperties.slack = noSlackValue;
                            }
                        }
                    }
                }
                if (flatRecords[index].slack === noSlackValue) {
                    if (flatRecords[index].ganttProperties.progress < 100) {
                        flatRecords[index].isCritical = true;
                        flatRecords[index].ganttProperties.isCritical = true;
                        if (this.criticalTasks.indexOf(flatRecords[index]) === -1) {
                            this.criticalTasks.push(flatRecords[index]);
                        }
                        if (criticalPathIds.indexOf(collection[x]['taskid']) === -1) {
                            criticalPathIds.push(collection[x]['taskid']);
                        }
                    }
                }
                Eif (flatRecords[index].ganttProperties.predecessor &&
                    flatRecords[index].ganttProperties.predecessor.length > 0) {
                    this.updateCriticalTasks(flatRecords[index], criticalPathIds);
                }
            }
            if (taskBeyondEnddate.length > 0) {
                for (var i = 0; i < taskBeyondEnddate.length; i++) {
                    if (this.parent.viewType === 'ProjectView') {
                        index = modelRecordIds.indexOf(taskBeyondEnddate[i].toString());
                    }
                    else {
                        index = this.resourceCollectionIds.indexOf(taskBeyondEnddate[i].toString());
                    }
                    Eif (index !== -1 && flatRecords[index].ganttProperties.progress < 100) {
                        this.criticalTasks.push(flatRecords[index]);
                        Eif (criticalPathIds.indexOf(taskBeyondEnddate[i]) === -1) {
                            criticalPathIds = criticalPathIds.concat(taskBeyondEnddate[i]);
                        }
                    }
                }
            }
            return criticalPathIds;
        };
        CriticalPath.prototype.criticalConnectorLine = function (criticalPathIds, collection, condition, collectionTaskId) {
            this.parent.removeCriticalPathStyles();
            var _loop_2 = function (i) {
                var criticalData;
                if (this_2.parent.viewType === 'ProjectView') {
                    criticalData = this_2.parent.flatData[this_2.parent.ids.indexOf(criticalPathIds[i].toString())];
                }
                else {
                    var currentRecords = this_2.parent.flatData.filter(function (data) {
                        return (data.ganttProperties.taskId).toString() === criticalPathIds[i].toString();
                    });
                    for (var i_1 = 0; i_1 < currentRecords.length; i_1++) {
                        if (currentRecords[i_1].ganttProperties.isCritical ||
                            currentRecords[i_1].ganttProperties.endDate >= this_2.maxEndDate) {
                            criticalData = currentRecords[i_1];
                        }
                    }
                }
                var index = this_2.parent.currentViewData.indexOf(criticalData);
                var element = this_2.parent.getRowByIndex(index);
                var taskClass = void 0;
                var columnFields = this_2.parent.taskFields;
                if (criticalData && criticalData.parentItem) {
                    var parentRecord = this_2.parent.currentViewData.filter(function (data) {
                        return criticalData.parentItem.uniqueID === data.uniqueID;
                    });
                    var parentIndex = this_2.parent.flatData.indexOf(parentRecord[0]);
                    var parentElement = this_2.parent.getRowByIndex(parentIndex);
                    if (parentElement) {
                        var parentTaskbarElement = parentElement.querySelectorAll('.e-taskbar-main-container');
                        for (var i_2 = 0; i_2 < parentTaskbarElement.length; i_2++) {
                            if (parentTaskbarElement[i_2].getAttribute('rowuniqueid') === criticalData['rowUniqueID']) {
                                ej2_base_2.addClass(parentTaskbarElement[i_2].querySelectorAll('.e-gantt-child-taskbar-inner-div'), cls.criticalChildTaskBarInnerDiv);
                            }
                        }
                    }
                }
                if (this_2.parent.allowUnscheduledTasks && criticalData && !criticalData[columnFields.startDate] && !criticalData[columnFields.endDate] && criticalData[columnFields.duration]) {
                    taskClass = cls.criticalUnscheduledTask;
                }
                else {
                    taskClass = cls.criticalChildProgressBarInnerDiv;
                }
                if (element && (this_2.parent.viewType === 'ProjectView' || (this_2.parent.viewType === 'ResourceView' &&
                    !criticalData.hasChildRecords))) {
                    if (element.getElementsByClassName('e-gantt-milestone')[0]) {
                        ej2_base_2.addClass(element.querySelectorAll('.e-gantt-milestone'), cls.criticalMilestone);
                    }
                    if (element.getElementsByClassName('e-gantt-child-taskbar-inner-div').length > 0) {
                        ej2_base_2.addClass(element.querySelectorAll('.e-gantt-child-taskbar-inner-div'), cls.criticalChildTaskBarInnerDiv);
                    }
                    if (element.getElementsByClassName('e-gantt-child-progressbar-inner-div').length > 0) {
                        ej2_base_2.addClass(element.querySelectorAll('.e-gantt-child-progressbar-inner-div'), taskClass);
                    }
                }
            };
            var this_2 = this;
            for (var i = 0; i < criticalPathIds.length; i++) {
                _loop_2(i);
            }
            if (collection.length !== 0) {
                var index = 0;
                var currentdata = void 0;
                var checking = [];
                var checkint = void 0;
                var values = void 0;
                for (var i = 0; i < this.criticalPathCollection.length; i++) {
                    index = collectionTaskId.indexOf(this.criticalPathCollection[i]);
                    currentdata = collection[index];
                    if (index !== -1 && currentdata['to']) {
                        checking = currentdata['to'].split(',');
                        for (var j = 0; j < checking.length; j++) {
                            values = checking[j].split('+');
                            if (checking[j].indexOf('-') >= 0) {
                                values = checking[j].split('-');
                            }
                            checkint = (values[0].replace(':', ''));
                            if (typeof (criticalPathIds[j]) === 'number') {
                                checkint = parseInt(values[0], 10);
                            }
                            if (criticalPathIds.indexOf(checkint) !== -1) {
                                var taskIdString = String(currentdata['taskid']);
                                var checkintString = String(checkint);
                                var lineElement = this.parent.element.querySelectorAll('#ConnectorLineparent' +
                                    taskIdString.replace(/([.])/g, '\\$1') + 'child' + checkintString.replace(/([.])/g, '\\$1'));
                                if (lineElement.length > 0) {
                                    ej2_base_2.addClass(this.parent.element.querySelectorAll('#ConnectorLineparent' + taskIdString.replace(/([.])/g, '\\$1') + 'child' +
                                        checkintString.replace(/([.])/g, '\\$1'))[0].querySelectorAll('.e-connector-line'), cls.criticalConnectorLineSVG);
                                    ej2_base_2.addClass(this.parent.element.querySelectorAll('#ConnectorLineparent' + taskIdString.replace(/([.])/g, '\\$1') + 'child' +
                                        checkintString.replace(/([.])/g, '\\$1'))[0].querySelectorAll('.e-connector-line-arrow'), cls.criticalConnectorArrowSVG);
                                }
                            }
                        }
                    }
                }
            }
        };
        CriticalPath.prototype.getModuleName = function () {
            return 'criticalPath';
        };
        CriticalPath.prototype.destroy = function () {
            if (!this.parent.enableCriticalPath && this.parent.criticalPathModule) {
                this.parent.criticalPathModule = undefined;
            }
        };
        return CriticalPath;
    }());
    exports.CriticalPath = CriticalPath;
});