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

#222 Save sheets when there is only 1 or zero lines in the sheet #230

Merged
merged 1 commit into from
Oct 8, 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
14 changes: 4 additions & 10 deletions blocks/edit/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,11 @@
return acc;
}, []);

// Remove trailing empty rows
let emptyRow = true;
while (emptyRow) {
const lastRow = data.slice(-1)[0];
const filled = Object.keys(lastRow).some((key) => lastRow[key]);
if (!filled) {
data.pop();
} else {
emptyRow = false;
}
// Remove trailing empty rows - leave one data row if all data is empty
while (data.length > 1 && !Object.values(data.slice(-1)[0]).some(Boolean)) {
data.pop();
}

return data;
}

Expand Down Expand Up @@ -215,7 +209,7 @@
try {
await daFetch(fullPath, opts);
} catch {
console.log('Error creating auto version on publish.');

Check warning on line 212 in blocks/edit/utils/helpers.js

View workflow job for this annotation

GitHub Actions / Running tests (20.x)

Unexpected console statement
}
}

Expand Down
1 change: 1 addition & 0 deletions blocks/sheet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function getDefaultSheet() {
}

function getSheetData(sheetData) {
if (!sheetData?.length) return [[], []];
const header = Object.keys(sheetData[0]).map((key) => key);
const data = sheetData.reduce((acc, item) => {
const values = Object.keys(item).map((key) => item[key]);
Expand Down
Loading