all files / actions/ undo-redo.js

93.86% Statements 566/603
87.75% Branches 351/400
86.67% Functions 13/15
94.02% Lines 566/602
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                       105× 105× 105× 105× 105× 105× 105× 105× 105× 105× 105×   49× 49× 48× 48× 48×   44×   42×   38×   37×   35×   34×   32×   30×                   25×   24×     17×     12× 12× 12× 46× 46× 34×     12×         46×     48× 48× 48× 48× 48×     44×   42×           38×         37×   35×   34×           32×   30×             25×             24×                   17×         12× 12×       48× 48× 48× 48× 48× 48× 48× 48×   48×   48× 48× 45×             28× 28× 28× 28×   26×   25×   22×   21×   19×   18×   16×   15×                         13×   12×       11× 11×             11×     28× 28× 28× 28×         26×   25×           22×           20×     19×   17×   16×   15×           13×         12×                                   28× 28× 28×   28× 28× 28× 28×       111×   111× 109×   111× 86× 86× 85×     25× 23× 23× 23×           62× 65× 65× 65× 36× 26× 26× 21× 21× 21×   10× 10×     11× 11× 11× 11× 11× 12× 12×     11× 11×                             10×                                                                                                 29× 22× 22×     13×   22× 13× 13× 13×       12×                                                                                     74×                                 65×                 60×     62× 62× 65×     27959×   105×          
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"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var UndoRedo = (function () {
        function UndoRedo(parent) {
            this.isUndoRedoPerformed = false;
            this.changedRecords = [];
            this.getRedoCollection = [];
            this.getUndoCollection = [];
            this.redoEnabled = false;
            this.previousSortedColumns = [];
            this.searchString = '';
            this.isFromUndoRedo = false;
            this.canUpdateIndex = true;
            this.sortedColumnsLength = 0;
            this.parent = parent;
        }
        UndoRedo.prototype.undoAction = function () {
            var _this = this;
            if (this.getUndoCollection.length > 0) {
                var updateAction_1 = this.getUndoCollection[this.getUndoCollection.length - 1];
                var previousActions = {};
                if (updateAction_1['action'] === 'ZoomIn' || updateAction_1['action'] === 'ZoomOut' || updateAction_1['action'] === 'ZoomToFit') {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['previousZoomingLevel'] = ej2_base_1.extend({}, {}, this.parent.currentZoomingLevel, true);
                }
                else if (updateAction_1['action'] === 'NextTimeSpan' || updateAction_1['action'] === 'PreviousTimeSpan') {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['previousTimelineStartDate'] = ej2_base_1.extend([], [this.parent.timelineModule.timelineStartDate], [], true)[0];
                    previousActions['previousTimelineEndDate'] = ej2_base_1.extend([], [this.parent.timelineModule.timelineEndDate], [], true)[0];
                }
                else if (updateAction_1['action'] === 'Sorting') {
                    previousActions['action'] = 'Sorting';
                    previousActions['sortColumns'] = this.previousSortedColumns;
                }
                else if (updateAction_1['action'] === 'Filtering') {
                    previousActions['action'] = 'Filtering';
                    previousActions['filteredColumns'] = updateAction_1['filteredColumns'];
                }
                else if (updateAction_1['action'] === 'ColumnReorder') {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['toColumn'] = updateAction_1['fromColumn'];
                    previousActions['fromColumn'] = updateAction_1['toColumn'];
                    previousActions['fromIndex'] = updateAction_1['toIndex'];
                    previousActions['toIndex'] = updateAction_1['fromIndex'];
                }
                else if (updateAction_1['action'] === 'Search') {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['searchString'] = this.searchString;
                }
                else if (updateAction_1['action'] === 'ColumnState') {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['showhideColumns'] = updateAction_1['showhideColumns'];
                }
                else if (updateAction_1['action'] === 'ColumnResize') {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['resizedColumn'] = __assign({}, this.parent.treeGrid.columns[updateAction_1['resizedColumn'].index]);
                }
                else if (updateAction_1['action'] === 'RowDragAndDrop' || updateAction_1['action'] === 'TaskbarDragAndDrop') {
                    var rowItems = [];
                    for (var i = 0; i < updateAction_1['beforeDrop'].length; i++) {
                        if (this.parent.viewType === 'ProjectView') {
                            rowItems.push(this.parent.getRecordByID(updateAction_1['beforeDrop'][i]['data'].ganttProperties.taskId));
                        }
                        else {
                            rowItems.push(this.parent.flatData[this.parent.taskIds.indexOf('T' + updateAction_1['beforeDrop'][i]['data'].ganttProperties.taskId.toString())]);
                        }
                    }
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['beforeDrop'] = [];
                    var previousDetails = {};
                    var dropRecord = ej2_base_1.extend([], [], [this.parent.getRecordByID(updateAction_1['afterDrop'].dropRecord.ganttProperties.taskId)], true)[0];
                    previousDetails['data'] = [];
                    for (var i = 0; i < updateAction_1['afterDrop'].data.length; i++) {
                        if (this.parent.viewType === 'ProjectView') {
                            previousDetails['data'].push(ej2_base_1.extend([], [], [this.parent.getRecordByID(updateAction_1['afterDrop'].data[i].ganttProperties.taskId)], true)[0]);
                        }
                        else {
                            previousDetails['data'].push(ej2_base_1.extend([], [], this.parent.flatData[this.parent.taskIds.indexOf('T' + updateAction_1['afterDrop'].data[i].ganttProperties.taskId)], true)[0]);
                        }
                    }
                    previousDetails['dropRecord'] = ej2_base_1.extend([], [], [dropRecord], true)[0];
                    previousDetails['dropPosition'] = updateAction_1['afterDrop'].dropPosition;
                    previousActions['afterDrop'] = previousDetails;
                    this['findPosition'](rowItems, previousActions, 'beforeDrop');
                }
                else if (updateAction_1['action'] === 'Indent' || updateAction_1['action'] === 'Outdent') {
                    previousActions['selectedRowIndexes'] = updateAction_1['selectedRowIndexes'];
                    previousActions['droppedRecord'] = ej2_base_1.extend([], [], [this.parent.flatData[this.parent.ids.indexOf(updateAction_1['droppedRecord'].ganttProperties.taskId.toString())]], true)[0];
                    previousActions['modifiedRecord'] = [];
                    this.findPosition(ej2_base_1.extend([], [], [this.parent.flatData[this.parent.ids.indexOf(updateAction_1['modifiedRecord'][0].data.ganttProperties.taskId.toString())]], true), previousActions, 'modifiedRecord');
                    previousActions['action'] = updateAction_1['action'];
                }
                else if (updateAction_1['action'] === 'Delete') {
                    previousActions['action'] = 'Delete';
                    previousActions['deleteRecords'] = [];
                    for (var i = 0; i < updateAction_1['deletedRecordsDetails'].length; i++) {
                        previousActions['deleteRecords'].push(updateAction_1['deletedRecordsDetails'][i].data);
                    }
                }
                else if (updateAction_1['action'] === 'Add') {
                    previousActions['action'] = 'Add';
                    previousActions['deletedRecordsDetails'] = [];
                    var rowItems = updateAction_1['addedRecords'];
                    this.findPosition(rowItems, previousActions, 'deletedRecordsDetails');
                }
                else {
                    previousActions['action'] = updateAction_1['action'];
                    previousActions['modifiedRecords'] = [];
                    for (var i = 0; i < updateAction_1['modifiedRecords'].length; i++) {
                        var index = void 0;
                        if (this.parent.viewType === 'ProjectView') {
                            index = this.parent.ids.indexOf(updateAction_1['modifiedRecords'][i].ganttProperties.taskId.toString());
                        }
                        else {
                            if (updateAction_1['modifiedRecords'][i].hasChildRecords) {
                                index = this.parent.taskIds.indexOf('R' + updateAction_1['modifiedRecords'][i].ganttProperties.taskId);
                            }
                            else {
                                index = this.parent.taskIds.indexOf('T' + updateAction_1['modifiedRecords'][i].ganttProperties.taskId);
                            }
                        }
                        previousActions['modifiedRecords'].push(ej2_base_1.extend([], [this.parent.flatData[index]], [], true)[0]);
                    }
                }
                this.getRedoCollection.push(previousActions);
                this.isUndoRedoPerformed = true;
                this.changedRecords = [];
                this.currentAction = updateAction_1;
                if (updateAction_1['action'] === 'ZoomIn' || updateAction_1['action'] === 'ZoomOut' || updateAction_1['action'] === 'ZoomToFit') {
                    this.parent.timelineSettings.timelineViewMode = updateAction_1['previousZoomingLevel'].timelineViewMode;
                    this.parent.timelineSettings.timelineUnitSize = updateAction_1['previousZoomingLevel'].timelineUnitSize;
                    this.parent.timelineSettings.updateTimescaleView = updateAction_1['previousZoomingLevel'].updateTimescaleView;
                    this.parent.timelineSettings.topTier.unit = updateAction_1['previousZoomingLevel'].topTier.unit;
                    this.parent.timelineSettings.topTier.count = updateAction_1['previousZoomingLevel'].topTier.count;
                    this.parent.timelineSettings.topTier.format = updateAction_1['previousZoomingLevel'].topTier.format;
                    this.parent.timelineSettings.bottomTier.unit = updateAction_1['previousZoomingLevel'].bottomTier.unit;
                    this.parent.timelineSettings.bottomTier.count = updateAction_1['previousZoomingLevel'].bottomTier.count;
                    this.parent.timelineSettings.bottomTier.format = updateAction_1['previousZoomingLevel'].bottomTier.format;
                    this.parent.timelineSettings.weekStartDay = updateAction_1['previousZoomingLevel'].weekStartDay;
                    this.parent.timelineSettings.weekendBackground = updateAction_1['previousZoomingLevel'].weekendBackground;
                    if (updateAction_1['action'] === 'ZoomToFit') {
                        this.parent.timelineModule.refreshTimeline();
                    }
                }
                else if (updateAction_1['action'] === 'NextTimeSpan' || updateAction_1['action'] === 'PreviousTimeSpan') {
                    this.parent.updateProjectDates(updateAction_1['previousTimelineStartDate'], updateAction_1['previousTimelineEndDate'], false);
                }
                else if (updateAction_1['action'] === 'Sorting') {
                    this.isFromUndoRedo = true;
                    this.sortedColumnsLength = 0;
                    if (updateAction_1['sortColumns'].length > 0) {
                        for (var i = 0; i < updateAction_1['sortColumns'].length; i++) {
                            this.parent.treeGrid.sortByColumn(updateAction_1['sortColumns'][i]['field'], updateAction_1['sortColumns'][i]['direction']);
                        }
                    }
                    else {
                        this.parent.clearSorting();
                    }
                }
                else if (updateAction_1['action'] === 'Filtering') {
                    this.isFromUndoRedo = true;
                    for (var i = this.getUndoCollection.length - 1; i >= 0; i--) {
                        Eif (this.getUndoCollection[i]['filteredColumns']) {
                            var columnsArray = [];
                            for (var j = 0; j < this.getUndoCollection[i]['filteredColumns'].length; j++) {
                                columnsArray.push(this.getUndoCollection[i]['filteredColumns'][j].field);
                            }
                            this.parent.clearFiltering(columnsArray);
                        }
                    }
                }
                else if (updateAction_1['action'] === 'ColumnReorder') {
                    this.isFromUndoRedo = true;
                    var fromColumn = this.parent.treeGrid.columns[updateAction_1['fromIndex']]['field'];
                    var toColumn = this.parent.treeGrid.columns[updateAction_1['toIndex']]['field'];
                    this.parent.reorderColumns(fromColumn, toColumn);
                }
                else if (updateAction_1['action'] === 'Search') {
                    this.isFromUndoRedo = true;
                    this.parent.search(updateAction_1['searchString']);
                }
                else if (updateAction_1['action'] === 'ColumnState') {
                    this.isFromUndoRedo = true;
                    for (var i = 0; i < updateAction_1['showhideColumns'].length; i++) {
                        if (updateAction_1['showhideColumns'][i].visible) {
                            this.parent.hideColumn(updateAction_1['showhideColumns'][i].field, 'field');
                        }
                        else {
                            this.parent.showColumn(updateAction_1['showhideColumns'][i].field, 'field');
                        }
                    }
                }
                else if (updateAction_1['action'] === 'ColumnResize') {
                    this.parent.treeGrid.columns[updateAction_1['resizedColumn'].index]['width'] = updateAction_1['resizedColumn'].width;
                    this.parent.treeGrid.refreshColumns();
                }
                else if (updateAction_1['action'] === 'RowDragAndDrop' || updateAction_1['action'] === 'TaskbarDragAndDrop') {
                    for (var i = 0; i < updateAction_1['beforeDrop'].length; i++) {
                        var fromIndex = void 0;
                        var toIndex = void 0;
                        if (this.parent.viewType === 'ProjectView') {
                            fromIndex = this.parent.ids.indexOf(updateAction_1['beforeDrop'][i].data.ganttProperties.taskId.toString());
                            toIndex = this.parent.ids.indexOf(updateAction_1['beforeDrop'][i]['id'].toString());
                        }
                        else {
                            fromIndex = this.parent.ids.indexOf('T' + updateAction_1['beforeDrop'][i].data.ganttProperties.taskId.toString());
                            toIndex = this.parent.taskIds.indexOf(updateAction_1['beforeDrop'][i]['id'].toString());
                        }
                        this.parent.reorderRows([fromIndex], toIndex, updateAction_1['beforeDrop'][i].position);
                        this.parent.updateRecordByID(updateAction_1['beforeDrop'][i].data);
                        if (updateAction_1['afterDrop'].dropPosition === 'child') {
                            this.parent.updateRecordByID(updateAction_1['afterDrop'].dropRecord);
                        }
                    }
                }
                else if (updateAction_1['action'] === 'Indent' || updateAction_1['action'] === 'Outdent') {
                    this.parent.selectRow(this.parent.ids.indexOf(updateAction_1['modifiedRecord'][0].data.ganttProperties.taskId.toString()));
                    Eif (updateAction_1['action'] === 'Indent') {
                        this.parent.outdent();
                    }
                    else {
                        this.parent.indent();
                    }
                    setTimeout(function () {
                        _this.isUndoRedoPerformed = true;
                        _this.parent.updateRecordByID(updateAction_1['droppedRecord']);
                        _this.isUndoRedoPerformed = false;
                    });
                }
                else if (updateAction_1['action'] === 'Delete') {
                    var rowIndex = void 0;
                    for (var i = 0; i < updateAction_1['deletedRecordsDetails'].length; i++) {
                        if (this.parent.viewType === 'ProjectView') {
                            rowIndex = this.parent.ids.indexOf(updateAction_1['deletedRecordsDetails'][i].id.toString());
                        }
                        else {
                            rowIndex = this.parent.taskIds.indexOf(updateAction_1['deletedRecordsDetails'][i].id.toString());
                        }
                        var position = void 0;
                        if (updateAction_1['deletedRecordsDetails'][i].position === 'above') {
                            position = 'Above';
                        }
                        if (updateAction_1['deletedRecordsDetails'][i].position === 'below') {
                            position = 'Below';
                        }
                        Iif (updateAction_1['deletedRecordsDetails'][i].position === 'child') {
                            position = 'Child';
                        }
                        this.parent.addRecord(updateAction_1['deletedRecordsDetails'][i].data, position, rowIndex);
                    }
                }
                else if (updateAction_1['action'] === 'Add') {
                    var isShowDeleteConfirmDialog = ej2_base_1.extend([], [this.parent.editSettings.showDeleteConfirmDialog], [], true)[0];
                    this.parent.editSettings.showDeleteConfirmDialog = false;
                    var deleteRec = updateAction_1['addedRecords'];
                    if (this.parent.viewType === 'ResourceView' && updateAction_1['addedRecords'].length === 1 && updateAction_1['addedRecords'][0].parentItem) {
                        var parentRec = this.parent.getTaskByUniqueID(updateAction_1['addedRecords'][0].parentItem.uniqueID);
                        if (parentRec.childRecords.length === 1 && parentRec.ganttProperties.taskName === 'Unassigned Task') {
                            deleteRec = parentRec;
                        }
                    }
                    this.parent.deleteRecord(deleteRec);
                    this.parent.editSettings.showDeleteConfirmDialog = isShowDeleteConfirmDialog;
                }
                else {
                    this.parent.updateRecordByID(this.getUndoCollection[this.getUndoCollection.length - 1]['modifiedRecords'][0]);
                    if (updateAction_1['connectedRecords'] && this.parent.viewType === 'ProjectView') {
                        for (var i = 0; i < updateAction_1['connectedRecords'].length; i++) {
                            this.parent.updateRecordByID(updateAction_1['connectedRecords'][i]);
                        }
                    }
                }
                var args = {};
                args = ej2_base_1.extend([], [], [this.getUndoCollection[this.getUndoCollection.length - 1]], true)[0];
                args['requestType'] = 'afterUndoAction';
                this.parent.trigger('onAfterUndo', args);
                this.isUndoRedoPerformed = false;
                Eif (this.getRedoCollection.length > 0) {
                    Eif (this.parent.toolbarModule) {
                        this.parent.toolbarModule.enableItems([this.parent.controlId + '_redo'], true);
                    }
                    this.redoEnabled = true;
                }
                this.getUndoCollection.splice(this.getUndoCollection.length - 1, 1);
                if (this.getUndoCollection.length === 0 && this.parent.toolbarModule) {
                    this.parent.toolbarModule.enableItems([this.parent.controlId + '_undo'], false);
                }
            }
            else {
                this.getUndoCollection.splice(this.getUndoCollection.length - 1, 1);
                Eif (this.getUndoCollection.length === 0 && this.parent.toolbarModule) {
                    this.parent.toolbarModule.enableItems([this.parent.controlId + '_undo'], false);
                }
            }
        };
        UndoRedo.prototype.redoAction = function () {
            Eif (this.getRedoCollection.length > 0) {
                var updateAction = this.getRedoCollection[this.getRedoCollection.length - 1];
                var previousActions = {};
                if (updateAction['action'] === 'ZoomIn' || updateAction['action'] === 'ZoomOut' || updateAction['action'] === 'ZoomToFit') {
                    previousActions['action'] = updateAction['action'];
                    previousActions['previousZoomingLevel'] = ej2_base_1.extend({}, {}, this.parent.currentZoomingLevel, true);
                }
                else if (updateAction['action'] === 'NextTimeSpan' || updateAction['action'] === 'PreviousTimeSpan') {
                    previousActions['action'] = updateAction['action'];
                    previousActions['previousTimelineStartDate'] = ej2_base_1.extend([], [this.parent.timelineModule.timelineStartDate], [], true)[0];
                    previousActions['previousTimelineEndDate'] = ej2_base_1.extend([], [this.parent.timelineModule.timelineEndDate], [], true)[0];
                }
                else if (updateAction['action'] === 'Sorting') {
                    previousActions['action'] = 'Sorting';
                    previousActions['sortColumns'] = ej2_base_1.extend([], this.parent.sortSettings.columns, [], true);
                }
                else if (updateAction['action'] === 'Filtering') {
                    previousActions['action'] = 'Filtering';
                    previousActions['filteredColumns'] = updateAction['filteredColumns'];
                }
                else if (updateAction['action'] === 'ColumnReorder') {
                    previousActions['action'] = updateAction['action'];
                    previousActions['toColumn'] = updateAction['fromColumn'];
                    previousActions['fromColumn'] = updateAction['toColumn'];
                    previousActions['fromIndex'] = updateAction['toIndex'];
                    previousActions['toIndex'] = updateAction['fromIndex'];
                }
                else if (updateAction['action'] === 'Search') {
                    previousActions['action'] = updateAction['action'];
                    previousActions['searchString'] = ej2_base_1.extend([], [this.parent.searchSettings.key], [], true)[0];
                }
                else if (updateAction['action'] === 'ColumnState') {
                    previousActions['action'] = updateAction['action'];
                    previousActions['showhideColumns'] = updateAction['showhideColumns'];
                }
                else if (updateAction['action'] === 'ColumnResize') {
                    previousActions['action'] = updateAction['action'];
                    previousActions['resizedColumn'] = __assign({}, this.parent.treeGrid.columns[updateAction['resizedColumn'].index]);
                }
                else if (updateAction['action'] === 'RowDragAndDrop' || updateAction['action'] === 'TaskbarDragAndDrop') {
                    var rowItems = [];
                    for (var i = 0; i < updateAction['beforeDrop'].length; i++) {
                        if (this.parent.viewType === 'ProjectView') {
                            rowItems.push(this.parent.getRecordByID(updateAction['beforeDrop'][i]['data'].ganttProperties.taskId));
                        }
                        else {
                            rowItems.push(this.parent.flatData[this.parent.taskIds.indexOf('T' + updateAction['beforeDrop'][i]['data'].ganttProperties.taskId.toString())]);
                        }
                    }
                    previousActions['action'] = updateAction['action'];
                    previousActions['beforeDrop'] = [];
                    var previousDetails = {};
                    var dropRecord = void 0;
                    if (updateAction['afterDrop'].dropRecord) {
                        dropRecord = ej2_base_1.extend([], [], [this.parent.getRecordByID(updateAction['afterDrop'].dropRecord.ganttProperties.taskId)], true)[0];
                    }
                    previousDetails['data'] = [];
                    for (var i = 0; i < updateAction['afterDrop'].data.length; i++) {
                        if (this.parent.viewType === 'ProjectView') {
                            previousDetails['data'].push(ej2_base_1.extend([], [], [this.parent.getRecordByID(updateAction['afterDrop'].data[i].ganttProperties.taskId)], true)[0]);
                        }
                        else {
                            Iif (updateAction['afterDrop'].data[i] !== undefined) {
                                previousDetails['data'].push(ej2_base_1.extend([], [], this.parent.flatData[this.parent.taskIds.indexOf('T' + updateAction['afterDrop'].data[i].ganttProperties.taskId)], true)[0]);
                            }
                        }
                    }
                    previousDetails['dropRecord'] = ej2_base_1.extend([], [], [dropRecord], true)[0];
                    previousDetails['dropPosition'] = updateAction['afterDrop'].dropPosition;
                    previousActions['afterDrop'] = previousDetails;
                    this['findPosition'](rowItems, previousActions, 'beforeDrop');
                }
                else if (updateAction['action'] === 'Indent' || updateAction['action'] === 'Outdent') {
                    previousActions['selectedRowIndexes'] = updateAction['selectedRowIndexes'];
                    previousActions['droppedRecord'] = ej2_base_1.extend([], [], [this.parent.flatData[this.parent.ids.indexOf(updateAction['droppedRecord'].ganttProperties.taskId.toString())]], true)[0];
                    previousActions['modifiedRecord'] = [];
                    this.findPosition(ej2_base_1.extend([], [], [this.parent.flatData[this.parent.ids.indexOf(updateAction['modifiedRecord'][0].data.ganttProperties.taskId.toString())]], true), previousActions, 'modifiedRecord');
                    previousActions['action'] = updateAction['action'];
                }
                else if (updateAction['action'] === 'Delete') {
                    previousActions['action'] = 'Delete';
                    previousActions['deletedRecordsDetails'] = [];
                    this['findPosition'](ej2_base_1.extend([], [], updateAction['deleteRecords'], true), previousActions, 'deletedRecordsDetails');
                }
                else if (updateAction['action'] === 'Add') {
                    previousActions['action'] = 'Add';
                    previousActions['addedRecords'] = [updateAction['deletedRecordsDetails'][0].data];
                }
                else {
                    previousActions['action'] = updateAction['action'];
                    previousActions['modifiedRecords'] = [];
                    for (var i = 0; i < updateAction['modifiedRecords'].length; i++) {
                        var index = void 0;
                        if (this.parent.viewType === 'ProjectView') {
                            index = this.parent.ids.indexOf(updateAction['modifiedRecords'][i].ganttProperties.taskId.toString());
                        }
                        else {
                            if (updateAction['modifiedRecords'][i].hasChildRecords) {
                                index = this.parent.taskIds.indexOf('R' + updateAction['modifiedRecords'][i].ganttProperties.taskId);
                            }
                            else {
                                index = this.parent.taskIds.indexOf('T' + updateAction['modifiedRecords'][i].ganttProperties.taskId);
                            }
                        }
                        previousActions['modifiedRecords'].push(ej2_base_1.extend([], [this.parent.flatData[index]], [], true)[0]);
                    }
                }
                this.getUndoCollection.push(previousActions);
                this.isUndoRedoPerformed = true;
                this.currentAction = updateAction;
                if (updateAction['action'] === 'ZoomIn' || updateAction['action'] === 'ZoomOut' || updateAction['action'] === 'ZoomToFit') {
                    if (updateAction['action'] === 'ZoomToFit') {
                        this.parent.fitToProject();
                    }
                    else {
                        this.parent.timelineSettings.timelineViewMode = updateAction['previousZoomingLevel'].timelineViewMode;
                        this.parent.timelineSettings.timelineUnitSize = updateAction['previousZoomingLevel'].timelineUnitSize;
                        this.parent.timelineSettings.updateTimescaleView = updateAction['previousZoomingLevel'].updateTimescaleView;
                        this.parent.timelineSettings.topTier.unit = updateAction['previousZoomingLevel'].topTier.unit;
                        this.parent.timelineSettings.topTier.count = updateAction['previousZoomingLevel'].topTier.count;
                        this.parent.timelineSettings.topTier.format = updateAction['previousZoomingLevel'].topTier.format;
                        this.parent.timelineSettings.bottomTier.unit = updateAction['previousZoomingLevel'].bottomTier.unit;
                        this.parent.timelineSettings.bottomTier.count = updateAction['previousZoomingLevel'].bottomTier.count;
                        this.parent.timelineSettings.bottomTier.format = updateAction['previousZoomingLevel'].bottomTier.format;
                        this.parent.timelineSettings.weekStartDay = updateAction['previousZoomingLevel'].weekStartDay;
                        this.parent.timelineSettings.weekendBackground = updateAction['previousZoomingLevel'].weekendBackground;
                    }
                }
                else if (updateAction['action'] === 'NextTimeSpan' || updateAction['action'] === 'PreviousTimeSpan') {
                    this.parent.updateProjectDates(updateAction['previousTimelineStartDate'], updateAction['previousTimelineEndDate'], false);
                }
                else if (updateAction['action'] === 'Sorting') {
                    this.isFromUndoRedo = true;
                    this.sortedColumnsLength = 0;
                    if (updateAction['sortColumns'].length === 0) {
                        this.parent.clearSorting();
                    }
                    else {
                        for (var i = 0; i < updateAction['sortColumns'].length; i++) {
                            this.parent.treeGrid.sortByColumn(updateAction['sortColumns'][i]['field'], updateAction['sortColumns'][i]['direction'], (updateAction['sortColumns'].length > 1 ? true : false));
                        }
                    }
                }
                else if (updateAction['action'] === 'ColumnState') {
                    this.isFromUndoRedo = true;
                    for (var i = 0; i < updateAction['showhideColumns'].length; i++) {
                        if (updateAction['showhideColumns'][i].visible) {
                            this.parent.hideColumn(updateAction['showhideColumns'][i].field, 'field');
                        }
                        else {
                            this.parent.showColumn(updateAction['showhideColumns'][i].field, 'field');
                        }
                    }
                }
                else if (updateAction['action'] === 'Filtering') {
                    for (var j = 0; j < updateAction['filteredColumns'].length; j++) {
                        this.isFromUndoRedo = true;
                        this.parent.filterByColumn(updateAction['filteredColumns'][j].field, updateAction['filteredColumns'][j].operator, updateAction['filteredColumns'][j].value, updateAction['filteredColumns'][j].predicate, updateAction['filteredColumns'][j].matchCase, updateAction['filteredColumns'][j].ignoreAccent);
                    }
                }
                else if (updateAction['action'] === 'ColumnReorder') {
                    this.isFromUndoRedo = true;
                    var fromColumn = this.parent.treeGrid.columns[updateAction['fromIndex']]['field'];
                    var toColumn = this.parent.treeGrid.columns[updateAction['toIndex']]['field'];
                    this.parent.reorderColumns(fromColumn, toColumn);
                }
                else if (updateAction['action'] === 'Search') {
                    this.isFromUndoRedo = true;
                    this.parent.search(updateAction['searchString']);
                }
                else if (updateAction['action'] === 'ColumnResize') {
                    this.parent.treeGrid.columns[updateAction['resizedColumn'].index]['width'] = updateAction['resizedColumn'].width;
                    this.parent.treeGrid.refreshColumns();
                }
                else if (updateAction['action'] === 'RowDragAndDrop' || updateAction['action'] === 'TaskbarDragAndDrop') {
                    for (var i = 0; i < updateAction['beforeDrop'].length; i++) {
                        var fromIndex = void 0;
                        var toIndex = void 0;
                        if (this.parent.viewType === 'ProjectView') {
                            fromIndex = this.parent.ids.indexOf(updateAction['beforeDrop'][i].data.ganttProperties.taskId.toString());
                            toIndex = this.parent.ids.indexOf(updateAction['beforeDrop'][i]['id'].toString());
                        }
                        else {
                            fromIndex = this.parent.ids.indexOf('T' + updateAction['beforeDrop'][i].data.ganttProperties.taskId.toString());
                            toIndex = this.parent.taskIds.indexOf(updateAction['beforeDrop'][i]['id'].toString());
                        }
                        this.parent.reorderRows([fromIndex], toIndex, updateAction['beforeDrop'][i].position);
                    }
                }
                else if (updateAction['action'] === 'Indent' || updateAction['action'] === 'Outdent') {
                    this.parent.selectRow(updateAction['selectedRowIndexes'][0]);
                    Eif (updateAction['action'] === 'Indent') {
                        this.parent.indent();
                    }
                    Iif (updateAction['action'] === 'Outdent') {
                        this.parent.outdent();
                    }
                }
                else if (updateAction['action'] === 'Delete') {
                    var isShowDeleteConfirmDialog = ej2_base_1.extend([], [this.parent.editSettings.showDeleteConfirmDialog], [], true)[0];
                    this.parent.editSettings.showDeleteConfirmDialog = false;
                    this.parent.deleteRecord(updateAction['deleteRecords']);
                    this.parent.editSettings.showDeleteConfirmDialog = isShowDeleteConfirmDialog;
                }
                else if (updateAction['action'] === 'Add') {
                    Iif (this.parent.viewType === 'ResourceView' && updateAction['deletedRecordsDetails'].length > 1) {
                        this.parent.editModule.addRecord(ej2_base_1.extend([], [], updateAction['deletedRecordsDetails'], true));
                    }
                    else {
                        var rowIndex = void 0;
                        for (var i = 0; i < updateAction['deletedRecordsDetails'].length; i++) {
                            if (this.parent.viewType === 'ProjectView') {
                                rowIndex = this.parent.ids.indexOf(updateAction['deletedRecordsDetails'][i].id.toString());
                            }
                            else {
                                rowIndex = this.parent.taskIds.indexOf(updateAction['deletedRecordsDetails'][i].id.toString());
                            }
                            var position = void 0;
                            if (updateAction['deletedRecordsDetails'][i].position === 'above') {
                                position = 'Above';
                            }
                            if (updateAction['deletedRecordsDetails'][i].position === 'below') {
                                position = 'Below';
                            }
                            Iif (updateAction['deletedRecordsDetails'][i].position === 'child') {
                                position = 'Child';
                            }
                            if (updateAction['deletedRecordsDetails'][i].position === 'bottom') {
                                position = 'Bottom';
                            }
                            this.parent.editModule.addRecord(updateAction['deletedRecordsDetails'][i].data, position, rowIndex);
                        }
                    }
                }
                else {
                    this.parent.updateRecordByID(updateAction['modifiedRecords'][0]);
                }
                this.isUndoRedoPerformed = false;
                Eif (this.getUndoCollection.length > 0 && this.parent.toolbarModule) {
                    this.parent.toolbarModule.enableItems([this.parent.controlId + '_undo'], true);
                }
                this.getRedoCollection.splice(this.getRedoCollection.length - 1, 1);
                Eif (this.getRedoCollection.length === 0 && this.parent.toolbarModule) {
                    this.redoEnabled = false;
                    this.parent.toolbarModule.enableItems([this.parent.controlId + '_redo'], false);
                }
            }
        };
        UndoRedo.prototype.createUndoCollection = function () {
            if (this.parent['totalUndoAction'] + 1 > this.parent.undoRedoStepsCount && this.getUndoCollection.length === this.parent['totalUndoAction']) {
                this.getUndoCollection.splice(0, 1);
                this.disableRedo();
            }
            if (this.parent.toolbarModule) {
                this.parent.toolbarModule.enableItems([this.parent.controlId + '_undo'], true);
            }
            if (this.getUndoCollection.length === 0) {
                this.getUndoCollection[0] = [];
                if (this.parent['totalUndoAction'] + 1 <= this.parent.undoRedoStepsCount) {
                    this.parent['totalUndoAction']++;
                }
            }
            else if (Object.keys(this['getUndoCollection'][this['getUndoCollection'].length - 1])['length'] > 0) {
                this.getUndoCollection[this.getUndoCollection.length] = [];
                Eif (this.parent['totalUndoAction'] + 1 <= this.parent.undoRedoStepsCount) {
                    this.parent['totalUndoAction']++;
                }
            }
        };
        UndoRedo.prototype.disableRedo = function () {
            this.redoEnabled = false;
            this.getRedoCollection = [];
            Eif (this.parent.toolbarModule) {
                this.parent.toolbarModule.enableItems([this.parent.controlId + '_redo'], false);
            }
        };
        UndoRedo.prototype.findPosition = function (rowItems, records, detail) {
            var _loop_1 = function (i) {
                var record = {};
                record['data'] = rowItems[i];
                if (this_1.parent.viewType === 'ProjectView') {
                    if (!rowItems[i].hasChildRecords && rowItems[i].parentItem) {
                        var parentItem = this_1.parent.getRecordByID(rowItems[i].parentItem.taskId);
                        if (parentItem.childRecords.length > 1) {
                            var recIndex = this_1.parent.ids.indexOf(rowItems[i].ganttProperties.taskId.toString());
                            var previousRecord = this_1.parent.flatData[recIndex - 1];
                            if (previousRecord.parentItem &&
                                previousRecord.parentItem.taskId.toString() === parentItem.ganttProperties.taskId.toString()) {
                                record['position'] = 'below';
                                record['id'] = ej2_base_1.extend([], [this_1.parent.flatData[this_1.parent.ids.indexOf(rowItems[i].ganttProperties.taskId.toString()) - 1].ganttProperties.taskId], [], true)[0];
                            }
                            else {
                                record['position'] = 'above';
                                var currentData = this_1.parent.flatData[this_1.parent.ids.indexOf(rowItems[i].ganttProperties.taskId.toString()) + 1];
                                var index = this_1.parent.ids.indexOf(rowItems[i].ganttProperties.taskId.toString()) + 1;
                                var rowIndex = i;
                                do {
                                    var rowData = rowItems[rowIndex + 1];
                                    if (!rowData ||
                                        (rowData && currentData.ganttProperties.taskId.toString() !==
                                            rowData.ganttProperties.taskId.toString())) {
                                        Eif (currentData && currentData.parentItem) {
                                            record['id'] = ej2_base_1.extend([], [currentData.ganttProperties.taskId], [], true)[0];
                                        }
                                        else {
                                            record['id'] = ej2_base_1.extend([], [rowItems[i].parentItem.taskId], [], true)[0];
                                            record['position'] = 'child';
                                        }
                                    }
                                    else {
                                        rowIndex++;
                                        index++;
                                        currentData = this_1.parent.flatData[index];
                                    }
                                } while (!record['id']);
                            }
                        }
                        else {
                            record['position'] = 'child';
                            record['id'] = ej2_base_1.extend([], [parentItem.ganttProperties.taskId], [], true)[0];
                        }
                    }
                    else if (!rowItems[i].hasChildRecords && !rowItems[i].parentItem) {
                        if (this_1.parent.ids.indexOf(rowItems[i].ganttProperties.taskId.toString()) === this_1.parent.ids.length - 1) {
                            record['position'] = 'below';
                        }
                        else {
                            record['position'] = 'above';
                        }
                        var parentIndex = void 0;
                        var currentData = void 0;
                        var prevInd = void 0;
                        for (var k = 0; k < this_1.parent.treeGrid.parentData.length; k++) {
                            Eif (this_1.parent.treeGrid.parentData[k]['ganttProperties'].taskId.toString() === rowItems[i].ganttProperties.taskId.toString()) {
                                parentIndex = k;
                                currentData = this_1.parent.treeGrid.parentData[k + 1];
                                prevInd = k + 1;
                                break;
                            }
                        }
                        var rowIndex = i;
                        do {
                            var rowData = rowItems[rowIndex + 1];
                            Eif (!rowData || (rowData && currentData['ganttProperties'].taskId.toString() !== rowData.ganttProperties.taskId.toString())) {
                                if (currentData) {
                                    record['id'] = ej2_base_1.extend([], [currentData['ganttProperties'].taskId], [], true)[0];
                                }
                                else {
                                    currentData = this_1.parent.treeGrid.parentData[parentIndex - 1];
                                    Eif (!currentData) {
                                        currentData = this_1.parent.treeGrid.parentData[parentIndex];
                                    }
                                    record['id'] = ej2_base_1.extend([], [currentData['ganttProperties'].taskId], [], true)[0];
                                }
                            }
                            else {
                                rowIndex++;
                                prevInd++;
                                currentData = this_1.parent.treeGrid.parentData[prevInd];
                            }
                        } while (!record['id']);
                    }
                    else if (rowItems[i].hasChildRecords && !rowItems[i].parentItem) {
                        var parentIndex = void 0;
                        var currentData = void 0;
                        var prevInd = void 0;
                        for (var k = 0; k < this_1.parent.treeGrid.parentData.length; k++) {
                            if (this_1.parent.treeGrid.parentData[k]['ganttProperties'].taskId.toString() === rowItems[i].ganttProperties.taskId.toString()) {
                                parentIndex = k;
                                currentData = this_1.parent.treeGrid.parentData[k + 1];
                                prevInd = k + 1;
                                break;
                            }
                        }
                        Eif (parentIndex !== -1) {
                            if (parentIndex === 0) {
                                record['position'] = 'above';
                                var rowIndex = i;
                                do {
                                    var rowData = rowItems[rowIndex + 1];
                                    Eif (!rowData || (rowData && currentData['ganttProperties'].taskId.toString() !== rowData.ganttProperties.taskId.toString())) {
                                        Iif (!currentData) {
                                            currentData = this_1.parent.treeGrid.parentData[parentIndex];
                                        }
                                        record['id'] = ej2_base_1.extend([], [currentData['ganttProperties'].taskId], [], true)[0];
                                    }
                                    else {
                                        rowIndex++;
                                        prevInd++;
                                        currentData = this_1.parent.treeGrid.parentData[prevInd];
                                    }
                                } while (!record['id']);
                            }
                            else {
                                record['position'] = 'below';
                                record['id'] = ej2_base_1.extend([], [this_1.parent.treeGrid.parentData[parentIndex - 1].ganttProperties.taskId], [], true)[0];
                            }
                        }
                    }
                    else Eif (rowItems[i].hasChildRecords && rowItems[i].parentItem) {
                        var parentItem = this_1.parent.getRecordByID(rowItems[i].parentItem.taskId);
                        if (parentItem.childRecords.length === 1) {
                            record['position'] = 'child';
                            record['id'] = ej2_base_1.extend([], [rowItems[i].parentItem.taskId], [], true)[0];
                        }
                        else {
                            var childIndex = void 0;
                            for (var k = 0; k < parentItem.childRecords.length; k++) {
                                if (parentItem.childRecords[i].ganttProperties.taskId.toString() ===
                                    rowItems[i].ganttProperties.taskId.toString()) {
                                    childIndex = k;
                                    break;
                                }
                            }
                            if (!ej2_base_1.isNullOrUndefined(childIndex)) {
                                Eif (childIndex === 0) {
                                    record['position'] = 'above';
                                    record['id'] = ej2_base_1.extend([], [parentItem.childRecords[childIndex + 1].ganttProperties.taskId], [], true)[0];
                                }
                                else {
                                    record['position'] = 'below';
                                    record['id'] = ej2_base_1.extend([], [parentItem.childRecords[childIndex - 1].ganttProperties.taskId], [], true)[0];
                                }
                            }
                        }
                    }
                }
                else {
                    if (rowItems[i].parentItem) {
                        var parentRecord = void 0;
                        if (rowItems[i].parentItem.index) {
                            parentRecord = this_1.parent.flatData[rowItems[i].parentItem.index];
                        }
                        else {
                            parentRecord = this_1.parent.flatData[this_1.parent.ids.indexOf(rowItems[i].parentItem.taskId)];
                        }
                        if (parentRecord.childRecords.length === 1) {
                            record['position'] = 'bottom';
                            record['id'] = 'R' + parentRecord.ganttProperties.taskId;
                            if (detail === 'deletedIndexes') {
                                record['position'] = 'child';
                                record['index'] = parentRecord.index;
                            }
                        }
                        else {
                            var currentIndex = void 0;
                            for (var j = 0; j < parentRecord.childRecords.length; j++) {
                                if (parentRecord.childRecords[j].ganttProperties.taskId.toString() ===
                                    rowItems[i].ganttProperties.taskId.toString()) {
                                    currentIndex = j;
                                    break;
                                }
                            }
                            var previousRecord = parentRecord.childRecords[currentIndex - 1];
                            if (previousRecord && previousRecord.parentItem && previousRecord.parentUniqueID === parentRecord.uniqueID) {
                                record['position'] = 'below';
                                record['id'] = ej2_base_1.extend([], ['T' + this_1.parent.flatData[this_1.parent.taskIds.indexOf('T' + rowItems[i].ganttProperties.taskId.toString()) - 1].ganttProperties.taskId], [], true)[0];
                                Iif (detail === 'deletedIndexes') {
                                    record['index'] = this_1.parent.taskIds.indexOf('T' + rowItems[i].ganttProperties.taskId.toString()) - 1;
                                }
                            }
                            else {
                                var index = void 0;
                                Eif (currentIndex !== parentRecord.childRecords.length - 1) {
                                    record['position'] = 'above';
                                    Eif (currentIndex === 0 && parentRecord.childRecords[1]) {
                                        index = parentRecord.childRecords[1].index;
                                    }
                                    else if (parentRecord.childRecords[currentIndex - 1]) {
                                        index = parentRecord.childRecords[currentIndex - 1].index;
                                    }
                                    var currentData = this_1.parent.flatData[index];
                                    var recIndex = index;
                                    var rowIndex = i;
                                    do {
                                        var rowData = rowItems[rowIndex + 1];
                                        if (!rowData ||
                                            (rowData && currentData.ganttProperties.taskId.toString() !==
                                                rowData.ganttProperties.taskId.toString())) {
                                            if (currentData.parentItem) {
                                                record['id'] = ej2_base_1.extend([], ['T' + currentData.ganttProperties.taskId], [], true)[0];
                                                if (detail === 'deletedIndexes') {
                                                    record['index'] = ej2_base_1.extend([], [currentData.index], [], true)[0];
                                                    Eif (currentIndex === 0 && parentRecord.childRecords[1].ganttProperties.taskId ===
                                                        currentData.ganttProperties.taskId) {
                                                        record['index'] = record['index'] - 1;
                                                    }
                                                }
                                            }
                                            else {
                                                record['id'] = ej2_base_1.extend([], ['R' + rowItems[i].parentItem.taskId], [], true)[0];
                                                record['position'] = 'child';
                                                Iif (detail === 'deletedIndexes') {
                                                    record['index'] = rowItems[i].parentItem.index;
                                                }
                                            }
                                        }
                                        else {
                                            rowIndex++;
                                            recIndex++;
                                            currentData = this_1.parent.flatData[recIndex];
                                        }
                                    } while (!record['id']);
                                }
                                else {
                                    if (currentIndex === parentRecord.childRecords.length - 1) {
                                        record['position'] = 'below';
                                    }
                                    else {
                                        record['position'] = 'above';
                                    }
                                    record['id'] = 'T' + parentRecord.childRecords[currentIndex - 1].ganttProperties.taskId;
                                    if (detail === 'deletedIndexes') {
                                        record['index'] = parentRecord.childRecords[currentIndex - 1].index;
                                    }
                                }
                            }
                        }
                    }
                    else {
                        var parentData = this_1.parent.treeGrid.parentData.filter(function (parentData) {
                            return parentData.ganttProperties.taskId === rowItems[i].ganttProperties.taskId;
                        })[0];
                        var parentDataIndex = this_1.parent.treeGrid.parentData.indexOf(parentData);
                        if (parentDataIndex === 0) {
                            record['position'] = 'above';
                            var currentData = void 0;
                            var prevInd = void 0;
                            for (var k = 0; k < this_1.parent.treeGrid.parentData.length; k++) {
                                Eif (this_1.parent.treeGrid.parentData[k]['ganttProperties'].taskId === rowItems[i].ganttProperties.taskId) {
                                    currentData = this_1.parent.treeGrid.parentData[k + 1];
                                    prevInd = k + 1;
                                    break;
                                }
                            }
                            var rowIndex = i;
                            do {
                                var rowData = rowItems[rowIndex + 1];
                                if (!rowData || (rowData && currentData['ganttProperties'].taskId !== rowData.ganttProperties.taskId)) {
                                    record['id'] = 'R' + currentData['ganttProperties'].taskId;
                                    Iif (detail === 'deletedIndexes') {
                                        record['index'] = currentData['index'];
                                    }
                                }
                                else {
                                    rowIndex++;
                                    prevInd++;
                                    currentData = this_1.parent.treeGrid.parentData[prevInd];
                                }
                            } while (!record['id']);
                        }
                        else {
                            record['position'] = 'below';
                            record['id'] = 'R' + this_1.parent.treeGrid.parentData[parentDataIndex - 1]['ganttProperties']['taskId'];
                            Iif (detail === 'deletedIndexes') {
                                record['index'] = this_1.parent.treeGrid.parentData[parentDataIndex - 1]['index'];
                            }
                        }
                    }
                }
                if (detail === 'deletedIndexes') {
                    var parent_1 = this_1.parent.getTaskByUniqueID(record['data'].parentUniqueID);
                    if (this_1.parent.editModule.dialogModule.ganttResources.length === 0 && records[detail].indexOf(record) === -1) {
                        records[detail].push(record);
                    }
                    else {
                        for (var j = 0; j < this_1.parent.editModule.dialogModule.ganttResources.length; j++) {
                            if (this_1.parent.editModule.dialogModule.ganttResources[j][this_1.parent.resourceFields.id] !==
                                parent_1.ganttProperties.taskId && records[detail].indexOf(record) === -1) {
                                records[detail].push(record);
                            }
                        }
                    }
                }
                else {
                    records[detail].push(record);
                }
            };
            var this_1 = this;
            for (var i = 0; i < rowItems.length; i++) {
                _loop_1(i);
            }
        };
        UndoRedo.prototype.getModuleName = function () {
            return 'undoRedo';
        };
        UndoRedo.prototype.destroy = function () {
            if (!this.parent.enableUndoRedo && this.parent.undoRedoModule) {
                this.parent.undoRedoModule = undefined;
            }
        };
        return UndoRedo;
    }());
    exports.UndoRedo = UndoRedo;
});