Skip to content

Commit

Permalink
db-tabulator: fix header_template when used without row_template
Browse files Browse the repository at this point in the history
!restart
  • Loading branch information
siddharthvp committed Nov 27, 2023
1 parent c2ca135 commit 8f362f5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions db-tabulator/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,22 @@ export class Query {

let table: InstanceType<typeof Mwn.table>;
let tableText = '';
// NOTE: header_template appears:
// - above table start if row_template is not being used
// - below table start if row_template is being used
if (header_template && (skip_table || !row_template)) {
tableText = '{{' + header_template + '}}\n';
}
if (!skip_table) {
table = new Mwn.table({
style: table_style,
classes: table_class,
sortable: table_class.includes('sortable'),
plain: !table_class.includes('wikitable')
});
if (header_template) {
tableText = table.text + '{{' + header_template + '}}\n';
}
if (!row_template) {
// row_template not being used? Add table headers, possibly in addition to the header_template.
if (header_template && row_template) {
tableText += table.text + '{{' + header_template + '}}\n';
} else {
table.addHeaders(Object.keys(result[0]).map((columnName, columnIndex) => {
let columnConfig: { label: string, style?: string } = {
label: columnName,
Expand All @@ -486,11 +490,7 @@ export class Query {
}
return columnConfig;
}));
tableText = table.text;
}
} else {
if (header_template) {
tableText = '{{' + header_template + '}}\n';
tableText += table.text;
}
}

Expand Down

0 comments on commit 8f362f5

Please sign in to comment.