Skip to content

Commit

Permalink
fix(Table): Make sure correct cells are editable by students (#730)
Browse files Browse the repository at this point in the history
- Set correct row indexes of editable cells in Tabulator
- Update correct row on edit of custom sorted table
- Set correct cells as editable with custom sorting

#727
  • Loading branch information
breity authored Aug 13, 2022
1 parent 9baa15b commit 30a003d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/services/tabulatorDataService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function convertTableDataToTabulator() {
expect(tabulatorData.data.length).toBe(3);
expect(tabulatorData.data[1]['0']).toBe('10');
expect(tabulatorData.options.maxHeight).toBe('500px');
expect(tabulatorData.editableCells[0]).toEqual(['1','2']);
expect(tabulatorData.editableCells[1]).toEqual(['1', '2']);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ export class TableStudent extends ComponentStudent {

tabulatorCellChanged(cell: Tabulator.CellComponent): void {
const columnIndex = parseInt(cell.getColumn().getField());
const rowIndex = cell.getRow().getPosition() + 1;
const rowIndex = cell.getRow().getIndex() + 1;
this.tableData[rowIndex][columnIndex].text = cell.getValue();
this.studentDataChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class TabulatorTableComponent implements OnChanges, AfterViewInit {
}

private isCellEditable(cell: Tabulator.CellComponent): boolean {
const rowIndex = cell.getRow().getPosition();
const rowIndex = cell.getRow().getIndex() + 1;
const field = cell.getColumn().getField();
const row = this.editableCells[rowIndex];
return row && row.includes(field);
Expand Down
2 changes: 1 addition & 1 deletion src/assets/wise5/components/table/tabulatorDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class TabulatorDataService {
const rowData = this.getTabulatorRowDataFromTableRow(row, content.columns);
rowData.values.id = rowIndex;
content.data.push(rowData.values);
content.editableCells[rowIndex] = rowData.editableCells;
content.editableCells[index] = rowData.editableCells;
}
}
return content;
Expand Down

0 comments on commit 30a003d

Please sign in to comment.