diff --git a/frontend/src/utils/inputs/checkrange.js b/frontend/src/utils/inputs/checkrange.js index 061b4c975..ee6441b95 100644 --- a/frontend/src/utils/inputs/checkrange.js +++ b/frontend/src/utils/inputs/checkrange.js @@ -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()) {