all files / actions/ connector-line-edit.js

93.55% Statements 667/713
85.13% Branches 435/511
91.04% Functions 61/67
93.64% Lines 663/708
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 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099                       713× 713× 713× 713× 713× 713× 713× 713× 713× 713×   143× 143×     145× 145× 145× 145× 145×     143×                         268× 268× 268× 268× 268× 268× 268× 268× 268× 268× 3252× 3252× 3252× 2788× 4063× 4063× 4063× 4063× 4063× 4063× 4063×     4063×   4063× 1033× 1033× 1033× 471×     562× 562×         2788×     268×   268× 268×   268× 268×     77× 77× 77× 77× 77× 88× 88× 88× 88× 88× 88× 88× 88× 88×   88×     88×                 88×                     83×       83× 83×       88× 88× 88× 79×         72×     71×             88×   77×   20× 20× 12×     12× 12× 12× 22×       12×     12× 12× 12×                 20× 20×   20×       1136× 1136× 1136× 594977×   1136× 519×   1136×       9667× 9666× 751×     748× 1366× 1363× 1363×           8915× 896× 816×     80× 101× 93× 93×           8019× 215× 103× 102×       112×       111× 100× 100× 100×           8640×   91× 91×   91× 91× 91× 77× 77× 84×         83× 62× 62× 62× 59×       84× 84× 84× 84× 104× 103×         84×   83× 83× 83× 83× 83× 125× 125× 125× 125× 93×   88× 88× 51× 95× 36× 36×       88×   21×   67× 67× 42× 42×   38× 10×   42×         25×       32×     83× 125× 125× 26× 99× 57×     77× 77× 84× 84× 27×     64×           64×   72× 59× 59× 59× 46×   59× 59× 59× 59× 59× 59× 59×   59× 59× 59×     13×   13× 13× 13×                         713× 709×     709× 709×     709×                                           709× 709× 709× 709×                           43× 43× 43×       43×   41× 41× 41× 37× 37× 33× 45×         41× 41×           41× 41×                                           234× 234× 39×     159×   600× 600×     592× 576× 576× 576× 267× 267× 339× 339× 339× 16× 17×   16×       339× 339×   337× 337× 337× 337× 337×   274×   274× 274×   23×   23× 23×   16×   16× 16×   24×   24× 24×   337× 191× 191× 191×     146× 146× 146× 146×   337× 145× 145×     192×         339× 339× 339×   339× 339× 339× 339×   339×   267× 267× 339×       309× 309× 200× 160× 163× 146×           576× 309×   576× 49×   21× 39× 30× 30× 21×       527×   576× 576× 576× 576× 576× 576×   576× 67× 193×     49×       509× 454× 454×   12×                                                           61× 61× 61× 61× 61× 61× 61× 61×     55×   61×     61× 63× 63× 63× 38× 28× 13× 13×   15× 14× 14×       25×                               20× 12× 10×                 63× 44× 44×     61×         61×   51× 51× 51× 51× 51× 36× 48× 48× 21× 26×   21× 21×   19×   19×               27× 27× 27× 19× 19×       36× 36× 48×     51× 51× 47× 47× 47× 27×   47× 46× 46×     51× 51× 47×                                                                      
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/css-constants", "../base/utils", "@syncfusion/ej2-popups"], function (require, exports, ej2_base_1, ej2_base_2, cls, utils_1, ej2_popups_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ConnectorLineEdit = (function () {
        function ConnectorLineEdit(ganttObj) {
            this.validationPredecessor = null;
            this.confirmPredecessorDialog = null;
            this.predecessorIndex = null;
            this.childRecord = null;
            this.validatedId = [];
            this.validatedOffsetIds = [];
            this.isPublicDependencyDelete = false;
            this.parent = ganttObj;
            this.dateValidateModule = this.parent.dateValidationModule;
            this.parent.on('initPredessorDialog', this.initPredecessorValidationDialog, this);
        }
        ConnectorLineEdit.prototype.updateConnectorLineEditElement = function (e) {
            var element = this.getConnectorLineHoverElement(e.target);
            if (!ej2_base_2.getValue('editModule.taskbarEditModule.taskBarEditAction', this.parent)) {
                this.highlightConnectorLineElements(element);
            }
        };
        ConnectorLineEdit.prototype.getConnectorLineHoverElement = function (target) {
            var isOnLine = utils_1.parentsUntil(target, cls.connectorLineSVG);
            var isArrow = utils_1.parentsUntil(target, cls.connectorLineArrow);
            var isCriticalLine = utils_1.parentsUntil(target, cls.criticalConnectorLineSVG);
            var isCriticalArrow = utils_1.parentsUntil(target, cls.criticalConnectorArrowSVG);
            if (isOnLine || isArrow || isCriticalLine || isCriticalArrow) {
                return utils_1.parentsUntil(target, cls.connectorLineContainer);
            }
            else {
                return null;
            }
        };
        ConnectorLineEdit.prototype.highlightConnectorLineElements = function (element) {
            if (element) {
                Eif (element !== this.connectorLineElement) {
                    this.removeHighlight();
                    this.addHighlight(element);
                }
            }
            else {
                this.removeHighlight();
            }
        };
        ConnectorLineEdit.prototype.addHighlight = function (element) {
            this.connectorLineElement = element;
            var pathElement = element.querySelector('.' + cls.connectorLineSVG);
            Eif (pathElement) {
                pathElement.setAttribute('stroke-width', (this.parent.connectorLineModule['lineStroke'] + 1).toString());
            }
        };
        ConnectorLineEdit.prototype.removeHighlight = function () {
            if (this.connectorLineElement) {
                var pathElement = this.connectorLineElement.querySelector('.' + cls.connectorLineSVG);
                Eif (pathElement) {
                    pathElement.setAttribute('stroke-width', (this.parent.connectorLineModule['lineStroke']).toString());
                }
                this.connectorLineElement = null;
            }
        };
        ConnectorLineEdit.prototype.getEditedConnectorLineString = function (records) {
            var ganttRecord;
            var predecessorsCollection;
            var predecessor;
            var parentGanttRecord;
            var childGanttRecord;
            var connectorObj;
            var idArray = [];
            var lineArray = [];
            var editedConnectorLineString = '';
            for (var count = 0; count < records.length; count++) {
                ganttRecord = records[count];
                predecessorsCollection = ganttRecord.ganttProperties.predecessor;
                if (predecessorsCollection) {
                    for (var predecessorCount = 0; predecessorCount < predecessorsCollection.length; predecessorCount++) {
                        predecessor = predecessorsCollection[predecessorCount];
                        var from = 'from';
                        var to = 'to';
                        this.parent.connectorLineModule.removeConnectorLineById('parent' + predecessor[from] + 'child' + predecessor[to]);
                        parentGanttRecord = this.parent.connectorLineModule.getRecordByID(predecessor["" + from]);
                        childGanttRecord = this.parent.connectorLineModule.getRecordByID(predecessor["" + to]);
                        Eif ((!this.parent.allowParentDependency && (parentGanttRecord && parentGanttRecord.expanded === true) ||
                            (childGanttRecord && childGanttRecord.expanded === true)) || (this.parent.allowParentDependency &&
                            (parentGanttRecord || childGanttRecord))) {
                            connectorObj =
                                this.parent.predecessorModule.updateConnectorLineObject(parentGanttRecord, childGanttRecord, predecessor);
                            if (!ej2_base_1.isNullOrUndefined(connectorObj)) {
                                var lineIndex = idArray.indexOf(connectorObj.connectorLineId);
                                var lineString = this.parent.connectorLineModule.getConnectorLineTemplate(connectorObj);
                                if (lineIndex !== -1) {
                                    lineArray[lineIndex] = lineString;
                                }
                                else {
                                    idArray.push(connectorObj.connectorLineId);
                                    lineArray.push(lineString);
                                }
                            }
                        }
                    }
                    editedConnectorLineString = lineArray.join('');
                }
            }
            return editedConnectorLineString;
        };
        ConnectorLineEdit.prototype.refreshEditedRecordConnectorLine = function (editedRecord) {
            this.parent.connectorLineModule.removePreviousConnectorLines(this.parent.previousRecords);
            this.parent.connectorLineModule.expandedRecords = this.parent.virtualScrollModule && this.parent.enableVirtualization ?
                this.parent.updatedRecords : this.parent.getExpandedRecords(this.parent.updatedRecords);
            var editedConnectorLineString = this.getEditedConnectorLineString(editedRecord);
            this.parent.connectorLineModule.svgObject.innerHTML =
                this.parent.connectorLineModule.svgObject.innerHTML + editedConnectorLineString;
        };
        ConnectorLineEdit.prototype.idFromPredecessor = function (pre) {
            var preArray = pre.split(',');
            var preIdArray = [];
            var values = [];
            var match = [];
            for (var j = 0; j < preArray.length; j++) {
                var strArray = [];
                var firstPart = void 0;
                var isAlpha = false;
                var predecessorName = void 0;
                var isGUId = false;
                var regex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
                var elSplit = preArray[j].split('-');
                var id = void 0;
                if (elSplit.length === 6) {
                    elSplit[4] = elSplit[4] + '-' + elSplit[5];
                    elSplit.pop();
                }
                if (elSplit.length === 5 && elSplit[4].length >= 12) {
                    id = preArray[j].substring(0, 36);
                    Eif (regex.test(id)) {
                        isGUId = true;
                    }
                }
                if (preArray[j].includes('-')) {
                    if (preArray[j].includes('-') && preArray[j].includes('days')) {
                        predecessorName = preArray[j].slice(-9).toString();
                    }
                    if (preArray[j].includes('-') && preArray[j].includes('day')) {
                        predecessorName = preArray[j].slice(-8).toString();
                    }
                    else {
                        predecessorName = preArray[j].slice(-2).toString();
                    }
                    if (preArray[j].includes('-') && /[A-Za-z]/.test(predecessorName)) {
                        var indexFS = preArray[j].indexOf(predecessorName);
                        Eif (indexFS !== -1) {
                            firstPart = preArray[j].substring(0, indexFS);
                            Eif (firstPart.includes('-')) {
                                isAlpha = true;
                            }
                        }
                    }
                }
                if (isGUId) {
                    var split = void 0;
                    split = elSplit[4].split('+');
                    var spliceLength = void 0;
                    if (split.length === 1) {
                        values[0] = preArray[j];
                    }
                    else {
                        spliceLength = split[1].length;
                        values[0] = preArray[j].slice(0, -(spliceLength + 1));
                        values[1] = split[1];
                    }
                    if (elSplit[4].indexOf('-') >= 0) {
                        split = elSplit[4].split('-');
                        Iif (split.length === 1) {
                            values[0] = preArray[j];
                        }
                        else {
                            spliceLength = split[1].length;
                            values[0] = preArray[j].slice(0, -(spliceLength + 1));
                            values[1] = split[1];
                        }
                    }
                }
                else {
                    Iif (isAlpha && firstPart.includes('-')) {
                        values[0] = firstPart;
                    }
                    else {
                        values = preArray[j].split('+');
                        if (preArray[j].indexOf('-') >= 0) {
                            values = preArray[j].split('-');
                        }
                    }
                }
                Eif (!ej2_base_1.isNullOrUndefined(values[0])) {
                    var ids = this.parent.viewType === 'ResourceView' ? this.parent.getTaskIds() : this.parent.ids;
                    if (ids.indexOf(values[0]) === -1) {
                        if (values[0].indexOf(' ') !== -1) {
                            match = values[0].split(' ');
                            Iif (match.length === 1) {
                                match = values[0].match(/(\d+|[A-z]+)/g);
                            }
                            strArray.push(match[0]);
                        }
                        else {
                            if (values[0].length === 1 || values[0].length === 2) {
                                strArray.push(values[0]);
                            }
                            else {
                                strArray.push(values[0].slice(0, -2));
                            }
                        }
                    }
                    else {
                        strArray.push(values[0]);
                    }
                }
                preIdArray.push((strArray.join('')));
            }
            return preIdArray;
        };
        ConnectorLineEdit.prototype.predecessorValidation = function (predecessor, record) {
            var recordId = record.rowUniqueID;
            var currentId;
            var currentRecord;
            for (var count = 0; count < predecessor.length; count++) {
                currentId = predecessor[count];
                var visitedIdArray = [];
                var predecessorCollection = predecessor.slice(0);
                predecessorCollection.splice(count, 1);
                var _loop_1 = function () {
                    var currentIdArray = [];
                    if (visitedIdArray.indexOf(currentId) === -1) {
                        Iif (ej2_base_1.isNullOrUndefined(this_1.parent.connectorLineModule.getRecordByID(currentId))) {
                            return { value: false };
                        }
                        currentRecord = this_1.parent.connectorLineModule.getRecordByID(currentId).ganttProperties;
                        Eif (!ej2_base_1.isNullOrUndefined(currentRecord.predecessor) && currentRecord.predecessor.length > 0) {
                            currentRecord.predecessor.forEach(function (value) {
                                if (currentRecord.rowUniqueID.toString() !== value.from) {
                                    currentIdArray.push(value.from.toString());
                                }
                            });
                        }
                        Iif (recordId.toString() === currentRecord.rowUniqueID.toString() || currentIdArray.indexOf(recordId.toString()) !== -1) {
                            return { value: false };
                        }
                        visitedIdArray.push(currentId);
                        Eif (!ej2_base_1.isNullOrUndefined(currentRecord.predecessor) && currentRecord.predecessor.length > 0) {
                            currentId = currentRecord.predecessor[0].from;
                        }
                        else {
                            return "break";
                        }
                    }
                    else {
                        return "break";
                    }
                };
                var this_1 = this;
                while (currentId !== null) {
                    var state_1 = _loop_1();
                    Iif (typeof state_1 === "object")
                        return state_1.value;
                    if (state_1 === "break")
                        break;
                }
            }
            return true;
        };
        ConnectorLineEdit.prototype.getRootParent = function (rec) {
            var parentRec = rec;
            Eif (rec.parentItem) {
                parentRec = this.parent.flatData.filter(function (item) {
                    return item.uniqueID === rec.parentUniqueID;
                })[0];
                if (parentRec.parentItem) {
                    parentRec = this.getRootParent(parentRec);
                }
                return parentRec;
            }
            return parentRec;
        };
        ConnectorLineEdit.prototype.validateParentPredecessor = function (fromRecord, toRecord) {
            if (fromRecord && toRecord) {
                if (toRecord.hasChildRecords && !fromRecord.hasChildRecords) {
                    if (fromRecord.parentUniqueID === toRecord.uniqueID) {
                        return false;
                    }
                    else {
                        do {
                            if (fromRecord.parentItem) {
                                fromRecord = this.parent.flatData[this.parent.ids.indexOf(fromRecord.parentItem.taskId)];
                                if (fromRecord.uniqueID === toRecord.uniqueID) {
                                    return false;
                                }
                            }
                        } while (fromRecord.parentItem);
                    }
                }
                else if (!toRecord.hasChildRecords && fromRecord.hasChildRecords) {
                    if (toRecord.parentUniqueID === fromRecord.uniqueID) {
                        return false;
                    }
                    else {
                        do {
                            if (toRecord.parentItem) {
                                toRecord = this.parent.flatData[this.parent.ids.indexOf(toRecord.parentItem.taskId)];
                                if (toRecord.uniqueID === fromRecord.uniqueID) {
                                    return false;
                                }
                            }
                        } while (toRecord.parentItem);
                    }
                }
                else if (toRecord.hasChildRecords && fromRecord.hasChildRecords) {
                    if (toRecord.parentItem && fromRecord.parentItem) {
                        if (fromRecord.parentUniqueID === toRecord.uniqueID || fromRecord.uniqueID === toRecord.parentUniqueID) {
                            return false;
                        }
                    }
                    else {
                        if (!toRecord.parentItem && fromRecord.parentItem) {
                            var fromRootParent = this.parent.connectorLineEditModule.getRootParent(fromRecord);
                            Iif (fromRootParent.uniqueID === toRecord.uniqueID) {
                                return false;
                            }
                        }
                        else if (toRecord.parentItem && !fromRecord.parentItem) {
                            var toRootParent = this.parent.connectorLineEditModule.getRootParent(toRecord);
                            Eif (toRootParent.uniqueID === fromRecord.uniqueID) {
                                return false;
                            }
                        }
                    }
                }
            }
            return true;
        };
        ConnectorLineEdit.prototype.validatePredecessorRelation = function (ganttRecord, predecessorString) {
            var flag = true;
            var recordId = this.parent.viewType === 'ResourceView' ? ganttRecord.ganttProperties.taskId
                : ganttRecord.ganttProperties.rowUniqueID;
            var predecessorIdArray;
            var currentId;
            if (!ej2_base_1.isNullOrUndefined(predecessorString) && predecessorString.length > 0) {
                predecessorIdArray = this.idFromPredecessor(predecessorString);
                var _loop_2 = function (count) {
                    if (!this_2.parent.allowParentDependency) {
                        var checkParent = this_2.checkParentRelation(ganttRecord, predecessorIdArray);
                        Iif (!checkParent) {
                            return { value: false };
                        }
                    }
                    else {
                        if (parseInt(predecessorIdArray[predecessorIdArray.length - 1], 10) !== ganttRecord[this_2.parent.taskFields.id]) {
                            var num = this_2.parent.ids.indexOf(predecessorIdArray[predecessorIdArray.length - 1]);
                            var fromRecord = this_2.parent.currentViewData[num];
                            if (fromRecord && ganttRecord) {
                                flag = this_2.validateParentPredecessor(fromRecord, ganttRecord);
                            }
                        }
                    }
                    var tempIdArray = predecessorIdArray.slice(0);
                    var checkArray = [];
                    var countFlag = true;
                    tempIdArray.forEach(function (value) {
                        if (checkArray.indexOf(value) === -1) {
                            checkArray.push(value);
                        }
                        else {
                            countFlag = false;
                        }
                    });
                    if (!countFlag) {
                        return { value: false };
                    }
                    currentId = predecessorIdArray[count];
                    var visitedIdArray = [];
                    var predecessorCollection = predecessorIdArray.slice(0);
                    predecessorCollection.splice(count, 1);
                    var _loop_3 = function () {
                        var currentIdArray = [];
                        var currentIdIndex;
                        var currentRecord;
                        if (visitedIdArray.indexOf(currentId) === -1) {
                            if (ej2_base_1.isNullOrUndefined(this_2.parent.connectorLineModule.getRecordByID(currentId.toString()))) {
                                return { value: false };
                            }
                            currentRecord = this_2.parent.connectorLineModule.getRecordByID(currentId.toString()).ganttProperties;
                            if (!ej2_base_1.isNullOrUndefined(currentRecord.predecessor) && currentRecord.predecessor.length > 0) {
                                currentRecord.predecessor.forEach(function (value, index) {
                                    if (currentRecord.rowUniqueID.toString() !== value.from) {
                                        currentIdArray.push(value.from.toString());
                                        currentIdIndex = index;
                                    }
                                });
                            }
                            if (recordId.toString() === currentRecord.rowUniqueID.toString() ||
                                currentIdArray.indexOf(recordId.toString()) !== -1) {
                                return { value: false };
                            }
                            visitedIdArray.push(currentId);
                            if (!ej2_base_1.isNullOrUndefined(currentRecord.predecessor) && currentRecord.predecessor.length > 0) {
                                var result = void 0;
                                if (currentIdArray.length > 1) {
                                    result = this_2.predecessorValidation(currentIdArray, ganttRecord.ganttProperties);
                                }
                                else if (currentIdArray.length === 1) {
                                    currentId = currentRecord.predecessor[currentIdIndex].from;
                                }
                                Iif (result === false) {
                                    return { value: false };
                                }
                            }
                            else {
                                return "break";
                            }
                        }
                        else {
                            return "break";
                        }
                    };
                    while (currentId !== null) {
                        var state_3 = _loop_3();
                        if (typeof state_3 === "object")
                            return state_3;
                        if (state_3 === "break")
                            break;
                    }
                };
                var this_2 = this;
                for (var count = 0; count < predecessorIdArray.length; count++) {
                    var state_2 = _loop_2(count);
                    if (typeof state_2 === "object")
                        return state_2.value;
                }
            }
            return flag;
        };
        ConnectorLineEdit.prototype.addPredecessor = function (ganttRecord, predecessorString) {
            var tempPredecessorString = ej2_base_1.isNullOrUndefined(ganttRecord.ganttProperties.predecessorsName) ||
                ganttRecord.ganttProperties.predecessorsName === '' ?
                predecessorString : (ganttRecord.ganttProperties.predecessorsName + ',' + predecessorString);
            this.updatePredecessorHelper(ganttRecord, tempPredecessorString);
        };
        ConnectorLineEdit.prototype.removePredecessor = function (ganttRecord) {
            this.isPublicDependencyDelete = true;
            this.updatePredecessorHelper(ganttRecord, null);
        };
        ConnectorLineEdit.prototype.updatePredecessor = function (ganttRecord, predecessorString, editedArgs) {
            return this.updatePredecessorHelper(ganttRecord, predecessorString, editedArgs);
        };
        ConnectorLineEdit.prototype.updatePredecessorHelper = function (ganttRecord, predecessorString, editedArgs) {
            if (ej2_base_1.isUndefined(predecessorString) || this.validatePredecessorRelation(ganttRecord, predecessorString)) {
                this.parent.isOnEdit = true;
                var predecessorCollection = [];
                if (!ej2_base_1.isNullOrUndefined(predecessorString) && predecessorString !== '') {
                    predecessorCollection = this.parent.predecessorModule.calculatePredecessor(predecessorString, ganttRecord);
                }
                this.parent.setRecordValue('predecessor', predecessorCollection, ganttRecord.ganttProperties, true);
                var stringValue = this.parent.predecessorModule.getPredecessorStringValue(ganttRecord);
                this.parent.setRecordValue('predecessorsName', stringValue, ganttRecord.ganttProperties, true);
                this.parent.setRecordValue('taskData.' + this.parent.taskFields.dependency, stringValue, ganttRecord);
                this.parent.setRecordValue(this.parent.taskFields.dependency, stringValue, ganttRecord);
                var args = {};
                args.action = editedArgs && editedArgs.action && editedArgs.action === 'CellEditing' ? editedArgs.action : ((this.parent.contextMenuModule && this.parent.contextMenuModule['isCntxtMenuDependencyDelete']) ||
                    this.isPublicDependencyDelete) ? 'DeleteConnectorLine' : 'DrawConnectorLine';
                args.data = ganttRecord;
                this.parent.editModule.initiateUpdateAction(args);
                return true;
            }
            else {
                if (ganttRecord.taskData[this.parent.taskFields.dependency]) {
                    ganttRecord.taskData[this.parent.taskFields.dependency] = null;
                }
                var err = predecessorString + " is an invalid relation for task " + this.parent.taskFields.id + ". Kindly ensure the " + this.parent.taskFields.dependency + " field contains only valid predecessor relations.";
                this.parent.trigger('actionFailure', { error: err });
                return false;
            }
        };
        ConnectorLineEdit.prototype.checkParentRelation = function (ganttRecord, predecessorIdArray) {
            var editingData = ganttRecord;
            var checkParent = true;
            Eif (editingData && editingData.parentItem) {
                Iif (predecessorIdArray.indexOf(editingData.parentItem.taskId.toString()) !== -1) {
                    return false;
                }
            }
            var _loop_4 = function (p) {
                var record = this_3.parent.currentViewData.filter(function (item) {
                    return item && item.ganttProperties.rowUniqueID.toString() === predecessorIdArray[p].toString();
                });
                Iif (record[0] && record[0].hasChildRecords) {
                    return { value: false };
                }
            };
            var this_3 = this;
            for (var p = 0; p < predecessorIdArray.length; p++) {
                var state_4 = _loop_4(p);
                Iif (typeof state_4 === "object")
                    return state_4.value;
            }
            return checkParent;
        };
        ConnectorLineEdit.prototype.initPredecessorValidationDialog = function () {
            if (this.parent.taskFields.dependency && this.parent.isInPredecessorValidation) {
                var dialogElement = ej2_base_2.createElement('div', {
                    id: this.parent.element.id + '_dialogValidationRule'
                });
                this.parent.element.appendChild(dialogElement);
                this.renderValidationDialog();
            }
        };
        ConnectorLineEdit.prototype.renderValidationDialog = function () {
            var validationDialog = new ej2_popups_1.Dialog({
                header: 'Validate Editing',
                isModal: true,
                enableRtl: this.parent.enableRtl,
                visible: false,
                width: '50%',
                showCloseIcon: true,
                close: this.validationDialogClose.bind(this),
                content: '',
                buttons: [
                    {
                        click: this.validationDialogOkButton.bind(this),
                        buttonModel: { content: this.parent.localeObj.getConstant('okText'), isPrimary: true }
                    },
                    {
                        click: this.validationDialogCancelButton.bind(this),
                        buttonModel: { content: this.parent.localeObj.getConstant('cancel') }
                    }
                ],
                target: this.parent.element,
                animationSettings: { effect: 'None' }
            });
            document.getElementById(this.parent.element.id + '_dialogValidationRule').innerHTML = '';
            validationDialog.isStringTemplate = true;
            validationDialog.appendTo('#' + this.parent.element.id + '_dialogValidationRule');
            this.parent.validationDialogElement = validationDialog;
        };
        ConnectorLineEdit.prototype.validationDialogOkButton = function () {
            var currentArgs = this.parent.currentEditedArgs;
            currentArgs.validateMode.preserveLinkWithEditing =
                document.getElementById(this.parent.element.id + '_ValidationAddlineOffset').checked;
            currentArgs.validateMode.removeLink =
                document.getElementById(this.parent.element.id + '_ValidationRemoveline').checked;
            currentArgs.validateMode.respectLink =
                document.getElementById(this.parent.element.id + '_ValidationCancel').checked;
            this.applyPredecessorOption();
            this.parent.validationDialogElement.hide();
        };
        ConnectorLineEdit.prototype.validationDialogCancelButton = function () {
            this.parent.currentEditedArgs.validateMode.respectLink = true;
            this.applyPredecessorOption();
            this.parent.validationDialogElement.hide();
        };
        ConnectorLineEdit.prototype.validationDialogClose = function (e) {
            Iif (ej2_base_2.getValue('isInteraction', e)) {
                this.parent.currentEditedArgs.validateMode.respectLink = true;
                this.applyPredecessorOption();
            }
        };
        ConnectorLineEdit.prototype.applyPredecessorOption = function () {
            var args = this.parent.currentEditedArgs;
            var ganttRecord = args.data;
            Iif (args.validateMode.respectLink) {
                this.parent.editModule.reUpdatePreviousRecords();
                this.parent.chartRowsModule.refreshRecords([args.data]);
            }
            else if (args.validateMode.removeLink) {
                this.checkChildRecords(ganttRecord);
                this.parent.editModule.updateEditedTask(args.editEventArgs);
            }
            else Eif (args.validateMode.preserveLinkWithEditing) {
                var connectedTaskId_1;
                if (this.parent.updateOffsetOnTaskbarEdit) {
                    var taskId_1 = ganttRecord.ganttProperties.taskId;
                    if (ganttRecord.ganttProperties.predecessor) {
                        ganttRecord.ganttProperties.predecessor.forEach(function (predecessor) {
                            if (taskId_1 === predecessor.from) {
                                connectedTaskId_1 = predecessor.to;
                                return;
                            }
                        });
                    }
                }
                this.parent.editModule.updateEditedTask(args.editEventArgs);
                this.processPredecessors(connectedTaskId_1);
            }
        };
        ConnectorLineEdit.prototype.compareArrays = function (arr1, arr2) {
            Iif (arr1.length !== arr2.length) {
                return false;
            }
            var str1 = JSON.stringify(arr1);
            var str2 = JSON.stringify(arr2);
            return str1 === str2;
        };
        ConnectorLineEdit.prototype.processPredecessors = function (parentId) {
            var _this = this;
            if (parentId) {
                var record_1 = this.parent.getRecordByID(parentId);
                Eif (record_1 && record_1.ganttProperties && record_1.ganttProperties.predecessor) {
                    this.parent.connectorLineEditModule['validatedOffsetIds'] = [];
                    this.calculateOffset(record_1);
                    var isIdInclude_1 = true;
                    var matchedObject = this.validatedId.find(function (item) {
                        return item.id === record_1.ganttProperties.taskId;
                    });
                    Iif (matchedObject) {
                        var predecessorArray = matchedObject.value;
                        var areArraysEqual = this.compareArrays(predecessorArray, record_1.ganttProperties.predecessor);
                        if (areArraysEqual) {
                            isIdInclude_1 = false;
                        }
                    }
                    var predecessors = record_1.ganttProperties.predecessor;
                    predecessors.forEach(function (predecessor) {
                        Iif (record_1.ganttProperties.taskId === predecessor.from && isIdInclude_1) {
                            _this.processPredecessors(predecessor.to);
                        }
                    });
                }
            }
        };
        ConnectorLineEdit.prototype.checkChildRecords = function (ganttRecord) {
            this.validationPredecessor = ganttRecord.ganttProperties.predecessor;
            if (!ej2_base_1.isNullOrUndefined(this.validationPredecessor)) {
                this.removePredecessors(ganttRecord, this.validationPredecessor);
            }
            if (ganttRecord.childRecords.length > 0) {
                for (var i = 0; i < ganttRecord.childRecords.length; i++) {
                    var childRecord = ganttRecord.childRecords[i];
                    this.validationPredecessor = childRecord.ganttProperties.predecessor;
                    Eif (!ej2_base_1.isNullOrUndefined(this.validationPredecessor)) {
                        this.removePredecessors(childRecord, this.validationPredecessor);
                    }
                    if (childRecord.childRecords.length > 0) {
                        this.checkChildRecords(childRecord);
                    }
                }
            }
            else Eif (!ej2_base_1.isNullOrUndefined(ganttRecord.parentItem)) {
                var parentRecord = this.parent.getRecordByID(ganttRecord.parentItem.taskId);
                this.validationPredecessor = parentRecord.ganttProperties.predecessor;
                this.removePredecessors(parentRecord, this.validationPredecessor);
            }
        };
        ConnectorLineEdit.prototype.compareObjects = function (obj1, obj2) {
            var keys1 = Object.keys(obj1).filter(function (key) { return key !== 'offset'; });
            var keys2 = Object.keys(obj2).filter(function (key) { return key !== 'offset'; });
            Iif (keys1.length !== keys2.length) {
                return false;
            }
            return keys1.every(function (key) { return obj1[key] === obj2[key]; });
        };
        ConnectorLineEdit.prototype.calculateOffset = function (record, isRecursive) {
            var _this = this;
            if (!this.parent.autoCalculateDateScheduling || (this.parent.isLoad && this.parent.treeGrid.loadChildOnDemand
                && this.parent.taskFields.hasChildMapping)) {
                return;
            }
            if (record && utils_1.isScheduledTask(record.ganttProperties) !== null) {
                var prevPredecessor = ej2_base_2.extend([], record.ganttProperties.predecessor, [], true);
                var validPredecessor_1 = this.parent.predecessorModule.getValidPredecessor(record);
                if (validPredecessor_1.length > 0) {
                    this.cumulativePredecessorChanges = prevPredecessor;
                    var _loop_5 = function (i) {
                        var predecessor = validPredecessor_1[parseInt(i.toString(), 10)];
                        var parentTask = this_4.parent.connectorLineModule.getRecordByID(predecessor.from);
                        if (this_4.parent.undoRedoModule && this_4.parent.undoRedoModule['isUndoRedoPerformed'] && this_4.parent.viewType === 'ProjectView') {
                            var isPresent = parentTask.ganttProperties.predecessor.filter(function (pred) {
                                return pred.from === validPredecessor_1[i].from && pred.to === validPredecessor_1[i].to;
                            });
                            Iif (isPresent.length === 0) {
                                parentTask.ganttProperties.predecessor.push(validPredecessor_1[i]);
                            }
                        }
                        var offset = void 0;
                        if ((parentTask.ganttProperties.startDate || parentTask.ganttProperties.endDate) &&
                            (record.ganttProperties.startDate || record.ganttProperties.endDate)) {
                            var tempStartDate = void 0;
                            var tempEndDate = void 0;
                            var tempDuration = void 0;
                            var isNegativeOffset = void 0;
                            switch (predecessor.type) {
                                case 'FS':
                                    tempStartDate = new Date((parentTask.ganttProperties.endDate ||
                                        parentTask.ganttProperties.startDate).getTime());
                                    tempEndDate = new Date((record.ganttProperties.startDate || record.ganttProperties.endDate).getTime());
                                    break;
                                case 'SS':
                                    tempStartDate = new Date((parentTask.ganttProperties.startDate ||
                                        parentTask.ganttProperties.endDate).getTime());
                                    tempEndDate = new Date((record.ganttProperties.startDate || record.ganttProperties.endDate).getTime());
                                    break;
                                case 'SF':
                                    tempStartDate = new Date((parentTask.ganttProperties.startDate ||
                                        parentTask.ganttProperties.endDate).getTime());
                                    tempEndDate = new Date((record.ganttProperties.endDate || record.ganttProperties.startDate).getTime());
                                    break;
                                case 'FF':
                                    tempStartDate = new Date((parentTask.ganttProperties.endDate ||
                                        parentTask.ganttProperties.startDate).getTime());
                                    tempEndDate = new Date((record.ganttProperties.endDate || record.ganttProperties.startDate).getTime());
                                    break;
                            }
                            if (tempStartDate.getTime() < tempEndDate.getTime()) {
                                tempStartDate = this_4.dateValidateModule.checkStartDate(tempStartDate);
                                tempEndDate = this_4.dateValidateModule.checkEndDate(tempEndDate, null);
                                isNegativeOffset = false;
                            }
                            else {
                                var tempDate = new Date(tempStartDate.getTime());
                                tempStartDate = this_4.dateValidateModule.checkStartDate(tempEndDate);
                                tempEndDate = this_4.dateValidateModule.checkEndDate(tempDate, null);
                                isNegativeOffset = true;
                            }
                            if (tempStartDate.getTime() < tempEndDate.getTime()) {
                                tempDuration = this_4.dateValidateModule.getDuration(tempStartDate, tempEndDate, predecessor.offsetUnit, true, false);
                                offset = isNegativeOffset ? (tempDuration * -1) : tempDuration;
                            }
                            else {
                                offset = 0;
                            }
                        }
                        else {
                            offset = 0;
                        }
                        var preIndex = utils_1.getIndex(predecessor, 'from', prevPredecessor, 'to');
                        Eif (preIndex !== -1) {
                            prevPredecessor[preIndex].offset = offset;
                        }
                        var parentPredecessors = ej2_base_2.extend([], parentTask.ganttProperties.predecessor, [], true);
                        var parentPreIndex = utils_1.getIndex(predecessor, 'from', parentPredecessors, 'to');
                        Eif (parentPreIndex !== -1) {
                            parentPredecessors[parentPreIndex].offset = offset;
                        }
                        this_4.parent.setRecordValue('predecessor', parentPredecessors, parentTask.ganttProperties, true);
                    };
                    var this_4 = this;
                    for (var i = 0; i < validPredecessor_1.length; i++) {
                        _loop_5(i);
                    }
                }
                else {
                    var validPredecessor_2 = record.ganttProperties.predecessor;
                    if (validPredecessor_2) {
                        if (validPredecessor_2.length > 0) {
                            validPredecessor_2.forEach(function (element) {
                                if (_this.validatedOffsetIds.indexOf(element.to) === -1) {
                                    _this.calculateOffset(_this.parent.getRecordByID(element.to), true);
                                }
                            });
                        }
                    }
                }
                if (validPredecessor_1.length === 0) {
                    this.cumulativePredecessorChanges = [];
                }
                if (!isRecursive && this.parent.undoRedoModule && !this.parent.undoRedoModule['isUndoRedoPerformed']) {
                    if (prevPredecessor && prevPredecessor.length > 0 && this.cumulativePredecessorChanges &&
                        this.cumulativePredecessorChanges.length > 0) {
                        var matchingObjects = prevPredecessor.map(function (objectToCompare) {
                            var matchedObject = _this.cumulativePredecessorChanges.find(function (obj) { return _this.compareObjects(obj, objectToCompare); });
                            return matchedObject ? __assign({}, matchedObject) : null;
                        }).filter(function (matchedObject) { return matchedObject !== null; });
                        this.parent.setRecordValue('predecessor', matchingObjects, record.ganttProperties, true);
                    }
                }
                else {
                    this.parent.setRecordValue('predecessor', prevPredecessor, record.ganttProperties, true);
                }
                var predecessorString = this.parent.predecessorModule.getPredecessorStringValue(record);
                this.parent.setRecordValue('taskData.' + this.parent.taskFields.dependency, predecessorString, record);
                this.parent.setRecordValue(this.parent.taskFields.dependency, predecessorString, record);
                this.parent.setRecordValue('predecessorsName', predecessorString, record.ganttProperties, true);
                Eif (this.validatedOffsetIds.indexOf(record.ganttProperties.taskId.toString()) === -1) {
                    this.validatedOffsetIds.push(record.ganttProperties.taskId.toString());
                }
                if (record.hasChildRecords) {
                    for (var i = 0; i < record.childRecords.length; i++) {
                        if (this.validatedOffsetIds.indexOf(record.childRecords[i].ganttProperties.taskId.toString()) === -1 &&
                            record.childRecords[i].ganttProperties.predecessor &&
                            record.childRecords[i].ganttProperties.predecessor.length > 0) {
                            this.calculateOffset(record.childRecords[i]);
                        }
                    }
                }
                else if (record.parentItem) {
                    var parentItem = this.parent.getRecordByID(record.parentItem.taskId);
                    if (this.validatedOffsetIds.indexOf(parentItem.ganttProperties.taskId.toString()) === -1 &&
                        parentItem.ganttProperties.predecessor && parentItem.ganttProperties.predecessor.length > 0) {
                        this.calculateOffset(parentItem);
                    }
                }
            }
        };
        ConnectorLineEdit.prototype.removePredecessors = function (ganttRecord, predecessor) {
            var prevPredecessor = ej2_base_2.extend([], [], ganttRecord.ganttProperties.predecessor, true);
            Iif (ej2_base_1.isNullOrUndefined(predecessor)) {
                return;
            }
            var preLength = predecessor.length;
            for (var i = 0; i < preLength; i++) {
                var parentGanttRecord = this.parent.connectorLineModule.getRecordByID(predecessor[i].from);
                var parentPredecessor = ej2_base_2.extend([], [], parentGanttRecord.ganttProperties.predecessor, true);
                var index = utils_1.getIndex(predecessor[i], 'from', prevPredecessor, 'to');
                prevPredecessor.splice(index, 1);
                var parentIndex = utils_1.getIndex(predecessor[parseInt(i.toString(), 10)], 'from', parentPredecessor, 'to');
                parentPredecessor.splice(parentIndex, 1);
                this.parent.setRecordValue('predecessor', parentPredecessor, parentGanttRecord.ganttProperties, true);
            }
            if (prevPredecessor.length !== ganttRecord.ganttProperties.predecessor.length) {
                this.parent.setRecordValue('predecessor', prevPredecessor, ganttRecord.ganttProperties, true);
                var predecessorString = this.parent.predecessorModule.getPredecessorStringValue(ganttRecord);
                this.parent.setRecordValue('predecessorsName', predecessorString, ganttRecord.ganttProperties, true);
                this.parent.setRecordValue('taskData.' + this.parent.taskFields.dependency, predecessorString, ganttRecord);
                this.parent.setRecordValue(this.parent.taskFields.dependency, predecessorString, ganttRecord);
            }
        };
        ConnectorLineEdit.prototype.openValidationDialog = function (args) {
            var contentTemplate = this.validationDialogTemplate(args);
            this.parent.validationDialogElement.setProperties({ content: contentTemplate });
            this.parent.validationDialogElement.show();
        };
        ConnectorLineEdit.prototype.validationDialogTemplate = function (args) {
            var ganttId = this.parent.element.id;
            var contentdiv = ej2_base_2.createElement('div', {
                className: 'e-ValidationContent'
            });
            var taskData = ej2_base_2.getValue('task', args);
            var parenttaskData = ej2_base_2.getValue('parentTask', args);
            var violationType = ej2_base_2.getValue('violationType', args);
            var recordName = taskData.ganttProperties.taskName;
            var recordNewStartDate = this.parent.getFormatedDate(taskData.ganttProperties.startDate, this.parent.dateFormat);
            var parentName = parenttaskData.ganttProperties.taskName;
            var recordArgs = [recordName, parentName];
            var topContentText;
            if (violationType === 'taskBeforePredecessor_FS') {
                topContentText = this.parent.localeObj.getConstant('taskBeforePredecessor_FS');
            }
            else if (violationType === 'taskAfterPredecessor_FS') {
                topContentText = this.parent.localeObj.getConstant('taskAfterPredecessor_FS');
            }
            else if (violationType === 'taskBeforePredecessor_SS') {
                topContentText = this.parent.localeObj.getConstant('taskBeforePredecessor_SS');
            }
            else if (violationType === 'taskAfterPredecessor_SS') {
                topContentText = this.parent.localeObj.getConstant('taskAfterPredecessor_SS');
            }
            else if (violationType === 'taskBeforePredecessor_FF') {
                topContentText = this.parent.localeObj.getConstant('taskBeforePredecessor_FF');
            }
            else if (violationType === 'taskAfterPredecessor_FF') {
                topContentText = this.parent.localeObj.getConstant('taskAfterPredecessor_FF');
            }
            else if (violationType === 'taskBeforePredecessor_SF') {
                topContentText = this.parent.localeObj.getConstant('taskBeforePredecessor_SF');
            }
            else Eif (violationType === 'taskAfterPredecessor_SF') {
                topContentText = this.parent.localeObj.getConstant('taskAfterPredecessor_SF');
            }
            topContentText = utils_1.formatString(topContentText, recordArgs);
            var topContent = '<div id="' + ganttId + '_ValidationText">' + topContentText + '<div>';
            var innerTable = '<table>' +
                '<tr><td><input type="radio" id="' + ganttId + '_ValidationCancel" name="ValidationRule" checked/><label for="'
                + ganttId + '_ValidationCancel" id= "' + ganttId + '_cancelLink">Cancel, keep the existing link</label></td></tr>' +
                '<tr><td><input type="radio" id="' + ganttId + '_ValidationRemoveline" name="ValidationRule"/><label for="'
                + ganttId + '_ValidationRemoveline" id="' + ganttId + '_removeLink">Remove the link and move <b>'
                + recordName + '</b> to start on <b>' + recordNewStartDate + '</b>.</label></td></tr>' +
                '<tr><td><input type="radio" id="' + ganttId + '_ValidationAddlineOffset" name="ValidationRule"/><label for="'
                + ganttId + '_ValidationAddlineOffset" id="' + ganttId + '_preserveLink">Move the <b>'
                + recordName + '</b> to start on <b>' + recordNewStartDate + '</b> and keep the link.</label></td></tr></table>';
            contentdiv.innerHTML = topContent + innerTable;
            return contentdiv;
        };
        ConnectorLineEdit.prototype.validateTypes = function (ganttRecord, data) {
            var predecessor = this.parent.predecessorModule.getValidPredecessor(ganttRecord);
            var parentGanttRecord;
            this.validationPredecessor = [];
            var violatedParent;
            var ganttTaskData;
            var violateType;
            var startDate = this.parent.predecessorModule.getPredecessorDate(ganttRecord, predecessor);
            if (data) {
                ganttTaskData = data.ganttProperties;
            }
            else {
                ganttTaskData = ganttRecord.ganttProperties;
            }
            var endDate = this.parent.allowUnscheduledTasks && ej2_base_1.isNullOrUndefined(startDate) ?
                ganttTaskData.endDate :
                this.dateValidateModule.getEndDate(startDate, ganttTaskData.duration, ganttTaskData.durationUnit, ganttTaskData, false);
            for (var i = 0; i < predecessor.length; i++) {
                parentGanttRecord = this.parent.connectorLineModule.getRecordByID(predecessor[i].from);
                var violationType = null;
                if (predecessor[i].type === 'FS') {
                    if (this.parent.dateValidationModule.getDuration(startDate, ganttTaskData.startDate, this.parent.durationUnit, ganttTaskData.isAutoSchedule, ganttTaskData.isMilestone, true) !== 0) {
                        if (ganttTaskData.startDate < startDate) {
                            this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                            violationType = 'taskBeforePredecessor_FS';
                        }
                        else if (ganttTaskData.startDate > startDate) {
                            this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                            violationType = 'taskAfterPredecessor_FS';
                        }
                    }
                }
                else if (predecessor[i].type === 'SS') {
                    var endDateOlny = new Date(ganttTaskData.endDate);
                    var startDateOlny = new Date(startDate);
                    if (ganttTaskData.startDate < startDate) {
                        this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                        violationType = 'taskBeforePredecessor_SS';
                    }
                    else if (ganttTaskData.startDate > startDate) {
                        this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                        violationType = 'taskAfterPredecessor_SS';
                    }
                    else Iif (this.parent.allowUnscheduledTasks &&
                        ej2_base_1.isNullOrUndefined(ganttTaskData.startDate) &&
                        ej2_base_1.isNullOrUndefined(ganttTaskData.duration) &&
                        endDateOlny.setHours(0, 0, 0, 0) < startDateOlny.setHours(0, 0, 0, 0)) {
                        this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                        violationType = 'taskBeforePredecessor_SS';
                    }
                    else Iif (this.parent.allowUnscheduledTasks &&
                        ej2_base_1.isNullOrUndefined(ganttTaskData.startDate) &&
                        ej2_base_1.isNullOrUndefined(ganttTaskData.duration) &&
                        endDateOlny.setHours(0, 0, 0, 0) > startDateOlny.setHours(0, 0, 0, 0)) {
                        this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                        violationType = 'taskAfterPredecessor_SS';
                    }
                }
                else if (predecessor[i].type === 'FF') {
                    if (this.parent.dateValidationModule.getDuration(startDate, parentGanttRecord.ganttProperties.endDate, this.parent.durationUnit, parentGanttRecord.ganttProperties.isAutoSchedule, parentGanttRecord.ganttProperties.isMilestone, true) !== 0) {
                        if (endDate <= parentGanttRecord.ganttProperties.endDate) {
                            this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                            violationType = 'taskBeforePredecessor_FF';
                        }
                        else Eif (endDate > parentGanttRecord.ganttProperties.endDate) {
                            this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                            violationType = 'taskAfterPredecessor_FF';
                        }
                    }
                }
                else Eif (predecessor[i].type === 'SF') {
                    if (this.parent.dateValidationModule.getDuration(parentGanttRecord.ganttProperties.startDate, endDate, this.parent.durationUnit, parentGanttRecord.ganttProperties.isAutoSchedule, parentGanttRecord.ganttProperties.isMilestone, true) !== 0) {
                        if (endDate < parentGanttRecord.ganttProperties.startDate) {
                            this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                            violationType = 'taskBeforePredecessor_SF';
                        }
                        else Eif (endDate >= parentGanttRecord.ganttProperties.startDate) {
                            this.validationPredecessor.push(predecessor[parseInt(i.toString(), 10)]);
                            violationType = 'taskAfterPredecessor_SF';
                        }
                    }
                }
                if (!ej2_base_1.isNullOrUndefined(violationType) && ej2_base_1.isNullOrUndefined(violateType)) {
                    violatedParent = parentGanttRecord;
                    violateType = violationType;
                }
            }
            var validateArgs = {
                parentTask: violatedParent,
                task: ganttRecord,
                violationType: violateType
            };
            return validateArgs;
        };
        ConnectorLineEdit.prototype.addRemovePredecessor = function (data) {
            var prevData = this.parent.previousRecords[data.uniqueID];
            var newPredecessor = data.ganttProperties.predecessor.slice();
            Eif (prevData && prevData.ganttProperties && prevData.ganttProperties.hasOwnProperty('predecessor')) {
                var prevPredecessor_1 = prevData.ganttProperties.predecessor;
                if (!ej2_base_1.isNullOrUndefined(prevPredecessor_1)) {
                    var _loop_6 = function (p) {
                        var parentGanttRecord = this_5.parent.connectorLineModule.getRecordByID(prevPredecessor_1[parseInt(p.toString(), 10)].from);
                        if (parentGanttRecord === data) {
                            var isValid = data.ganttProperties.predecessor.filter(function (pred) {
                                return prevPredecessor_1[p].from === pred.from && prevPredecessor_1[p].to === pred.to;
                            });
                            Eif (isValid.length === 0) {
                                if (data.parentItem && this_5.parent.taskFields.dependency && data.ganttProperties.predecessor &&
                                    this_5.parent.allowParentDependency) {
                                    Eif (prevPredecessor_1[p].from !== data.parentItem.taskId &&
                                        prevPredecessor_1[p].to !== data.parentItem.taskId) {
                                        data.ganttProperties.predecessor.push(prevPredecessor_1[parseInt(p.toString(), 10)]);
                                    }
                                }
                                else {
                                    data.ganttProperties.predecessor.push(prevPredecessor_1[parseInt(p.toString(), 10)]);
                                }
                            }
                        }
                        else {
                            var parentPredecessor = ej2_base_2.extend([], [], parentGanttRecord.ganttProperties.predecessor, true);
                            var parentIndex = utils_1.getIndex(prevPredecessor_1[parseInt(p.toString(), 10)], 'from', parentPredecessor, 'to');
                            if (parentIndex !== -1) {
                                parentPredecessor.splice(parentIndex, 1);
                                this_5.parent.setRecordValue('predecessor', parentPredecessor, parentGanttRecord.ganttProperties, true);
                            }
                        }
                    };
                    var this_5 = this;
                    for (var p = 0; p < prevPredecessor_1.length; p++) {
                        _loop_6(p);
                    }
                }
                Eif (!ej2_base_1.isNullOrUndefined(newPredecessor)) {
                    var _loop_7 = function (n) {
                        var parentGanttRecord = this_6.parent.connectorLineModule.getRecordByID(newPredecessor[parseInt(n.toString(), 10)].from);
                        var parentPredecessor = ej2_base_2.extend([], [], parentGanttRecord.ganttProperties.predecessor, true);
                        var isValid = parentPredecessor.filter(function (pred) {
                            return newPredecessor[n].from === pred.from && newPredecessor[n].to === pred.to;
                        });
                        if (isValid.length === 0) {
                            parentPredecessor.push(newPredecessor[parseInt(n.toString(), 10)]);
                            this_6.parent.setRecordValue('predecessor', parentPredecessor, parentGanttRecord.ganttProperties, true);
                        }
                    };
                    var this_6 = this;
                    for (var n = 0; n < newPredecessor.length; n++) {
                        _loop_7(n);
                    }
                }
            }
        };
        ConnectorLineEdit.prototype.removePredecessorByIndex = function (childRecord, index) {
            if (this.parent.undoRedoModule && !this.parent.undoRedoModule['isUndoRedoPerformed']) {
                Eif (this.parent.undoRedoModule['redoEnabled']) {
                    this.parent.undoRedoModule['disableRedo']();
                }
                this.parent.undoRedoModule['createUndoCollection']();
                var details = {};
                details['action'] = 'DeleteDependency';
                details['modifiedRecords'] = ej2_base_2.extend([], [childRecord], [], true);
                this.parent.undoRedoModule['getUndoCollection'][this.parent.undoRedoModule['getUndoCollection'].length - 1] = details;
            }
            var childPredecessor = childRecord.ganttProperties.predecessor;
            var predecessor = childPredecessor.splice(index, 1);
            var parentRecord = this.parent.connectorLineModule.getRecordByID(predecessor[0].from);
            var parentPredecessor = parentRecord.ganttProperties.predecessor;
            var parentIndex = utils_1.getIndex(predecessor[0], 'from', parentPredecessor, 'to');
            parentPredecessor.splice(parentIndex, 1);
            var predecessorString = this.parent.predecessorModule.getPredecessorStringValue(childRecord);
            childPredecessor.push(predecessor[0]);
            this.parent.connectorLineEditModule.updatePredecessor(childRecord, predecessorString);
        };
        ConnectorLineEdit.prototype.renderPredecessorDeleteConfirmDialog = function () {
            this.confirmPredecessorDialog = new ej2_popups_1.Dialog({
                width: '320px',
                isModal: true,
                enableRtl: this.parent.enableRtl,
                content: this.parent.localeObj.getConstant('confirmPredecessorDelete'),
                buttons: [
                    {
                        click: this.confirmOkDeleteButton.bind(this),
                        buttonModel: { content: this.parent.localeObj.getConstant('okText'), isPrimary: true }
                    },
                    {
                        click: this.confirmCloseDialog.bind(this),
                        buttonModel: { content: this.parent.localeObj.getConstant('cancel') }
                    }
                ],
                target: this.parent.element,
                animationSettings: { effect: 'None' }
            });
            var confirmDialog = ej2_base_2.createElement('div', {
                id: this.parent.element.id + '_deletePredecessorConfirmDialog'
            });
            this.parent.element.appendChild(confirmDialog);
            this.confirmPredecessorDialog.isStringTemplate = true;
            this.confirmPredecessorDialog.appendTo(confirmDialog);
        };
        ConnectorLineEdit.prototype.confirmCloseDialog = function () {
            this.confirmPredecessorDialog.destroy();
        };
        ConnectorLineEdit.prototype.confirmOkDeleteButton = function () {
            this.removePredecessorByIndex(this.childRecord, this.predecessorIndex);
            this.confirmPredecessorDialog.destroy();
        };
        return ConnectorLineEdit;
    }());
    exports.ConnectorLineEdit = ConnectorLineEdit;
});