FIX: Allow headings to have the same label (#46)

Fixes an issue where multiple headings with the same value would remove
columns from displaying.
This commit is contained in:
Penar Musaraj
2023-02-16 21:16:48 -05:00
committed by GitHub
parent d754e7a2ec
commit b45ffe48b7
6 changed files with 77 additions and 39 deletions
@@ -5,6 +5,7 @@ import {
findTableRegex,
tokenRange,
} from "../discourse-table-builder/lib/utilities";
import Component from "@glimmer/component";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -12,6 +13,7 @@ import I18n from "I18n";
import { schedule } from "@ember/runloop";
import { tracked } from "@glimmer/tracking";
import { localeMapping } from "../discourse-table-builder/lib/locale-mapping";
export default class SpreadsheetEditor extends Component {
@tracked showEditReason = false;
@tracked loading = null;
@@ -244,10 +246,13 @@ export default class SpreadsheetEditor extends Component {
data.forEach((row) => {
const result = {};
headers.forEach((key, index) => (result[key] = row[index]));
headers.forEach((_key, index) => {
const columnKey = `col${index}`;
return (result[columnKey] = row[index]);
});
table.push(result);
});
return arrayToTable(table);
return arrayToTable(table, headers);
}
}