Skip to content

Commit d125cbf

Browse files
committed
Cleaned up some Table authoring code. #2902
1 parent 6e50560 commit d125cbf

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,23 @@
1313
<mat-label i18n>Columns</mat-label>
1414
<input matInput
1515
type="number"
16+
min="1"
1617
[(ngModel)]="authoringComponentContent.numColumns"
1718
(ngModelChange)="numColumnsChange.next($event)">
1819
</mat-form-field>
1920
<mat-form-field class="size-input">
2021
<mat-label i18n>Rows</mat-label>
2122
<input matInput
2223
type="number"
24+
min="1"
2325
[(ngModel)]="authoringComponentContent.numRows"
2426
(ngModelChange)="numRowsChange.next($event)"/>
2527
</mat-form-field>
2628
<mat-form-field class="size-input">
2729
<mat-label i18n>Global Cell Size</mat-label>
2830
<input matInput
2931
type="number"
32+
min="1"
3033
[(ngModel)]="authoringComponentContent.globalCellSize"
3134
(ngModelChange)="globalCellSizeChange.next($event)"/>
3235
</mat-form-field>
@@ -152,6 +155,7 @@
152155
<mat-label i18n>Column Cell Size</mat-label>
153156
<input matInput
154157
type="number"
158+
min="1"
155159
[(ngModel)]="columnCellSizes[cellIndex]"
156160
(ngModelChange)="columnSizeChanged(cellIndex)"/>
157161
</mat-form-field>

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class TableAuthoring extends ComponentAuthoring {
209209
};
210210
}
211211

212-
insertRow(y: number): void {
212+
insertRow(rowIndex: number): void {
213213
const tableData = this.authoringComponentContent.tableData;
214214
const newRow = [];
215215
const numColumns = this.authoringComponentContent.numColumns;
@@ -221,46 +221,42 @@ export class TableAuthoring extends ComponentAuthoring {
221221
}
222222
newRow.push(newCell);
223223
}
224-
tableData.splice(y, 0, newRow);
224+
tableData.splice(rowIndex, 0, newRow);
225225
this.authoringComponentContent.numRows++;
226226
this.componentChanged();
227227
}
228228

229-
deleteRow(y: number): void {
229+
deleteRow(rowIndex: number): void {
230230
if (confirm($localize`Are you sure you want to delete this row?`)) {
231231
const tableData = this.authoringComponentContent.tableData;
232232
if (tableData != null) {
233-
tableData.splice(y, 1);
233+
tableData.splice(rowIndex, 1);
234234
this.authoringComponentContent.numRows--;
235235
}
236236
this.componentChanged();
237237
}
238238
}
239239

240-
insertColumn(x: number): void {
240+
insertColumn(columnIndex: number): void {
241241
const tableData = this.authoringComponentContent.tableData;
242242
const numRows = this.authoringComponentContent.numRows;
243243
for (let r = 0; r < numRows; r++) {
244-
const tempRow = tableData[r];
245-
if (tempRow != null) {
246-
const newCell = this.createEmptyCell();
247-
tempRow.splice(x, 0, newCell);
248-
}
244+
const row = tableData[r];
245+
const newCell = this.createEmptyCell();
246+
row.splice(columnIndex, 0, newCell);
249247
}
250248
this.authoringComponentContent.numColumns++;
251249
this.parseColumnCellSizes(this.authoringComponentContent);
252250
this.componentChanged();
253251
}
254252

255-
deleteColumn(x: number): void {
253+
deleteColumn(columnIndex: number): void {
256254
if (confirm($localize`Are you sure you want to delete this column?`)) {
257255
const tableData = this.authoringComponentContent.tableData;
258256
const numRows = this.authoringComponentContent.numRows;
259257
for (let r = 0; r < numRows; r++) {
260-
const tempRow = tableData[r];
261-
if (tempRow != null) {
262-
tempRow.splice(x, 1);
263-
}
258+
const row = tableData[r];
259+
row.splice(columnIndex, 1);
264260
}
265261
this.authoringComponentContent.numColumns--;
266262
this.parseColumnCellSizes(this.authoringComponentContent);

0 commit comments

Comments
 (0)