Skip to content

Commit

Permalink
Update TSV
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Mar 11, 2024
1 parent 9da6f66 commit 5409dd5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/renderer/src/stories/BasicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class BasicTable extends LitElement {
validateOnChange,
onStatusChange,
onLoaded,
onUpdate,
} = {}) {
super();
this.name = name ?? "data_table";
Expand All @@ -134,6 +135,7 @@ export class BasicTable extends LitElement {
this.ignore = ignore ?? {};

if (validateOnChange) this.validateOnChange = validateOnChange;
if (onUpdate) this.onUpdate = onUpdate;
if (onStatusChange) this.onStatusChange = onStatusChange;
if (onLoaded) this.onLoaded = onLoaded;
}
Expand Down Expand Up @@ -380,14 +382,16 @@ export class BasicTable extends LitElement {
}, {})
);

console.log('Got', structuredData)

Object.keys(this.data).forEach((row) => delete this.data[row]); // Delete all previous rows
Object.keys(data).forEach((row) => {
const cols = structuredData[row];
const latest = (this.data[this.keyColumn ? cols[this.keyColumn] : row] = {});
Object.entries(cols).forEach(([key, value]) => (key in this.#itemProps ? (latest[key] = value) : "")); // Only include data from schema
});

this.onUpdate(null, null, value); // Update the whole table
if (this.onUpdate) this.onUpdate([], data); // Update the whole table
}

// Render Code
Expand Down

0 comments on commit 5409dd5

Please sign in to comment.