all files / actions/ toolbar.js

94.44% Statements 323/342
91.22% Branches 270/296
96.55% Functions 28/29
94.44% Lines 323/342
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   821× 821×     821× 821× 821×   27962×   824× 824× 823× 823×     820×   823×     823× 16460× 16460× 16460× 16460× 823× 823×     15637× 15637×   16460×                 16460× 320× 16×   320× 16×       823× 823×               818×                       823×             823× 823×           823× 823× 823× 823× 823×   823× 823× 823× 519×   823× 525×   823× 823× 6005× 290×     823×               820×   823× 352× 352× 352×     823× 823×               352× 290× 290× 290×             12×   12×           366×     823× 823× 823× 823× 6005×   290×     823× 290× 290×   823× 6005× 6005× 5971×     34×     823×   34× 34×   5971×   109× 109× 109× 109× 109× 109×         109× 109×       109×           109×                       17× 17× 17×     17× 17×   17×   14× 14×         14×                           11× 11×       13× 13×           11× 11×         2396× 2396× 2396× 2396× 2396× 2396× 2396×               2396× 2396× 2396× 2382× 862×     2396×   2396× 2396× 17× 17×         17×       2396× 2396×   2396×   2396× 2222×   2222× 2222× 2222×   2222× 1536× 1536×     686×   105× 105×     581× 581×   258× 258×   323× 323× 323×       2222×   2222× 17×     17× 17× 17×                         2222× 853×     1369×   2222×   615× 615× 615× 615× 4493×   1898×         1607× 1607× 12883×   6011×           174× 174× 174× 174× 174× 174× 174×   2396× 10299× 10299× 68312× 9449× 9449×     10299× 10299×     2396× 11307× 11307× 49487× 6586× 6586×     11307× 11307×       1297× 2167× 2167× 2167× 714×       825× 746×   79× 79×   79× 79× 12×   79×        
define(["require", "exports", "@syncfusion/ej2-navigations", "@syncfusion/ej2-base", "../base/css-constants", "../base/constant", "@syncfusion/ej2-inputs"], function (require, exports, ej2_navigations_1, ej2_base_1, cls, events, ej2_inputs_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Toolbar = (function () {
        function Toolbar(parent) {
            this.predefinedItems = {};
            this.items = ['Add', 'Edit', 'Update', 'Delete', 'Cancel', 'ExpandAll', 'CollapseAll', 'Search',
                'PrevTimeSpan', 'NextTimeSpan', 'ZoomIn', 'ZoomOut', 'ZoomToFit', 'ExcelExport',
                'CsvExport', 'PdfExport', 'Indent', 'Outdent', 'CriticalPath'];
            this.parent = parent;
            this.id = this.parent.element.id;
            this.parent.on('ui-toolbarupdate', this.propertyChanged, this);
        }
        Toolbar.prototype.getModuleName = function () {
            return 'toolbar';
        };
        Toolbar.prototype.renderToolbar = function () {
            var toolbarItems = this.parent.toolbar || [];
            if (toolbarItems.length > 0) {
                this.element = ej2_base_1.createElement('div', { id: this.parent.controlId + '_Gantt_Toolbar', className: cls.toolbar });
                if (this.parent.treeGrid.grid.headerModule) {
                    this.parent.element.insertBefore(this.element, this.parent.treeGridPane.offsetParent);
                }
                else {
                    this.parent.element.appendChild(this.element);
                }
                var preItems = ['Add', 'Edit', 'Update', 'Delete', 'Cancel', 'ExpandAll', 'CollapseAll',
                    'PrevTimeSpan', 'NextTimeSpan', 'ZoomIn', 'ZoomOut', 'ZoomToFit', 'ExcelExport', 'CsvExport',
                    'PdfExport', 'Indent', 'Outdent', 'CriticalPath', 'Undo', 'Redo'];
                for (var _i = 0, preItems_1 = preItems; _i < preItems_1.length; _i++) {
                    var item = preItems_1[_i];
                    var itemStr = void 0;
                    var localeName = void 0;
                    if (item === 'CriticalPath') {
                        itemStr = 'critical-path';
                        localeName = 'criticalPath';
                    }
                    else {
                        itemStr = item.toLowerCase();
                        localeName = item[0].toLowerCase() + item.slice(1);
                    }
                    this.predefinedItems[item] = {
                        id: this.parent.element.id + '_' + itemStr, prefixIcon: 'e-' + itemStr,
                        text: this.parent.isAdaptive ? '' : this.parent.localeObj.getConstant(localeName),
                        tooltipText: this.parent.localeObj.getConstant(localeName) + ((localeName === 'add' ||
                            localeName === 'edit' || localeName === 'delete') ? this.parent.localeObj.getConstant('task') :
                            (localeName === 'expandAll' || localeName === 'collapseAll') ?
                                this.parent.localeObj.getConstant('tasks') : ''),
                        align: this.parent.isAdaptive ? 'Right' : 'Left'
                    };
                    if (this.parent.enableRtl) {
                        if (item === 'PrevTimeSpan') {
                            this.predefinedItems[item].prefixIcon = 'e-nexttimespan';
                        }
                        if (item === 'NextTimeSpan') {
                            this.predefinedItems[item].prefixIcon = 'e-prevtimespan';
                        }
                    }
                }
                var searchLocalText = this.parent.localeObj.getConstant('search');
                if (this.parent.isAdaptive) {
                    this.predefinedItems.Search = {
                        id: this.id + '_searchbutton',
                        prefixIcon: 'e-search-icon',
                        tooltipText: searchLocalText,
                        align: 'Right'
                    };
                }
                else {
                    this.predefinedItems.Search = {
                        id: this.id + '_search',
                        template: '<div class="e-input-group e-search" role="search">' +
                            '<input id="' + this.id + '_searchbar" class="e-input" name="input" type="search"' +
                            'placeholder= \"' + searchLocalText + '\"/>' +
                            '<span id="' + this.id + '_searchbutton" class="e-input-group-icon e-search-icon e-icons"' +
                            'tabindex="-1" title="' + searchLocalText + '" aria-label= "search" role="button"></span>' +
                            '</div>',
                        tooltipText: searchLocalText,
                        align: 'Right', cssClass: 'e-search-wrapper'
                    };
                }
                this.createToolbar();
            }
        };
        Toolbar.prototype.addReactToolbarPortals = function (args) {
            Iif (this.parent.isReact && args) {
                this.parent.portals = this.parent.portals.concat(args);
                this.parent.renderTemplates();
            }
        };
        Toolbar.prototype.createToolbar = function () {
            var items = this.getItems();
            this.toolbar = new ej2_navigations_1.Toolbar({
                items: items,
                enableRtl: this.parent.enableRtl,
                clicked: this.toolbarClickHandler.bind(this),
                height: this.parent.isAdaptive ? 48 : 'auto'
            });
            this.toolbar.isStringTemplate = true;
            this.toolbar.isReact = this.parent.isReact;
            this.toolbar.on('render-react-toolbar-template', this.addReactToolbarPortals, this);
            this.toolbar.appendTo(this.element);
            if (this.parent.treeGrid.grid && this.parent.isReact) {
                (this.parent.treeGrid.grid).portals = this.parent.portals;
            }
            var cancelItem = this.element.querySelector('#' + this.parent.element.id + '_cancel');
            var updateItem = this.element.querySelector('#' + this.parent.element.id + '_update');
            if (cancelItem) {
                ej2_base_1.addClass([cancelItem], cls.focusCell);
            }
            if (updateItem) {
                ej2_base_1.addClass([updateItem], cls.focusCell);
            }
            var template = false;
            this.parent.toolbar.map(function (e) {
                if (e === 'Search') {
                    template = true;
                }
            });
            if (this.parent.isAdaptive && template) {
                this.element.insertBefore(this.getSearchBarElement(), this.element.childNodes[0]);
                this.searchElement = this.element.querySelector('#' + this.parent.element.id + '_searchbar');
                var textObj = new ej2_inputs_1.TextBox({
                    placeholder: this.parent.localeObj.getConstant('search'),
                    enableRtl: this.parent.enableRtl,
                    floatLabelType: 'Never',
                    showClearButton: true
                });
                textObj.appendTo(this.searchElement);
            }
            else {
                this.searchElement = this.element.querySelector('#' + this.parent.element.id + '_searchbar');
            }
            if (this.parent.filterModule) {
                this.wireEvent();
                Eif (this.parent.searchSettings) {
                    this.updateSearchTextBox();
                }
            }
            this.enableItems([this.parent.controlId + '_redo', this.parent.controlId + '_undo'], false);
            if (this.parent.readOnly) {
                this.enableItems([this.parent.element.id + '_add', this.parent.element.id + '_update', this.parent.element.id + '_delete',
                    this.parent.element.id + '_cancel', this.parent.element.id + '_indent', this.parent.element.id + '_outdent'], false);
            }
        };
        Toolbar.prototype.getSearchBarElement = function () {
            var _this = this;
            var div = ej2_base_1.createElement('div', { className: 'e-adaptive-searchbar', styles: 'display: none' });
            var textbox = ej2_base_1.createElement('input', { attrs: { type: 'text' }, id: this.parent.element.id + '_searchbar' });
            var span = ej2_base_1.createElement('span', { className: 'e-backarrowspan e-icons' });
            span.onclick = function () {
                div.style.display = 'none';
                _this.element.childNodes[1].style.display = 'block';
            };
            div.appendChild(span);
            div.appendChild(textbox);
            return div;
        };
        Toolbar.prototype.wireEvent = function () {
            if (this.searchElement) {
                ej2_base_1.EventHandler.add(this.searchElement, 'keyup', this.keyUpHandler, this);
                ej2_base_1.EventHandler.add(this.searchElement, 'focus', this.focusHandler, this);
                ej2_base_1.EventHandler.add(this.searchElement, 'blur', this.blurHandler, this);
            }
        };
        Toolbar.prototype.propertyChanged = function (property) {
            var module = ej2_base_1.getValue('module', property);
            Iif (module !== this.getModuleName() || !this.parent.toolbar) {
                return;
            }
            if (this.element && this.element.parentNode) {
                ej2_base_1.remove(this.element);
            }
            this.renderToolbar();
            this.refreshToolbarItems();
        };
        Toolbar.prototype.unWireEvent = function () {
            if (this.searchElement) {
                ej2_base_1.EventHandler.remove(this.searchElement, 'keyup', this.keyUpHandler);
                ej2_base_1.EventHandler.remove(this.searchElement, 'focus', this.focusHandler);
                ej2_base_1.EventHandler.remove(this.searchElement, 'blur', this.blurHandler);
                this.searchElement = null;
            }
            this.parent.off('ui-toolbarupdate', this.propertyChanged);
        };
        Toolbar.prototype.keyUpHandler = function (e) {
            Eif (e.keyCode === 13 && this.parent.searchSettings.key !== this.searchElement.value) {
                this.parent.searchSettings.key = this.searchElement.value;
                this.parent.dataBind();
            }
        };
        Toolbar.prototype.focusHandler = function (e) {
            e.target.parentElement.classList.add('e-input-focus');
        };
        Toolbar.prototype.blurHandler = function (e) {
            e.target.parentElement.classList.remove('e-input-focus');
        };
        Toolbar.prototype.updateSearchTextBox = function () {
            if (this.searchElement && this.searchElement.value !== this.parent.searchSettings.key) {
                this.searchElement.value = this.parent.searchSettings.key;
            }
        };
        Toolbar.prototype.getItems = function () {
            var items = [];
            var toolbarItems = this.parent.toolbar;
            var searchIndex = -1;
            toolbarItems.forEach(function (item, index) {
                if ((typeof (item) === 'string' && item === 'Search') ||
                    ((typeof (item) === 'object') && item.text === 'Search')) {
                    searchIndex = index;
                }
            });
            if (searchIndex > -1) {
                var searchItem = toolbarItems.splice(searchIndex, 1);
                toolbarItems.push(searchItem[0]);
            }
            for (var _i = 0, toolbarItems_1 = toolbarItems; _i < toolbarItems_1.length; _i++) {
                var item = toolbarItems_1[_i];
                if (typeof item === 'string') {
                    items.push(this.getItemObject(item));
                }
                else {
                    items.push(this.getItem(item));
                }
            }
            return items;
        };
        Toolbar.prototype.getItem = function (itemObject) {
            var item = this.predefinedItems[itemObject.text];
            return item ? ej2_base_1.extend(item, item, itemObject) : itemObject;
        };
        Toolbar.prototype.getItemObject = function (itemName) {
            return this.predefinedItems[itemName] || { text: itemName, id: this.id + '_' + itemName };
        };
        Toolbar.prototype.toolbarClickHandler = function (arg) {
            var _this = this;
            var gObj = this.parent;
            var gID = this.id;
            this.parent.isToolBarClick = false;
            ej2_base_1.extend(arg, { cancel: false });
            if (arg.item['properties'].id === this.parent.element.id + '_pdfexport' || arg.item['properties'].id === this.parent.element.id + '_critical-path') {
                if (!ej2_base_1.isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === 'Shimmer') {
                    this.parent.showMaskRow();
                }
                else {
                    this.parent.showSpinner();
                }
            }
            gObj.trigger(events.toolbarClick, arg, function (args) {
                Iif (args.cancel) {
                    return;
                }
                else {
                    if (_this.parent.isAdaptive === true) {
                        if (args.item.id === gID + '_edit' || args.item.id === gID + '_add' || args.item.id === gID + '_delete'
                            || args.item.id === gID + '_searchbutton' || args.item.id === gID + '_expandall'
                            || args.item.id === gID + '_collapseall') {
                            Eif (_this.parent.selectionModule && _this.parent.selectionSettings.type === 'Multiple') {
                                _this.parent.selectionModule.hidePopUp();
                                document.getElementsByClassName('e-gridpopup')[0].style.display = 'none';
                            }
                        }
                    }
                    switch (!ej2_base_1.isNullOrUndefined(args.item) && args.item.id) {
                        case gID + '_edit':
                            Eif (gObj.editModule && gObj.editSettings.allowEditing) {
                                gObj.editModule.dialogModule.openToolbarEditDialog();
                            }
                            break;
                        case gID + '_indent':
                            Eif (gObj.editModule && gObj.selectionModule.getSelectedRecords().length) {
                                gObj.indent();
                            }
                            break;
                        case gID + '_critical-path':
                            if (gObj.enableCriticalPath) {
                                gObj.enableCriticalPath = false;
                            }
                            else {
                                gObj.enableCriticalPath = true;
                            }
                            break;
                        case gID + '_outdent':
                            Eif (gObj.editModule && gObj.selectionModule.getSelectedRecords().length) {
                                gObj.outdent();
                            }
                            break;
                        case gID + '_update':
                            gObj.editModule.cellEditModule.isCellEdit = false;
                            gObj.treeGrid.grid.saveCell();
                            break;
                        case gID + '_cancel':
                            gObj.cancelEdit();
                            break;
                        case gID + '_add':
                            Eif (gObj.editModule && gObj.editSettings.allowAdding) {
                                gObj.editModule.dialogModule.openAddDialog();
                            }
                            break;
                        case gID + '_delete':
                            Eif (_this.parent.selectionModule && _this.parent.editModule) {
                                if ((_this.parent.selectionSettings.mode !== 'Cell' && _this.parent.selectionModule.selectedRowIndexes.length)
                                    || (_this.parent.selectionSettings.mode === 'Cell' &&
                                        _this.parent.selectionModule.getSelectedRowCellIndexes().length)) {
                                    _this.parent.editModule.startDeleteAction();
                                }
                            }
                            break;
                        case gID + '_search':
                            {
                                var searchButtonId = ej2_base_1.getValue('originalEvent.target.id', args);
                                Eif (searchButtonId === _this.parent.element.id + '_searchbutton' && _this.parent.filterModule) {
                                    var keyVal = _this.element.querySelector('#' + _this.parent.element.id + '_searchbar').value;
                                    if (_this.parent.searchSettings.key !== keyVal) {
                                        _this.parent.searchSettings.key = keyVal;
                                        _this.parent.dataBind();
                                    }
                                }
                                break;
                            }
                        case gID + '_searchbutton':
                            {
                                var adaptiveSearchbar = _this.element.querySelector('.e-adaptive-searchbar');
                                adaptiveSearchbar.parentElement.childNodes[1].style.display = 'none';
                                adaptiveSearchbar.style.display = 'block';
                                break;
                            }
                        case gID + '_expandall':
                            _this.parent.ganttChartModule.expandCollapseAll('expand');
                            _this.parent.isCollapseAll = false;
                            break;
                        case gID + '_collapseall':
                            _this.parent.ganttChartModule.expandCollapseAll('collapse');
                            _this.parent.isCollapseAll = true;
                            break;
                        case gID + '_prevtimespan':
                            _this.parent.previousTimeSpan();
                            break;
                        case gID + '_nexttimespan':
                            _this.parent.nextTimeSpan();
                            break;
                        case gID + '_zoomin':
                            _this.zoomIn();
                            break;
                        case gID + '_zoomout':
                            _this.zoomOut();
                            break;
                        case gID + '_zoomtofit':
                            _this.zoomToFit();
                            break;
                        case gID + '_undo':
                            _this.parent.undo();
                            break;
                        case gID + '_redo':
                            _this.parent.redo();
                            break;
                    }
                }
            });
        };
        Toolbar.prototype.zoomIn = function () {
            this.parent.timelineModule.processZooming(true);
            this.parent.timelineModule.isZooming = false;
        };
        Toolbar.prototype.zoomToFit = function () {
            if (this.parent.timelineModule.isZoomIn) {
                this.parent.timelineModule.isZoomIn = false;
            }
            this.parent.timelineModule.processZoomToFit();
            this.parent.ganttChartModule.updateScrollLeft(0);
            this.parent.timelineModule.isZoomToFit = false;
        };
        Toolbar.prototype.zoomOut = function () {
            this.parent.timelineModule.processZooming(false);
            this.parent.timelineModule.isZooming = false;
        };
        Toolbar.prototype.refreshToolbarItems = function (args) {
            var gObj = this.parent;
            var enableItems = [];
            var disableItems = [];
            var edit = gObj.editSettings;
            var gID = this.id;
            var ind = gObj.selectedRowIndex;
            Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                for (var i = 0; i < gObj.updatedRecords.length; i++) {
                    if (gObj.updatedRecords[i].index === ind) {
                        ind = i;
                        break;
                    }
                }
            }
            var previousGanttRecord;
            var isSelected = false;
            if (gObj.selectionModule) {
                if (gObj.selectionModule.getSelectedRecords().length === 1 || gObj.selectionModule.getSelectedRowCellIndexes().length === 1) {
                    isSelected = true;
                }
            }
            if (gObj.selectionModule && gObj.selectionSettings.type === 'Multiple' && gObj.selectionModule.selectedRowIndexes.length > 1) {
                isSelected = false;
            }
            var isPersist = false;
            if (gObj.selectionModule && gObj.selectionSettings.persistSelection) {
                var selectedRecords = gObj.selectionModule.getSelectedRecords().length;
                if (gObj.selectionSettings.persistSelection && selectedRecords === 1) {
                    for (var i = 0; i < selectedRecords; i++) {
                        var index = gObj.currentViewData.indexOf(gObj.selectionModule.getSelectedRecords()[i]);
                        Iif (index === -1) {
                            isPersist = true;
                        }
                    }
                }
                Iif (isPersist) {
                    isSelected = false;
                }
            }
            var toolbarItems = this.toolbar ? this.toolbar.items : [];
            var toolbarDefaultItems = [gID + '_add', gID + '_edit', gID + '_delete',
                gID + '_update', gID + '_cancel', gID + '_indent', gID + '_outdent'];
            var isResouceParent = (this.parent.viewType === 'ResourceView' && ej2_base_1.getValue('data.level', args) !== 0
                || this.parent.viewType === 'ProjectView');
            if (!ej2_base_1.isNullOrUndefined(this.parent.editModule)) {
                var touchEdit = gObj.editModule.taskbarEditModule ?
                    gObj.editModule.taskbarEditModule.touchEdit : false;
                var hasData = gObj.flatData && gObj.flatData.length;
                edit.allowAdding && !touchEdit ? enableItems.push(gID + '_add') : disableItems.push(gID + '_add');
                edit.allowEditing && isResouceParent && hasData && isSelected && !touchEdit ?
                    enableItems.push(gID + '_edit') : disableItems.push(gID + '_edit');
                if (!edit.allowEditing || ind === 0 || ind === -1 || !hasData || !isSelected || this.parent.viewType === 'ResourceView') {
                    disableItems.push(gID + '_indent');
                    disableItems.push(gID + '_outdent');
                }
                else {
                    if (!ej2_base_1.isNullOrUndefined(gObj.updatedRecords[ind]) &&
                        gObj.updatedRecords[ind].level === 0 && hasData && !touchEdit) {
                        enableItems.push(gID + '_indent');
                        disableItems.push(gID + '_outdent');
                    }
                    else {
                        previousGanttRecord = gObj.updatedRecords[ind - 1];
                        if (!ej2_base_1.isNullOrUndefined(gObj.updatedRecords[ind]) &&
                            (gObj.updatedRecords[ind].level - previousGanttRecord.level === 1) && ind !== -1) {
                            disableItems.push(gID + '_indent');
                            enableItems.push(gID + '_outdent');
                        }
                        else Eif (ind !== -1) {
                            enableItems.push(gID + '_indent');
                            enableItems.push(gID + '_outdent');
                        }
                    }
                }
                var isDeleteSelected = gObj.selectionModule ? gObj.selectionModule.getSelectedRecords().length > 0 ||
                    gObj.selectionModule.getSelectedRowCellIndexes().length > 0 ? true : false : false;
                if (gObj.selectionModule && gObj.selectionSettings.persistSelection) {
                    Iif (isPersist) {
                        isDeleteSelected = false;
                    }
                    var selectedRecords = gObj.selectionModule.getSelectedRecords();
                    var selectedRecordsCount = selectedRecords.length;
                    Iif (gObj.selectionSettings.persistSelection && selectedRecordsCount > 1) {
                        for (var i = 0; i < selectedRecordsCount; i++) {
                            var index = gObj.currentViewData.indexOf(selectedRecords[i]);
                            if (index > -1) {
                                isDeleteSelected = true;
                                break;
                            }
                            else {
                                isDeleteSelected = false;
                            }
                        }
                    }
                }
                if (edit.allowDeleting && hasData && isDeleteSelected && !touchEdit) {
                    enableItems.push(gID + '_delete');
                }
                else {
                    disableItems.push(gID + '_delete');
                }
                if (gObj.editSettings.mode === 'Auto' && !ej2_base_1.isNullOrUndefined(gObj.editModule.cellEditModule)
                    && gObj.editModule.cellEditModule.isCellEdit) {
                    enableItems = [];
                    enableItems.push(gID + '_update', gID + '_cancel');
                    disableItems = [];
                    for (var t = 0; t < toolbarItems.length; t++) {
                        if (toolbarItems[t].id !== gID + '_update' && toolbarItems[t].id !== gID + '_cancel' &&
                            toolbarDefaultItems.indexOf(toolbarItems[t].id) !== -1) {
                            disableItems.push(toolbarItems[t].id);
                        }
                    }
                }
                else {
                    disableItems.push(gID + '_update', gID + '_cancel');
                    for (var t = 0; t < toolbarItems.length; t++) {
                        if (enableItems.indexOf(toolbarItems[t].id) === -1 &&
                            disableItems.indexOf(toolbarItems[t].id) === -1) {
                            enableItems.push(toolbarItems[t].id);
                        }
                    }
                }
            }
            else {
                disableItems.push(gID + '_delete');
                disableItems.push(gID + '_add');
                disableItems.push(gID + '_edit');
                disableItems.push(gID + '_update');
                disableItems.push(gID + '_cancel');
                disableItems.push(gID + '_indent');
                disableItems.push(gID + '_outdent');
            }
            for (var e = 0; e < enableItems.length; e++) {
                var index = void 0;
                for (var t = 0; t < toolbarItems.length; t++) {
                    if (toolbarItems[t].id === enableItems[e]) {
                        index = t;
                        break;
                    }
                }
                Eif (toolbarItems.length > 0) {
                    this.toolbar.hideItem(index, false);
                }
            }
            for (var d = 0; d < disableItems.length; d++) {
                var index = void 0;
                for (var t = 0; t < toolbarItems.length; t++) {
                    if (toolbarItems[t].id === disableItems[d]) {
                        index = t;
                        break;
                    }
                }
                Eif (toolbarItems.length > 0) {
                    this.toolbar.hideItem(index, true);
                }
            }
        };
        Toolbar.prototype.enableItems = function (items, isEnable) {
            for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
                var item = items_1[_i];
                var element = this.element.querySelector('#' + item);
                if (element) {
                    this.toolbar.enableItems(element.parentElement, isEnable);
                }
            }
        };
        Toolbar.prototype.destroy = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            Eif (this.toolbar) {
                this.toolbar.off('render-react-toolbar-template', this.addReactToolbarPortals);
            }
            this.toolbar.destroy();
            if (this.parent.filterModule) {
                this.unWireEvent();
            }
            ej2_base_1.remove(this.element);
        };
        return Toolbar;
    }());
    exports.Toolbar = Toolbar;
});