Skip to content

Commit

Permalink
feat: xsl export -- projects shape finishing touches
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeen committed Jan 23, 2022
1 parent d5bfeee commit c3be53a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/climate-warehouse.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/utils/xls.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ export const createXlsFromSequelizeResults = (rows, model) => {
// Populate main sheet values
for (const [mainColName, mainCol] of columnsInMainSheet.entries()) {
if (!Object.keys(sheets).includes(model.name)) {
sheets[model.name] = { name: model.name + 's', data: [model.defaultColumns] }; // Column headings
sheets[model.name] = {
name: model.name + 's',
data: [
columnsInMainSheet
]
}; // Column headings
}

if (!associations.map(singular => singular + 's').includes(mainColName)) {
if (row[mainCol] === null) {
row[mainCol] = 'null';
}
mainXlsRow.push(row[mainCol]);
}

Expand All @@ -55,7 +63,7 @@ export const createXlsFromSequelizeResults = (rows, model) => {
for (const associatedModel of associatedModels) {
const xlsRow = [];
// Column headings for associated sheets will be available for associated sheets once its referenced by a row
if (!Object.keys(sheets).includes(associatedModel) && row[associatedModel + 's'].length > 0) {
if (!Object.keys(sheets).includes(associatedModel) && row[associatedModel].length > 0) {
sheets[associatedModel] = {
name: associatedModel,
data: [
Expand Down

0 comments on commit c3be53a

Please sign in to comment.