Skip to content

Commit 6e50560

Browse files
Cleaned up table authoring code. #2902
1 parent 8d8c815 commit 6e50560

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/main/webapp/wise5/components/table/table-authoring/table-authoring.component.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class TableAuthoring extends ComponentAuthoring {
104104
isRowEmpty(rowIndex: number): boolean {
105105
const tableData = this.authoringComponentContent.tableData;
106106
for (const cell of tableData[rowIndex]) {
107-
if (cell.text != null && cell.text != '') {
107+
if (!this.isEmpty(cell.text)) {
108108
return false;
109109
}
110110
}
@@ -142,13 +142,17 @@ export class TableAuthoring extends ComponentAuthoring {
142142
isColumnEmpty(columnIndex: number): boolean {
143143
for (const row of this.authoringComponentContent.tableData) {
144144
const cell = row[columnIndex];
145-
if (cell.text != null && cell.text != '') {
145+
if (!this.isEmpty(cell.text)) {
146146
return false;
147147
}
148148
}
149149
return true;
150150
}
151151

152+
isEmpty(txt: string): boolean {
153+
return txt == null || txt == '';
154+
}
155+
152156
tableSizeChanged(): void {
153157
this.authoringComponentContent.tableData = this.getUpdatedTable(
154158
this.authoringComponentContent.numRows,
@@ -301,11 +305,8 @@ export class TableAuthoring extends ComponentAuthoring {
301305
}
302306

303307
setAllCellsIsEditable(isEditable: boolean): void {
304-
const tableData = this.authoringComponentContent.tableData;
305-
for (let r = 0; r < tableData.length; r++) {
306-
const row = tableData[r];
307-
for (let c = 0; c < row.length; c++) {
308-
const cell = row[c];
308+
for (const row of this.authoringComponentContent.tableData) {
309+
for (const cell of row) {
309310
cell.editable = isEditable;
310311
}
311312
}

0 commit comments

Comments
 (0)