Skip to content

Commit

Permalink
[#11084] Remove error highlighting on a new enrollment (#11089)
Browse files Browse the repository at this point in the history
* Remove error highlighting on a new submit

* Add variable for last col index
  • Loading branch information
daongochieu2810 authored Apr 6, 2021
1 parent 3c2fd02 commit e36c2fd
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,21 @@ export class InstructorCourseEnrollPageComponent implements OnInit {
this.allStudentChunks = [];
this.invalidRowsIndex = new Set();

const lastColIndex: number = 4;
const newStudentsHOTInstance: Handsontable =
this.hotRegisterer.getInstance(this.newStudentsHOT);
const hotInstanceColHeaders: string[] = (newStudentsHOTInstance.getColHeader() as string[]);

// Reset error highlighting on a new submission
this.resetTableStyle(newStudentsHOTInstance, 0,
newStudentsHOTInstance.getData().length - 1,
0,
hotInstanceColHeaders.indexOf(this.colHeaders[lastColIndex]));

// Remove error highlight on click
newStudentsHOTInstance.addHook('afterSelectionEnd', (row: number, column: number,
row2: number, column2: number) => {
this.resetTableStyleOnClick(newStudentsHOTInstance, row, row2, column, column2);
this.resetTableStyle(newStudentsHOTInstance, row, row2, column, column2);
});

// Record the row with its index on the table
Expand Down Expand Up @@ -319,7 +326,7 @@ export class InstructorCourseEnrollPageComponent implements OnInit {
}
}

private resetTableStyleOnClick(newStudentsHOTInstance: Handsontable,
private resetTableStyle(newStudentsHOTInstance: Handsontable,
startRow: number, endRow: number, startCol: number, endCol: number): void {
for (let row: number = startRow; row <= endRow; row += 1) {
for (let col: number = startCol; col <= endCol; col += 1) {
Expand Down

0 comments on commit e36c2fd

Please sign in to comment.