feat(checkrange): unchecking a range is possible
This commit is contained in:
parent
b7073760eb
commit
154f2e35cc
@ -49,16 +49,25 @@ export class CheckRange {
|
||||
if(ev.shiftKey && this.lastCheckedCell !== null) {
|
||||
let lastClickedIndex = this._tableIndices.rowIndex(this._lastCheckedCell);
|
||||
let currentCellIndex = this._tableIndices.rowIndex(el);
|
||||
let cell = this._columns[columnId][currentCellIndex];
|
||||
if(currentCellIndex > lastClickedIndex)
|
||||
this._checkMultipleCells(lastClickedIndex, currentCellIndex, columnId);
|
||||
this._handleCellsInBetween(cell, lastClickedIndex, currentCellIndex, columnId);
|
||||
else
|
||||
this._checkMultipleCells(currentCellIndex, lastClickedIndex, columnId);
|
||||
this._handleCellsInBetween(cell, currentCellIndex, lastClickedIndex, columnId);
|
||||
} else {
|
||||
this._lastCheckedCell = el;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
_handleCellsInBetween(cell, firstRowIndex, lastRowIndex, columnId) {
|
||||
if(this._isChecked(cell)) {
|
||||
this._uncheckMultipleCells(firstRowIndex, lastRowIndex, columnId);
|
||||
} else {
|
||||
this._checkMultipleCells(firstRowIndex, lastRowIndex, columnId);
|
||||
}
|
||||
}
|
||||
|
||||
_checkMultipleCells(firstRowIndex, lastRowIndex, columnId) {
|
||||
for(let i=firstRowIndex; i<=lastRowIndex; i++) {
|
||||
let cell = this._columns[columnId][i];
|
||||
@ -68,6 +77,19 @@ export class CheckRange {
|
||||
}
|
||||
}
|
||||
|
||||
_uncheckMultipleCells(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 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_isChecked(cell) {
|
||||
return cell.querySelector(CHECKBOX_SELECTOR).checked;
|
||||
}
|
||||
|
||||
|
||||
_gatherColumns() {
|
||||
for (const rowIndex of Array(this._tableIndices.maxRow + 1).keys()) {
|
||||
|
||||
Reference in New Issue
Block a user