Skip to content

Commit

Permalink
fix: show empty table when header is invalid
Browse files Browse the repository at this point in the history
Refs: #113
  • Loading branch information
kunfang98927 committed Jul 12, 2024
1 parent 2d2001a commit be86a25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/Editor/ColumnTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export class ColumnTools {
*/
convertMeiQuoteSign(body: any[]) {
for (let i = 0; i < body.length; i++) {
if (body[i].mei === undefined) {
continue;
}
body[i].mei = body[i].mei.replace(//g, '"').replace(//g, '"');
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Editor/CressTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class CressTable {
private validationTools: ValidationTools;
private exportTools: ExportTools;
private columnTools: ColumnTools;
private defaultHeader = ['image', 'name', 'classification', 'mei'];

constructor(id: string, inputHeader: string[], body: any[]) {
const container = document.getElementById('hot-container');
Expand Down Expand Up @@ -57,9 +58,8 @@ export class CressTable {
);

// Prepare table configuration
const headers = ['image', 'name', 'classification', 'mei'];
const columns = this.columnTools.getColumns(headers);
const colWidths = this.columnTools.getColWidths(headers);
const columns = this.columnTools.getColumns(this.defaultHeader);
const colWidths = this.columnTools.getColWidths(this.defaultHeader);
const indices = this.columnTools.getIndices(body).map(String);

// Process images
Expand All @@ -85,7 +85,7 @@ export class CressTable {
colWidths: colWidths,
columns: columns,
rowHeaders: indices,
colHeaders: headers,
colHeaders: this.defaultHeader,
stretchH: 'all',
minSpareRows: 0,
autoWrapRow: true,
Expand All @@ -97,7 +97,7 @@ export class CressTable {
afterChange: (changes, source) => this.validateMei(changes, source),
});

this.initFileListener(id, inputHeader, body, headers);
this.initFileListener(id, inputHeader, body, this.defaultHeader);
this.initChangeListener();
}

Expand Down

0 comments on commit be86a25

Please sign in to comment.