chore(check-all): removed checkrange from checkall

This commit is contained in:
Johannes Eder 2021-09-21 17:15:32 +02:00
parent 7d8fc4301b
commit c28dca7b76

View File

@ -37,44 +37,16 @@ export class CheckAll {
if (DEBUG_MODE > 0)
console.log(this._columns);
//Todo: 1 forEach loop
let checkboxColumns = this._findCheckboxColumns();
checkboxColumns.forEach(columnId => this._checkAllColumns.push(new CheckAllColumn(this._element, app, this._columns[columnId])));
checkboxColumns.forEach(columnId => {
let currentColumn = this._columns[columnId];
currentColumn.forEach(el => el.addEventListener('click', (ev) => {
if(ev.shiftKey && this.lastCheckedCell !== null) {
let lastClickedIndex = this._tableIndices.rowIndex(this._lastCheckedCell);
let currentCellIndex = this._tableIndices.rowIndex(el);
if(currentCellIndex > lastClickedIndex)
this._checkMultipleCells(lastClickedIndex, currentCellIndex, columnId);
else
this._checkMultipleCells(currentCellIndex, lastClickedIndex, columnId);
} else {
this._lastCheckedCell = el;
}
}));
});
// mark initialized
this._element.classList.add(CHECK_ALL_INITIALIZED_CLASS);
}
_checkMultipleCells(firstRowIndex, lastRowIndex, columnId) {
for(let i=firstRowIndex; i<=lastRowIndex; i++) {
let cell = this._columns[columnId][i];
if (cell.tagName !== 'TH') {
cell.querySelector(CHECKBOX_SELECTOR).checked = true;
}
}
}
_gatherColumns() {
for (const rowIndex of Array(this._tableIndices.maxRow + 1).keys()) {
for (const colIndex of Array(this._tableIndices.maxCol + 1).keys()) {