all files / actions/ action.js

94.72% Statements 287/303
85.29% Branches 145/170
90.91% Functions 30/33
95.62% Lines 284/297
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   209× 209× 209× 209× 209× 209× 209× 209× 209×   89×     89× 89×   85× 40× 40×   40×   45× 29×   16×                               234×                         20× 20× 20×     40× 40× 40× 40× 40× 40× 40× 40× 37×             32× 32×   32×   37× 10×   37× 37× 37× 311× 37×           20× 20× 20× 20× 20× 20× 20× 20× 20×       14× 14× 14× 14× 14× 14× 13× 13× 13× 13× 13× 13× 13×       13× 13× 13× 13× 52× 13× 13×       30× 30× 30× 30× 30× 28× 28× 28× 28× 28×   28× 28×       36× 36× 36× 36× 36× 36× 36× 36× 14× 14×               14× 14× 34× 34× 34× 34× 34× 34× 34× 27× 27× 27×         14× 34× 34×   14×   14× 14× 14×     22× 22×     22× 22× 22× 42× 42× 42× 42× 41×               42× 42× 42× 42× 42× 42× 78× 78×       22× 22× 42× 42×   22×   22× 22× 22×     72× 72×   71× 71× 70× 70× 70×   69× 20× 20×     19×   20× 24× 24× 24×     69× 40×   10× 10× 10× 10× 10× 10× 10× 10× 10×         65× 65× 65× 65× 65× 65× 65× 65× 65× 25× 25× 25×             10× 10×   10× 10×               47× 46×   46× 40× 40× 40×            
define(["require", "exports", "@syncfusion/ej2-base", "../models/columns", "../base/constant", "../base/css-constant"], function (require, exports, ej2_base_1, columns_1, events, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Action = (function () {
        function Action(parent) {
            this.parent = parent;
            this.columnToggleArray = [];
            this.selectionArray = [];
            this.lastCardSelection = null;
            this.lastSelectionRow = null;
            this.lastCard = null;
            this.selectedCardsElement = [];
            this.selectedCardsData = [];
            this.hideColumnKeys = [];
        }
        Action.prototype.clickHandler = function (e) {
            var elementSelector = '.' + cls.CARD_CLASS + ',.' + cls.HEADER_ICON_CLASS + ',.' + cls.CONTENT_ROW_CLASS + '.' +
                cls.SWIMLANE_ROW_CLASS + ',.' + cls.SHOW_ADD_BUTTON + ',.' + cls.FROZEN_SWIMLANE_ROW_CLASS + ',.' + cls.CONTENT_ROW_CLASS +
                ':not(.' + cls.SWIMLANE_ROW_CLASS + ') .' + cls.CONTENT_CELLS_CLASS;
            var target = ej2_base_1.closest(e.target, elementSelector);
            if (!target) {
                return;
            }
            if (target.classList.contains(cls.CARD_CLASS)) {
                Eif (this.parent.allowKeyboard) {
                    this.parent.keyboardModule.cardTabIndexRemove();
                }
                this.cardClick(e);
            }
            else if (target.classList.contains(cls.HEADER_ICON_CLASS)) {
                this.columnExpandCollapse(e);
            }
            else if (target.classList.contains(cls.CONTENT_ROW_CLASS) && target.classList.contains(cls.SWIMLANE_ROW_CLASS)) {
                this.rowExpandCollapse(e);
            }
            else if (target.classList.contains(cls.SHOW_ADD_BUTTON)) {
                this.addButtonClick(target);
            }
            else Iif (target.classList.contains(cls.FROZEN_SWIMLANE_ROW_CLASS)) {
                var swimlaneRows = [].slice.call(this.parent.element.querySelectorAll('.' + cls.SWIMLANE_ROW_CLASS));
                var targetIcon = this.parent.layoutModule.frozenSwimlaneRow.querySelector('.' + cls.ICON_CLASS);
                this.rowExpandCollapse(e, swimlaneRows[this.parent.layoutModule.frozenOrder]);
                var isCollapsed = targetIcon.classList.contains(cls.SWIMLANE_ROW_COLLAPSE_CLASS) ? true : false;
                if (isCollapsed) {
                    ej2_base_1.classList(targetIcon, [cls.SWIMLANE_ROW_EXPAND_CLASS], [cls.SWIMLANE_ROW_COLLAPSE_CLASS]);
                }
                else {
                    ej2_base_1.classList(targetIcon, [cls.SWIMLANE_ROW_COLLAPSE_CLASS], [cls.SWIMLANE_ROW_EXPAND_CLASS]);
                }
            }
        };
        Action.prototype.addButtonClick = function (target) {
            var _this = this;
            var newData = {};
            if (this.parent.kanbanData.length === 0) {
                newData[this.parent.cardSettings.headerField] = 1;
            }
            else Eif (typeof (this.parent.kanbanData[0])[this.parent.cardSettings.headerField] === 'number') {
                var id = this.parent.kanbanData.map(function (obj) {
                    return parseInt(obj[_this.parent.cardSettings.headerField], 10);
                });
                newData[this.parent.cardSettings.headerField] = Math.max.apply(Math, id) + 1;
            }
            newData[this.parent.keyField] = ej2_base_1.closest(target, '.' + cls.CONTENT_CELLS_CLASS).getAttribute('data-key');
            if (this.parent.sortSettings.sortBy === 'Index') {
                newData[this.parent.sortSettings.field] = 1;
                if (ej2_base_1.closest(target, '.' + cls.CONTENT_CELLS_CLASS).querySelector('.' + cls.CARD_CLASS)) {
                    var card = this.parent.sortSettings.direction === 'Ascending' ?
                        target.nextElementSibling.classList.contains(cls.BORDER_CLASS) ?
                            target.nextElementSibling.nextElementSibling.lastElementChild : target.nextElementSibling.lastElementChild
                        : target.nextElementSibling.classList.contains(cls.BORDER_CLASS) ?
                            target.nextElementSibling.nextElementSibling.firstElementChild : target.nextElementSibling.firstElementChild;
                    var data = this.parent.getCardDetails(card);
                    newData[this.parent.sortSettings.field] = data[this.parent.sortSettings.field] + 1;
                }
            }
            if (this.parent.kanbanData.length !== 0 && this.parent.swimlaneSettings.keyField &&
                ej2_base_1.closest(target, '.' + cls.CONTENT_ROW_CLASS).previousElementSibling) {
                newData[this.parent.swimlaneSettings.keyField] =
                    ej2_base_1.closest(target, '.' + cls.CONTENT_ROW_CLASS).previousElementSibling.getAttribute('data-key');
            }
            this.parent.openDialog('Add', newData);
        };
        Action.prototype.doubleClickHandler = function (e) {
            var target = ej2_base_1.closest(e.target, '.' + cls.CARD_CLASS);
            Eif (target) {
                this.cardDoubleClick(e);
            }
        };
        Action.prototype.cardClick = function (e, selectedCard) {
            var _this = this;
            var target = ej2_base_1.closest((selectedCard) ? selectedCard : e.target, '.' + cls.CARD_CLASS);
            var cardClickObj = this.parent.getCardDetails(target);
            Eif (cardClickObj) {
                this.parent.activeCardData = { data: cardClickObj, element: target };
                var args = { data: cardClickObj, element: target, cancel: false, event: e };
                this.parent.trigger(events.cardClick, args, function (clickArgs) {
                    if (!clickArgs.cancel) {
                        if (target.classList.contains(cls.CARD_SELECTION_CLASS) && e.type === 'click') {
                            ej2_base_1.removeClass([target], cls.CARD_SELECTION_CLASS);
                            Iif (_this.parent.enableVirtualization) {
                                _this.parent.virtualLayoutModule.disableAttributeSelection(target);
                            }
                            else {
                                _this.parent.layoutModule.disableAttributeSelection(target);
                            }
                        }
                        else {
                            var isCtrlKey = e.ctrlKey;
                            if (_this.parent.isAdaptive && _this.parent.touchModule) {
                                isCtrlKey = (_this.parent.touchModule.mobilePopup && _this.parent.touchModule.tabHold) || isCtrlKey;
                            }
                            _this.cardSelection(target, isCtrlKey, e.shiftKey);
                        }
                        if (_this.parent.isAdaptive && _this.parent.touchModule) {
                            _this.parent.touchModule.updatePopupContent();
                        }
                        var cell = ej2_base_1.closest(target, '.' + cls.CONTENT_CELLS_CLASS);
                        Eif (_this.parent.allowKeyboard) {
                            var element = [].slice.call(cell.querySelectorAll('.' + cls.CARD_CLASS));
                            element.forEach(function (e) { e.setAttribute('tabindex', '0'); });
                            _this.parent.keyboardModule.addRemoveTabIndex('Remove');
                        }
                    }
                });
            }
        };
        Action.prototype.cardDoubleClick = function (e) {
            var _this = this;
            var target = ej2_base_1.closest(e.target, '.' + cls.CARD_CLASS);
            var cardDoubleClickObj = this.parent.getCardDetails(target);
            this.parent.activeCardData = { data: cardDoubleClickObj, element: target };
            this.cardSelection(target, false, false);
            var args = { data: cardDoubleClickObj, element: target, cancel: false, event: e };
            this.parent.trigger(events.cardDoubleClick, args, function (doubleClickArgs) {
                Eif (!doubleClickArgs.cancel) {
                    _this.parent.dialogModule.openDialog('Edit', args.data);
                }
            });
        };
        Action.prototype.rowExpandCollapse = function (e, isFrozenElem) {
            var _this = this;
            var headerTarget = (e instanceof HTMLElement) ? e : e.target;
            var currentSwimlaneHeader = !ej2_base_1.isNullOrUndefined(isFrozenElem) ? isFrozenElem : headerTarget;
            var args = { cancel: false, target: headerTarget, requestType: 'rowExpandCollapse' };
            this.parent.trigger(events.actionBegin, args, function (actionArgs) {
                if (!actionArgs.cancel) {
                    var target = ej2_base_1.closest(currentSwimlaneHeader, '.' + cls.SWIMLANE_ROW_CLASS);
                    var key = target.getAttribute('data-key');
                    var tgtRow = _this.parent.element.querySelector('.' + cls.CONTENT_ROW_CLASS + (":nth-child(" + (target.rowIndex + 2) + ")"));
                    var targetIcon = target.querySelector("." + cls.SWIMLANE_ROW_EXPAND_CLASS + ",." + cls.SWIMLANE_ROW_COLLAPSE_CLASS);
                    var isCollapsed = target.classList.contains(cls.COLLAPSED_CLASS) ? true : false;
                    var tabIndex_1;
                    if (isCollapsed) {
                        ej2_base_1.removeClass([tgtRow, target], cls.COLLAPSED_CLASS);
                        ej2_base_1.classList(targetIcon, [cls.SWIMLANE_ROW_EXPAND_CLASS], [cls.SWIMLANE_ROW_COLLAPSE_CLASS]);
                        _this.parent.swimlaneToggleArray.splice(_this.parent.swimlaneToggleArray.indexOf(key), 1);
                        tabIndex_1 = '0';
                    }
                    else {
                        ej2_base_1.addClass([tgtRow, target], cls.COLLAPSED_CLASS);
                        ej2_base_1.classList(targetIcon, [cls.SWIMLANE_ROW_COLLAPSE_CLASS], [cls.SWIMLANE_ROW_EXPAND_CLASS]);
                        _this.parent.swimlaneToggleArray.push(key);
                        tabIndex_1 = '-1';
                    }
                    targetIcon.setAttribute('aria-label', isCollapsed ? key + ' Expand' : key + ' Collapse');
                    target.setAttribute('aria-expanded', isCollapsed.toString());
                    tgtRow.setAttribute('aria-expanded', isCollapsed.toString());
                    var rows = [].slice.call(tgtRow.querySelectorAll('.' + cls.CONTENT_CELLS_CLASS));
                    rows.forEach(function (cell) { cell.setAttribute('tabindex', tabIndex_1); });
                    _this.parent.notify(events.contentReady, {});
                    _this.parent.trigger(events.actionComplete, { target: headerTarget, requestType: 'rowExpandCollapse' });
                }
            });
        };
        Action.prototype.columnExpandCollapse = function (e) {
            var _this = this;
            var headerTarget = (e instanceof HTMLElement) ? e : e.target;
            var args = { cancel: false, target: headerTarget, requestType: 'columnExpandCollapse' };
            this.parent.trigger(events.actionBegin, args, function (actionArgs) {
                if (!actionArgs.cancel) {
                    var target = ej2_base_1.closest(headerTarget, '.' + cls.HEADER_CELLS_CLASS);
                    var colIndex = target.cellIndex;
                    _this.columnToggle(target);
                    var collapsed = _this.parent.element.querySelectorAll("." + cls.HEADER_CELLS_CLASS + "." + cls.COLLAPSED_CLASS).length;
                    if (collapsed === (_this.parent.columns.length - _this.hideColumnKeys.length)) {
                        var index = (colIndex + 1 === collapsed) ? 1 : colIndex + 2;
                        var headerSelector = "." + cls.HEADER_CELLS_CLASS + ":not(." + cls.STACKED_HEADER_CELL_CLASS + "):nth-child(" + index + ")";
                        var nextCol = _this.parent.element.querySelector(headerSelector);
                        ej2_base_1.addClass([nextCol], cls.COLLAPSED_CLASS);
                        _this.columnToggle(nextCol);
                    }
                    _this.parent.notify(events.contentReady, {});
                    _this.parent.trigger(events.actionComplete, { target: headerTarget, requestType: 'columnExpandCollapse' });
                }
            });
        };
        Action.prototype.columnToggle = function (target) {
            var _this = this;
            var colIndex = target.cellIndex;
            var elementSelector = "." + cls.CONTENT_ROW_CLASS + ":not(." + cls.SWIMLANE_ROW_CLASS + ")";
            var targetRow = [].slice.call(this.parent.element.querySelectorAll(elementSelector));
            var colSelector = "." + cls.TABLE_CLASS + " col:nth-child(" + (colIndex + 1) + ")";
            var targetIcon = target.querySelector("." + cls.COLUMN_EXPAND_CLASS + ",." + cls.COLUMN_COLLAPSE_CLASS);
            var colGroup = [].slice.call(this.parent.element.querySelectorAll(colSelector));
            if (target.classList.contains(cls.COLLAPSED_CLASS)) {
                ej2_base_1.removeClass(colGroup, cls.COLLAPSED_CLASS);
                Iif (this.parent.isAdaptive) {
                    if (this.parent.enableVirtualization) {
                        colGroup.forEach(function (col) { return col.style.width = ej2_base_1.formatUnit(_this.parent.virtualLayoutModule.getWidth()); });
                    }
                    else {
                        colGroup.forEach(function (col) { return col.style.width = ej2_base_1.formatUnit(_this.parent.layoutModule.getWidth()); });
                    }
                }
                ej2_base_1.classList(targetIcon, [cls.COLUMN_EXPAND_CLASS], [cls.COLUMN_COLLAPSE_CLASS]);
                var _loop_1 = function (row) {
                    var targetCol = row.querySelector("." + cls.CONTENT_CELLS_CLASS + ":nth-child(" + (colIndex + 1) + ")");
                    ej2_base_1.removeClass([targetCol, target], cls.COLLAPSED_CLASS);
                    ej2_base_1.remove(targetCol.querySelector('.' + cls.COLLAPSE_HEADER_TEXT_CLASS));
                    target.setAttribute('aria-expanded', 'true');
                    targetCol.setAttribute('aria-expanded', 'true');
                    var collapsedCell = [].slice.call(targetCol.parentElement.querySelectorAll('.' + cls.COLLAPSED_CLASS));
                    collapsedCell.forEach(function (cell) {
                        var collapasedText = cell.querySelector('.' + cls.COLLAPSE_HEADER_TEXT_CLASS);
                        collapasedText.style.height = 'auto';
                        Iif (collapasedText && targetCol.getBoundingClientRect().height < (collapasedText.getBoundingClientRect().height + 10)) {
                            collapasedText.style.height = (targetCol.getBoundingClientRect().height - 4) + 'px';
                        }
                    });
                };
                for (var _i = 0, targetRow_1 = targetRow; _i < targetRow_1.length; _i++) {
                    var row = targetRow_1[_i];
                    _loop_1(row);
                }
                if (this.parent.kanbanData.length === 0 && targetRow.length === 0) {
                    ej2_base_1.removeClass([target], cls.COLLAPSED_CLASS);
                    target.setAttribute('aria-expanded', 'true');
                }
                this.columnToggleArray.splice(this.columnToggleArray.indexOf(target.getAttribute('data-key')), 1);
                this.parent.columns[colIndex].setProperties({ isExpanded: true }, true);
                target.querySelector('.e-header-icon').setAttribute('aria-label', target.getAttribute('data-key') + ' Expand');
            }
            else {
                ej2_base_1.addClass(colGroup, cls.COLLAPSED_CLASS);
                Iif (this.parent.isAdaptive) {
                    colGroup.forEach(function (col) { return col.style.width = ej2_base_1.formatUnit(events.toggleWidth); });
                }
                ej2_base_1.classList(targetIcon, [cls.COLUMN_COLLAPSE_CLASS], [cls.COLUMN_EXPAND_CLASS]);
                var key = target.getAttribute('data-key');
                var _loop_2 = function (row) {
                    var targetCol = row.querySelector("." + cls.CONTENT_CELLS_CLASS + "[data-key=\"" + key + "\"]");
                    var index = targetCol.cellIndex;
                    var text = void 0;
                    if (!this_1.parent.enableVirtualization) {
                        text = (this_1.parent.columns[index].showItemCount ? '[' +
                            targetCol.querySelectorAll('.' + cls.CARD_CLASS).length + '] ' : '') + this_1.parent.columns[index].headerText;
                    }
                    else {
                        var value = this_1.parent.dataModule.isRemote() ?
                            this_1.parent.columnDataCount[this_1.parent.columns[index].keyField]
                            : this_1.parent.virtualLayoutModule.columnData[this_1.parent.columns[index].keyField].length;
                        text = (this_1.parent.columns[index].showItemCount ? '[' +
                            value + '] ' : '') + this_1.parent.columns[index].headerText;
                    }
                    targetCol.appendChild(ej2_base_1.createElement('div', { className: cls.COLLAPSE_HEADER_TEXT_CLASS, innerHTML: text }));
                    ej2_base_1.addClass([targetCol, target], cls.COLLAPSED_CLASS);
                    target.setAttribute('aria-expanded', 'false');
                    targetCol.setAttribute('aria-expanded', 'false');
                    var collapsedCell = [].slice.call(targetCol.parentElement.querySelectorAll('.' + cls.COLLAPSED_CLASS));
                    collapsedCell.forEach(function (cell) {
                        var collapasedText = cell.querySelector('.' + cls.COLLAPSE_HEADER_TEXT_CLASS);
                        if (collapasedText && targetCol.getBoundingClientRect().height < (collapasedText.getBoundingClientRect().height + 10)) {
                            collapasedText.style.height = (targetCol.getBoundingClientRect().height - 4) + 'px';
                        }
                    });
                };
                var this_1 = this;
                for (var _a = 0, targetRow_2 = targetRow; _a < targetRow_2.length; _a++) {
                    var row = targetRow_2[_a];
                    _loop_2(row);
                }
                if (this.parent.kanbanData.length === 0 && targetRow.length === 0) {
                    ej2_base_1.addClass([target], cls.COLLAPSED_CLASS);
                    target.setAttribute('aria-expanded', 'false');
                }
                this.columnToggleArray.push(target.getAttribute('data-key'));
                this.parent.columns[colIndex].setProperties({ isExpanded: false }, true);
                target.querySelector('.e-header-icon').setAttribute('aria-label', key + ' Collapse');
            }
        };
        Action.prototype.cardSelection = function (target, isCtrl, isShift) {
            var _this = this;
            if (!target) {
                return;
            }
            var cards = this.parent.getSelectedCards();
            if (this.parent.cardSettings.selectionType !== 'None') {
                var contentRow = ej2_base_1.closest(target, '.' + cls.CONTENT_ROW_CLASS);
                var index = !ej2_base_1.isNullOrUndefined(this.lastSelectionRow) ? this.lastSelectionRow.rowIndex : contentRow.rowIndex;
                if (index !== contentRow.rowIndex && (isCtrl || isShift) && this.parent.cardSettings.selectionType === 'Multiple') {
                    return;
                }
                if (cards.length !== 0 && (!isCtrl || this.parent.cardSettings.selectionType === 'Single')) {
                    ej2_base_1.removeClass(cards, cls.CARD_SELECTION_CLASS);
                    if (this.parent.enableVirtualization) {
                        this.parent.virtualLayoutModule.disableAttributeSelection(cards);
                    }
                    else {
                        this.parent.layoutModule.disableAttributeSelection(cards);
                    }
                    cards.forEach(function (el) {
                        _this.selectionArray.splice(_this.selectionArray.indexOf(el.getAttribute('data-id')), 1);
                        _this.selectedCardsElement.splice(_this.selectedCardsElement.indexOf(el), 1);
                        _this.selectedCardsData.splice(_this.selectedCardsData.indexOf(_this.parent.getCardDetails(el), 1));
                    });
                }
                if (cards.length > 0 && isShift && this.parent.cardSettings.selectionType === 'Multiple') {
                    var curCards_1 = [];
                    var start = void 0;
                    var end = void 0;
                    var i = void 0;
                    var allCards = [].slice.call(contentRow.querySelectorAll('.' + cls.CARD_CLASS));
                    allCards.forEach(function (el) { return curCards_1.push(el.getAttribute('data-id')); });
                    var curId = target.getAttribute('data-id');
                    var lastId = this.lastCard.getAttribute('data-id');
                    var curIndex = end = curCards_1.indexOf(curId);
                    var lastIndex = start = curCards_1.indexOf(lastId);
                    var select = curIndex > lastIndex ? 'next' : 'prev';
                    if (select === 'prev') {
                        start = curIndex;
                        end = lastIndex;
                    }
                    for (i = start; i <= end; i++) {
                        var card = allCards[i];
                        ej2_base_1.addClass([card], cls.CARD_SELECTION_CLASS);
                        card.setAttribute('aria-selected', 'true');
                        card.setAttribute('tabindex', '0');
                        this.selectionArray.push(card.getAttribute('data-id'));
                        this.selectedCardsElement.push(card);
                        this.selectedCardsData.push(this.parent.getCardDetails(card));
                        this.lastCardSelection = card;
                        if (select === 'prev') {
                            this.lastCardSelection = allCards[start];
                        }
                    }
                }
                else {
                    ej2_base_1.addClass([target], cls.CARD_SELECTION_CLASS);
                    target.setAttribute('aria-selected', 'true');
                    target.setAttribute('tabindex', '0');
                    this.selectionArray.push(target.getAttribute('data-id'));
                    this.selectedCardsElement.push(target);
                    this.selectedCardsData.push(this.parent.getCardDetails(target));
                    this.lastCard = this.lastCardSelection = target;
                    this.lastSelectionRow = ej2_base_1.closest(target, '.' + cls.CONTENT_ROW_CLASS);
                    if (this.lastSelectionRow.previousElementSibling) {
                        var elementSelector = "." + cls.SWIMLANE_ROW_EXPAND_CLASS + ",." + cls.SWIMLANE_ROW_COLLAPSE_CLASS;
                        var parentEle = this.lastSelectionRow.previousElementSibling.querySelector(elementSelector);
                        if (parentEle && parentEle.classList.contains(cls.SWIMLANE_ROW_COLLAPSE_CLASS)) {
                            this.rowExpandCollapse(parentEle);
                        }
                    }
                }
            }
        };
        Action.prototype.addColumn = function (columnOptions, index) {
            var addColumn = ej2_base_1.createInstance(columns_1.Columns, [this.parent, 'columns', columnOptions, true]);
            this.parent.columns.splice(index, 0, addColumn);
            this.parent.notify(events.dataReady, { processedData: this.parent.kanbanData });
        };
        Action.prototype.deleteColumn = function (index) {
            var listKey = this.parent.element.querySelectorAll('.' + cls.HEADER_CELLS_CLASS).item(index);
            if (listKey && listKey.classList.contains(cls.HEADER_ROW_TOGGLE_CLASS)) {
                this.columnToggleArray.splice(this.columnToggleArray.indexOf(listKey.getAttribute('data-key'), 0));
            }
            this.parent.columns.splice(index, 1);
            if (this.parent.columns.length === 0) {
                ej2_base_1.detach(this.parent.element.querySelector('.' + cls.HEADER_CLASS));
                ej2_base_1.detach(this.parent.element.querySelector('.' + cls.CONTENT_CLASS));
            }
            else {
                this.parent.notify(events.dataReady, { processedData: this.parent.kanbanData });
            }
        };
        Action.prototype.showColumn = function (key) {
            var index = this.hideColumnKeys.indexOf(key.toString());
            if (index !== -1) {
                this.hideColumnKeys.splice(index, 1);
                this.parent.notify(events.dataReady, { processedData: this.parent.kanbanData });
            }
        };
        Action.prototype.hideColumn = function (key) {
            this.hideColumnKeys.push(key.toString());
            this.parent.notify(events.dataReady, { processedData: this.parent.kanbanData });
        };
        Action.prototype.SingleCardSelection = function (data) {
            if (this.parent.cardSettings.selectionType !== 'None' && data[this.parent.cardSettings.headerField]) {
                var card = this.parent.element.querySelector('.e-card[data-id=\"' +
                    data[this.parent.cardSettings.headerField].toString() + '"\]');
                if (card) {
                    ej2_base_1.addClass([card], cls.CARD_SELECTION_CLASS);
                    card.setAttribute('aria-selected', 'true');
                    card.setAttribute('tabindex', '0');
                }
            }
        };
        return Action;
    }());
    exports.Action = Action;
});