Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show empty table when header is invalid #114

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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