Skip to content

Commit

Permalink
Merge pull request #114 from DDMAL/fix-invalid-header
Browse files Browse the repository at this point in the history
fix: show empty table when header is invalid
  • Loading branch information
kunfang98927 authored Jul 12, 2024
2 parents ec3761c + 8dfce98 commit ca06fd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Editor/ColumnTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export class ColumnTools {
*/
convertMeiQuoteSign(body: any[]) {
for (let i = 0; i < body.length; i++) {
body[i].mei = body[i].mei.replace(//g, '"').replace(//g, '"');
if (body[i].mei) {
body[i].mei = body[i].mei.replace(//g, '"').replace(//g, '"');
}
}
}
}
10 changes: 5 additions & 5 deletions src/Editor/CressTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class CressTable {
private meiTools: MeiTools;
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 All @@ -54,9 +55,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 @@ -82,7 +82,7 @@ export class CressTable {
colWidths: colWidths,
columns: columns,
rowHeaders: indices,
colHeaders: headers,
colHeaders: this.defaultHeader,
stretchH: 'all',
minSpareRows: 0,
autoWrapRow: true,
Expand All @@ -96,7 +96,7 @@ export class CressTable {
},
});

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

Expand Down

0 comments on commit ca06fd8

Please sign in to comment.